reset() public method

Call this each time before looping through the tasks.
See also: each()
public reset ( )
コード例 #1
0
ファイル: Driver.php プロジェクト: DSNS-LAB/Dmail
 /**
  * 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;
 }
コード例 #2
0
ファイル: List.php プロジェクト: jubinpatel/horde
 /**
  * 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 '';
 }
コード例 #3
0
ファイル: Search.php プロジェクト: horde/horde
 /**
  * Perform the search
  *
  * @param integer $page     The page number
  * @param integer $perpage  The number of results per page.
  *
  * @return Nag_Task
  */
 protected function _search($page, $perpage)
 {
     global $injector, $prefs;
     if (!empty($this->_due)) {
         $parser = Horde_Date_Parser::factory(array('locale' => $GLOBALS['prefs']->getValue('language')));
         $date = $parser->parse($this->_due[1]);
         $date->mday += $this->_due[0];
         $date = $date->timestamp();
     } else {
         $date = false;
     }
     // Get the full, sorted task list.
     $tasks = Nag::listTasks(array('tasklists' => $this->_tasklists, 'completed' => $this->_completed, 'include_history' => false));
     if (!empty($this->_search)) {
         $pattern = '/' . preg_quote($this->_search, '/') . '/i';
     }
     $search_results = new Nag_Task();
     if (!empty($this->_tags)) {
         $tagged_tasks = $injector->getInstance('Nag_Tagger')->search($this->_tags, array('list' => $GLOBALS['display_tasklists']));
     }
     $tasks->reset();
     while ($task = $tasks->each()) {
         // Need to empty the children since they might not be in the results
         $task = clone $task;
         $task->orphan();
         if (!empty($date)) {
             if (empty($task->due) || $task->due > $date) {
                 continue;
             }
         }
         // If we have a search string and it doesn't match name|desc continue
         if (!empty($this->_search) && !($this->_mask & self::MASK_NAME && preg_match($pattern, $task->name)) && !($this->_mask & self::MASK_DESC && preg_match($pattern, $task->desc))) {
             continue;
         }
         // No tags to search? Add it to results. Otherwise, make sure it
         // has the requested tags.
         if (empty($this->_tags) || in_array($task->uid, $tagged_tasks)) {
             $search_results->add($task);
         }
     }
     // Now try to maintain parent/child relationships when they are both
     // in the result set.
     $search_results->reset();
     $search_results_copy = clone $search_results;
     $processed_results = new Nag_Task();
     while ($result = $search_results_copy->each()) {
         if ($result->parent_id && ($parent_task = $search_results->hasTask($result->parent_id))) {
             $parent_task->add($result, true);
             $processed_results->add($parent_task, true);
         } else {
             $result->parent_id = '';
             $processed_results->add($result);
         }
     }
     // Now that we have filtered results, load all tags at once.
     $processed_results->loadTags();
     $processed_results->process();
     return $processed_results;
 }