Пример #1
0
 /**
  * As defined in Sabre_CalDAV_Backend_Abstract
  * 
  * Returns all calendar objects for the given calendar id.
  * We don't return all calendar data here.
  *
  * @param string $calendarId The id of the calendar to retrieve. Corresponds to the id of the user it belongs to.
  *
  * @return array CalendarObject data as specified by SabreDAV.
  */
 public function getCalendarObjects($calendarId)
 {
     $db = Phprojekt::getInstance()->getDb();
     $calendar = new Calendar2_Models_Calendar2();
     $where = $db->quoteInto('u.user_id = ?', $calendarId);
     $join = 'JOIN calendar2_user_relation AS u ON calendar2.id = u.calendar2_id';
     $events = $calendar->fetchAll($where, 'uri', null, null, null, $join);
     if (empty($events)) {
         return array();
     }
     $ret = array();
     $currentUri = $events[0]->uri;
     $group = array(array_shift($events));
     while (!empty($events)) {
         $e = array_shift($events);
         if ($e->uri === $currentUri) {
             $group[] = $e;
         } else {
             $ret[] = $this->getCalendarObjectsGroup($calendarId, $group);
             $currentUri = $e->uri;
             $group = array($e);
         }
     }
     $ret[] = $this->getCalendarObjectsGroup($calendarId, $group);
     return $ret;
 }
Пример #2
0
 private function _regenerateSearch()
 {
     $step = 100;
     $start = 0;
     $max = $this->_db->select()->from('calendar2', 'MAX(id)')->query()->fetchColumn();
     $model = new Calendar2_Models_Calendar2();
     $search = new Phprojekt_Search();
     while ($start <= $max) {
         if ($this->_debug) {
             Phprojekt::getInstance()->getLog()->debug($start . ' - ' . ($start + $step));
         }
         $events = $model->fetchAll("id >= {$start} AND id < " . ($start + $step));
         $start += $step;
         foreach ($events as $e) {
             $search->indexObjectItem($e);
         }
     }
 }