each() public method

Call reset() each time before looping through the tasks: $tasks->reset(); while ($task = $tasks->each() { ... }
See also: reset()
public each ( )
Ejemplo n.º 1
0
 /**
  * List all alarms near $date.
  *
  * @param integer $date  The unix epoch time to check for alarms.
  *
  * @return array  An array of tasks that have alarms that match.
  */
 public function listAlarms($date)
 {
     if (!$this->tasks->count()) {
         $result = $this->retrieve(0);
     }
     $alarms = array();
     $this->tasks->reset();
     while ($task = $this->tasks->each()) {
         if ($task->alarm && ($due = $task->getNextDue()) && $due->timestamp() - $task->alarm * 60 <= $date) {
             $alarms[$task_id] = $task;
         }
     }
     return $alarms;
 }
Ejemplo n.º 2
0
 /**
  * Get HTML to display the related tags links.
  *
  * @return string
  */
 protected function _getRelatedTags()
 {
     $this->_tasks->reset();
     $ids = array();
     while ($t = $this->_tasks->each()) {
         $ids[] = $t->uid;
     }
     $rtags = $this->_browser->getRelatedTags($ids);
     if (count($rtags)) {
         $html = '<div class="nag-tags-related">' . Horde::img('tags.png') . ' <ul class="horde-tags">';
         foreach ($rtags as $id => $taginfo) {
             $html .= '<li>' . $this->_linkAddTag($taginfo['tag_name'])->link() . htmlspecialchars($taginfo['tag_name']) . '</a></li>';
         }
         return $html . '</ul></div>';
     }
     return '';
 }