Changeset View
Changeset View
Standalone View
Standalone View
plugins/tasklist/tasklist.php
Show First 20 Lines • Show All 1,346 Lines • ▼ Show 20 Lines | public function filter_mask($rec) | ||||
if ($this->driver->is_complete($rec)) | if ($this->driver->is_complete($rec)) | ||||
$mask |= self::FILTER_MASK_COMPLETE; | $mask |= self::FILTER_MASK_COMPLETE; | ||||
if (empty($rec['date'])) | if (empty($rec['date'])) | ||||
$mask |= self::FILTER_MASK_NODATE; | $mask |= self::FILTER_MASK_NODATE; | ||||
else if ($rec['date'] < $today) | else if ($rec['date'] < $today) | ||||
$mask |= self::FILTER_MASK_OVERDUE; | $mask |= self::FILTER_MASK_OVERDUE; | ||||
if (empty($rec['recurrence']) || $duedate < $today || $start > $weeklimit) { | |||||
if ($duedate <= $today || ($rec['startdate'] && $start <= $today)) | if ($duedate <= $today || ($rec['startdate'] && $start <= $today)) | ||||
$mask |= self::FILTER_MASK_TODAY; | $mask |= self::FILTER_MASK_TODAY; | ||||
if ($duedate <= $tomorrow || ($rec['startdate'] && $start <= $tomorrow)) | if ($duedate <= $tomorrow || ($rec['startdate'] && $start <= $tomorrow)) | ||||
$mask |= self::FILTER_MASK_TOMORROW; | $mask |= self::FILTER_MASK_TOMORROW; | ||||
if (($start > $tomorrow && $start <= $weeklimit) || ($duedate > $tomorrow && $duedate <= $weeklimit)) | if (($start > $tomorrow && $start <= $weeklimit) || ($duedate > $tomorrow && $duedate <= $weeklimit)) | ||||
$mask |= self::FILTER_MASK_WEEK; | $mask |= self::FILTER_MASK_WEEK; | ||||
else if ($start > $weeklimit || ($rec['date'] && $duedate > $weeklimit)) | else if ($start > $weeklimit || $duedate > $weeklimit) | ||||
$mask |= self::FILTER_MASK_LATER; | $mask |= self::FILTER_MASK_LATER; | ||||
} | |||||
else if ($rec['startdate'] || $rec['date']) { | |||||
$date = new DateTime($rec['startdate'] ?: $rec['date'], $this->timezone); | |||||
// set safe recurrence start | |||||
while ($date->format('Y-m-d') >= $today) { | |||||
switch ($rec['recurrence']['FREQ']) { | |||||
case 'DAILY': | |||||
$date = clone $today_date; | |||||
$date->sub(new DateInterval('P1D')); | |||||
break; | |||||
case 'WEEKLY': $date->sub(new DateInterval('P7D')); break; | |||||
case 'MONTHLY': $date->sub(new DateInterval('P1M')); break; | |||||
case 'YEARLY': $date->sub(new DateInterval('P1Y')); break; | |||||
default; break 2; | |||||
} | |||||
} | |||||
$date->_dateonly = true; | |||||
$engine = libcalendaring::get_recurrence(); | |||||
$engine->init($rec['recurrence'], $date); | |||||
// check task occurrences (stop next week) | |||||
// FIXME: is there a faster way of doing this? | |||||
while ($date = $engine->next()) { | |||||
$date = $date->format('Y-m-d'); | |||||
// break iteration asap | |||||
if ($date > $duedate || ($mask & self::FILTER_MASK_LATER)) { | |||||
break; | |||||
} | |||||
if ($date == $today) { | |||||
$mask |= self::FILTER_MASK_TODAY; | |||||
} | |||||
else if ($date == $tomorrow) { | |||||
$mask |= self::FILTER_MASK_TOMORROW; | |||||
} | |||||
else if ($date > $tomorrow && $date <= $weeklimit) { | |||||
$mask |= self::FILTER_MASK_WEEK; | |||||
} | |||||
else if ($date > $weeklimit) { | |||||
$mask |= self::FILTER_MASK_LATER; | |||||
break; | |||||
} | |||||
} | |||||
} | |||||
// add masks for assigned tasks | // add masks for assigned tasks | ||||
if ($this->is_organizer($rec) && !empty($rec['attendees']) && $this->is_attendee($rec) === false) | if ($this->is_organizer($rec) && !empty($rec['attendees']) && $this->is_attendee($rec) === false) | ||||
$mask |= self::FILTER_MASK_ASSIGNED; | $mask |= self::FILTER_MASK_ASSIGNED; | ||||
else if (/*empty($rec['attendees']) ||*/ $this->is_attendee($rec) !== false) | else if (/*empty($rec['attendees']) ||*/ $this->is_attendee($rec) !== false) | ||||
$mask |= self::FILTER_MASK_MYTASKS; | $mask |= self::FILTER_MASK_MYTASKS; | ||||
return $mask; | return $mask; | ||||
▲ Show 20 Lines • Show All 918 Lines • Show Last 20 Lines |