Nag_Task::recurs PHP Method

recurs() public method

Returns whether this task is a recurring task.
public recurs ( ) : boolean
return boolean True if this is a recurring task.
    public function recurs()
    {
        return isset($this->recurrence) && !$this->recurrence->hasRecurType(Horde_Date_Recurrence::RECUR_NONE);
    }

Usage Example

Beispiel #1
0
 /**
  * Retrieves tasks from the Kolab server.
  *
  * @param integer $completed  Which tasks to retrieve (1 = all tasks,
  *                            0 = incomplete tasks, 2 = complete tasks).
  */
 public function retrieve($completed = Nag::VIEW_ALL)
 {
     $dict = array();
     $this->tasks = new Nag_Task();
     $task_list = $this->_getData()->getObjects();
     if (empty($task_list)) {
         return;
     }
     foreach ($task_list as $task) {
         $tid = Horde_Url::uriB64Encode($task['uid']);
         $nag_task = $this->_buildTask($task);
         $nag_task['tasklist_id'] = $this->_tasklist;
         $t = new Nag_Task($this, $nag_task);
         $complete = $t->completed;
         if (empty($t->start)) {
             $start = null;
         } else {
             $start = $t->start;
         }
         switch ($completed) {
             case Nag::VIEW_INCOMPLETE:
                 if ($complete) {
                     continue;
                 }
                 if ($start && $t->recurs() && ($completions = $t->recurrence->getCompletions())) {
                     sort($completions);
                     list($year, $month, $mday) = sscanf(end($completions), '%04d%02d%02d');
                     $lastCompletion = new Horde_Date($year, $month, $mday);
                     $recurrence = clone $t->recurrence;
                     $recurrence->start = new Horde_Date($start);
                     $start = $recurrence->nextRecurrence($lastCompletion)->timestamp();
                     if ($start > $_SERVER['REQUEST_TIME']) {
                         continue;
                     }
                 }
                 break;
             case Nag::VIEW_COMPLETE:
                 if (!$complete) {
                     continue;
                 }
                 break;
             case Nag::VIEW_FUTURE:
                 if ($complete || $start == 0) {
                     continue;
                 }
                 if ($start && $t->recurs() && ($completions = $t->recurrence->getCompletions())) {
                     sort($completions);
                     list($year, $month, $mday) = sscanf(end($completions), '%04d%02d%02d');
                     $lastCompletion = new Horde_Date($year, $month, $mday);
                     $recurrence = clone $t->recurrence;
                     $recurrence->start = new Horde_Date($start);
                     $start = $recurrence->nextRecurrence($lastCompletion)->timestamp();
                     if ($start < $_SERVER['REQUEST_TIME']) {
                         continue;
                     }
                 }
                 break;
             case Nag::VIEW_FUTURE_INCOMPLETE:
                 if ($complete) {
                     continue;
                 }
                 break;
         }
         if (empty($t->parent_id)) {
             $this->tasks->add($t);
         } else {
             $dict[$tid] = $t;
         }
     }
     /* Build a tree from the subtasks. */
     foreach (array_keys($dict) as $key) {
         $task = $this->tasks->get($dict[$key]->parent_id);
         if ($task) {
             $task->add($dict[$key]);
         } elseif (isset($dict[$dict[$key]->parent_id])) {
             $dict[$dict[$key]->parent_id]->add($dict[$key]);
         } else {
             $this->tasks->add($dict[$key]);
         }
     }
 }
All Usage Examples Of Nag_Task::recurs