/** * Search for events matching given arguments * * @param array $_filter * @param array $_paging * @return array */ public function searchEvents($filter, $paging) { $controller = Calendar_Controller_Event::getInstance(); $decodedPagination = is_array($paging) ? $paging : Zend_Json::decode($paging); $pagination = new Tinebase_Model_Pagination($decodedPagination); $clientFilter = $filter = $this->_decodeFilter($filter, 'Calendar_Model_EventFilter'); // add fixed calendar on demand $fixedCalendars = Tinebase_Config::getInstance()->getConfigAsArray('fixedCalendars', 'Calendar'); if (is_array($fixedCalendars) && !empty($fixedCalendars)) { $fixed = new Calendar_Model_EventFilter(array(), 'AND'); $fixed->addFilter(new Tinebase_Model_Filter_Text('container_id', 'in', $fixedCalendars)); $periodFilter = $filter->getFilter('period'); if ($periodFilter) { $fixed->addFilter($periodFilter); } $og = new Calendar_Model_EventFilter(array(), 'OR'); $og->addFilterGroup($fixed); $og->addFilterGroup($clientFilter); $filter = new Calendar_Model_EventFilter(array(), 'AND'); $filter->addFilterGroup($og); } $records = $controller->search($filter, $pagination, FALSE); $result = $this->_multipleRecordsToJson($records, $clientFilter, $pagination); return array('results' => $result, 'totalcount' => count($result), 'filter' => $clientFilter->toArray(TRUE)); }
/** * Search for events matching given arguments * * @param array $_filter * @param array $_paging * @return array */ public function searchEvents($filter, $paging) { $controller = Calendar_Controller_Event::getInstance(); $decodedPagination = is_array($paging) ? $paging : Zend_Json::decode($paging); $pagination = new Tinebase_Model_Pagination($decodedPagination); $clientFilter = $filter = $this->_decodeFilter($filter, 'Calendar_Model_EventFilter'); // find out if fixed calendars should be used $fixedCalendars = Calendar_Config::getInstance()->get(Calendar_Config::FIXED_CALENDARS); $useFixedCalendars = is_array($fixedCalendars) && !empty($fixedCalendars); $periodFilter = $filter->getFilter('period'); // add period filter per default to prevent endless search if (!$periodFilter) { $periodFilter = $this->_getDefaultPeriodFilter(); // periodFilter will be added to fixed filter when using fixed calendars if (!$useFixedCalendars) { $filter->addFilter($periodFilter); } } // add fixed calendar on demand if ($useFixedCalendars) { $fixed = new Calendar_Model_EventFilter(array(), 'AND'); $fixed->addFilter(new Tinebase_Model_Filter_Text('container_id', 'in', $fixedCalendars)); $fixed->addFilter($periodFilter); $og = new Calendar_Model_EventFilter(array(), 'OR'); $og->addFilterGroup($fixed); $og->addFilterGroup($clientFilter); $filter = new Calendar_Model_EventFilter(array(), 'AND'); $filter->addFilterGroup($og); } $records = $controller->search($filter, $pagination, FALSE); $result = $this->_multipleRecordsToJson($records, $clientFilter, $pagination); return array('results' => $result, 'totalcount' => count($result), 'filter' => $clientFilter->toArray(TRUE)); }
/** * returns all persistent recur exceptions of recur series * * NOTE: deleted instances are saved in the base events exception property * NOTE: returns all exceptions regardless of current filters and access restrictions * * @param Calendar_Model_Event $_event * @param boolean $_fakeDeletedInstances * @param Calendar_Model_EventFilter $_eventFilter * @return Tinebase_Record_RecordSet of Calendar_Model_Event */ public function getRecurExceptions($_event, $_fakeDeletedInstances = FALSE, $_eventFilter = NULL) { $baseEventId = $_event->base_event_id ?: $_event->id; $exceptionFilter = new Calendar_Model_EventFilter(array(array('field' => 'base_event_id', 'operator' => 'equals', 'value' => $baseEventId), array('field' => 'recurid', 'operator' => 'notnull', 'value' => NULL))); if ($_eventFilter instanceof Calendar_Model_EventFilter) { $exceptionFilter->addFilterGroup($_eventFilter); } $exceptions = $this->_backend->search($exceptionFilter); if ($_fakeDeletedInstances) { $baseEvent = $this->getRecurBaseEvent($_event); $this->fakeDeletedExceptions($baseEvent, $exceptions); } $exceptions->exdate = NULL; $exceptions->rrule = NULL; $exceptions->rrule_until = NULL; return $exceptions; }