/**
  * append relation filter
  *
  * @param Tinebase_Model_Filter_FilterGroup $filter
  */
 protected function _advancedSearch(Tinebase_Model_Filter_FilterGroup $filter)
 {
     $relationFilter = $this->_getAdvancedSearchFilter('Crm_Model_Lead', array('Addressbook_Model_Contact', 'Sales_Model_Product', 'Tasks_Model_Task'));
     if ($relationFilter) {
         $filter->addFilter($relationFilter);
     }
 }
 /**
  * update to 8.1
  * - move ack & snooze time from attendee to alarm
  */
 public function update_0()
 {
     // find all events with ack or snooze times set
     $eventIds = $this->_db->query("SELECT DISTINCT " . $this->_db->quoteIdentifier('cal_event_id') . " FROM " . $this->_db->quoteIdentifier(SQL_TABLE_PREFIX . "cal_attendee") . " WHERE " . $this->_db->quoteIdentifier("alarm_ack_time") . " IS NOT NULL OR " . $this->_db->quoteIdentifier("alarm_snooze_time") . " IS NOT NULL")->fetchAll(Zend_Db::FETCH_ASSOC);
     $attendeeBE = new Calendar_Backend_Sql_Attendee();
     $alarmBE = Tinebase_Alarm::getInstance();
     foreach ($eventIds as $eventId) {
         $eventId = $eventId['cal_event_id'];
         $attendeeFilter = new Tinebase_Model_Filter_FilterGroup();
         $attendeeFilter->addFilter(new Tinebase_Model_Filter_Text('cal_event_id', 'equals', $eventId));
         $attendees = $attendeeBE->search($attendeeFilter);
         $alarms = $alarmBE->search(new Tinebase_Model_AlarmFilter(array(array('field' => 'model', 'operator' => 'equals', 'value' => 'Calendar_Model_Event'), array('field' => 'record_id', 'operator' => 'equals', 'value' => $eventId))));
         foreach ($alarms as $alarm) {
             foreach ($attendees as $attendee) {
                 if ($attendee->alarm_ack_time instanceof Tinebase_DateTime) {
                     $alarm->setOption("acknowledged-{$attendee->user_id}", $attendee->alarm_ack_time->format(Tinebase_Record_Abstract::ISO8601LONG));
                 }
                 if ($attendee->alarm_snooze_time instanceof Tinebase_DateTime) {
                     $alarm->setOption("snoozed-{$attendee->user_id}", $attendee->alarm_snooze_time->format(Tinebase_Record_Abstract::ISO8601LONG));
                 }
             }
             $alarmBE->update($alarm);
         }
     }
     // delte ack & snooze from attendee
     $this->_backend->dropCol('cal_attendee', 'alarm_ack_time');
     $this->_backend->dropCol('cal_attendee', 'alarm_snooze_time');
     $this->setTableVersion('cal_attendee', 5);
     $this->setApplicationVersion('Calendar', '8.1');
 }
 /**
  * repair dangling attendee records (no displaycontainer_id)
  *
  * @see https://forge.tine20.org/mantisbt/view.php?id=8172
  */
 public function repairDanglingDisplaycontainerEvents()
 {
     $filter = new Tinebase_Model_Filter_FilterGroup();
     $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'user_type', 'operator' => 'in', 'value' => array(Calendar_Model_Attender::USERTYPE_USER, Calendar_Model_Attender::USERTYPE_GROUPMEMBER, Calendar_Model_Attender::USERTYPE_RESOURCE))));
     $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'displaycontainer_id', 'operator' => 'isnull', 'value' => null)));
     $danglingAttendee = $this->_attendeeBackend->search($filter);
     $danglingContactAttendee = $danglingAttendee->filter('user_type', '/' . Calendar_Model_Attender::USERTYPE_USER . '|' . Calendar_Model_Attender::USERTYPE_GROUPMEMBER . '/', TRUE);
     $danglingContactIds = array_unique($danglingContactAttendee->user_id);
     $danglingContacts = Addressbook_Controller_Contact::getInstance()->getMultiple($danglingContactIds, TRUE);
     $danglingResourceAttendee = $danglingAttendee->filter('user_type', Calendar_Model_Attender::USERTYPE_RESOURCE);
     $danglingResourceIds = array_unique($danglingResourceAttendee->user_id);
     Calendar_Controller_Resource::getInstance()->doContainerACLChecks(false);
     $danglingResources = Calendar_Controller_Resource::getInstance()->getMultiple($danglingResourceIds, TRUE);
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Processing ' . count($danglingContactIds) . ' dangling contact ids...');
     }
     foreach ($danglingContactIds as $danglingContactId) {
         $danglingContact = $danglingContacts->getById($danglingContactId);
         if ($danglingContact && $danglingContact->account_id) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Get default display container for account ' . $danglingContact->account_id);
             }
             if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
                 Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($danglingContact->toArray(), true));
             }
             $displayCalId = Calendar_Controller_Event::getDefaultDisplayContainerId($danglingContact->account_id);
             if ($displayCalId) {
                 // finaly repair attendee records
                 $attendeeRecords = $danglingContactAttendee->filter('user_id', $danglingContactId);
                 $this->_attendeeBackend->updateMultiple($attendeeRecords->getId(), array('displaycontainer_id' => $displayCalId));
                 Tinebase_Core::getLogger()->NOTICE(__METHOD__ . '::' . __LINE__ . " repaired the following contact attendee " . print_r($attendeeRecords->toArray(), TRUE));
             }
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Processing ' . count($danglingResourceIds) . ' dangling resource ids...');
     }
     foreach ($danglingResourceIds as $danglingResourceId) {
         $resource = $danglingResources->getById($danglingResourceId);
         if ($resource && $resource->container_id) {
             $displayCalId = $resource->container_id;
             $attendeeRecords = $danglingResourceAttendee->filter('user_id', $danglingResourceId);
             $this->_attendeeBackend->updateMultiple($attendeeRecords->getId(), array('displaycontainer_id' => $displayCalId));
             Tinebase_Core::getLogger()->NOTICE(__METHOD__ . '::' . __LINE__ . " repaired the following resource attendee " . print_r($attendeeRecords->toArray(), TRUE));
         }
     }
 }
 /**
  * returns the active contract for the given employee and date or now, when no date is given
  * 
  * @param string $_employeeId
  * @param Tinebase_DateTime $_firstDayDate
  * @throws Tinebase_Exception_InvalidArgument
  * @throws HumanResources_Exception_NoCurrentContract
  * @throws Tinebase_Exception_Duplicate
  * @return HumanResources_Model_Contract
  */
 public function getValidContract($_employeeId, $_firstDayDate = NULL)
 {
     if (!$_employeeId) {
         throw new Tinebase_Exception_InvalidArgument('You have to set an account id at least');
     }
     $_firstDayDate = $_firstDayDate ? new Tinebase_DateTime($_firstDayDate) : new Tinebase_DateTime();
     $filter = new HumanResources_Model_ContractFilter(array(), 'AND');
     $filter->addFilter(new Tinebase_Model_Filter_Date(array('field' => 'start_date', 'operator' => 'before', 'value' => $_firstDayDate)));
     $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'employee_id', 'operator' => 'equals', 'value' => $_employeeId)));
     $endDate = new Tinebase_Model_Filter_FilterGroup(array(), 'OR');
     $endDate->addFilter(new Tinebase_Model_Filter_Date(array('field' => 'end_date', 'operator' => 'after', 'value' => $_firstDayDate)));
     $filter->addFilterGroup($endDate);
     $contracts = $this->search($filter);
     if ($contracts->count() < 1) {
         $filter = new HumanResources_Model_ContractFilter(array(), 'AND');
         $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'employee_id', 'operator' => 'equals', 'value' => $_employeeId)));
         $contracts = $this->search($filter);
         if ($contracts->count() > 0) {
             $e = new HumanResources_Exception_NoCurrentContract();
             $e->addRecord($contracts->getFirstRecord());
             throw $e;
         } else {
             throw new HumanResources_Exception_NoContract();
         }
     } else {
         if ($contracts->count() > 1) {
             throw new Tinebase_Exception_Duplicate('There are more than one valid contracts for this employee!');
         }
     }
     return $contracts->getFirstRecord();
 }
 /**
  * (non-PHPdoc)
  * @see ActiveSync_Frontend_Abstract::_addContainerFilter()
  */
 protected function _addContainerFilter(Tinebase_Model_Filter_FilterGroup $_filter, $_containerId)
 {
     // custom filter gets added when created
     $_filter->createFilter('account_id', 'equals', Tinebase_Core::getPreference('Expressomail')->{Expressomail_Preference::DEFAULTACCOUNT});
     $_filter->addFilter($_filter->createFilter('folder_id', 'equals', $_containerId));
 }
Example #6
0
 /**
  * Removes accounts where current user has no access to
  * 
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param string $_action get|update
  */
 public function checkFilterACL(Tinebase_Model_Filter_FilterGroup $_filter, $_action = 'get')
 {
     $userFilter = $_filter->getFilter('user_id');
     // force a $userFilter filter (ACL)
     if ($userFilter === NULL || $userFilter->getOperator() !== 'equals' || $userFilter->getValue() !== $this->_currentAccount->getId()) {
         $userFilter = $_filter->createFilter('user_id', 'equals', $this->_currentAccount->getId());
         $_filter->addFilter($userFilter);
     }
 }
 /**
  * add container acl filter to filter group
  * 
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param string                            $_containerId
  */
 protected function _addContainerFilter(Tinebase_Model_Filter_FilterGroup $_filter, $_containerId)
 {
     $syncableContainers = $this->_getSyncableFolders();
     $containerIds = array();
     if ($_containerId == $this->_specialFolderName) {
         $containerIds = $syncableContainers->getArrayOfIds();
     } elseif (in_array($_containerId, $syncableContainers->id)) {
         $containerIds = array($_containerId);
     }
     $_filter->addFilter($_filter->createFilter('container_id', 'in', $containerIds));
 }
 /**
  * Search for records matching given filter
  *
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param Tinebase_Model_Pagination $_pagination
  * @param boolean $_onlyIds
  * @return Tinebase_Record_RecordSet|array
  */
 public function search(Tinebase_Model_Filter_FilterGroup $_filter = NULL, Tinebase_Model_Pagination $_pagination = NULL, $_onlyIds = FALSE)
 {
     $backend = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Relation', 'tableName' => 'relations'));
     $_filter->addFilter(new Tinebase_Model_Filter_Bool('is_deleted', 'equals', (int) FALSE));
     return $backend->search($_filter, $_pagination, $_onlyIds);
 }
 /**
  * get timeaccounts by grant
  * - this function caches its result (with cache tag 'container')
  *
  * @param integer $_grant
  * @param boolean $_onlyIds
  * @return Tinebase_Record_RecordSet|array
  */
 public static function getTimeaccountsByAcl($_grant, $_onlyIds = FALSE)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' get grant: ' . print_r($_grant, true));
     }
     $cache = Tinebase_Core::getCache();
     $cacheId = convertCacheId('getTimeaccountsByAcl' . Tinebase_Core::getUser()->getId() . $_grant . $_onlyIds);
     $result = $cache->load($cacheId);
     if ($result === FALSE) {
         $containerIds = Tinebase_Container::getInstance()->getContainerByACL(Tinebase_Core::getUser()->getId(), 'Timetracker', $_grant, TRUE);
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' got containers: ' . print_r($containerIds, true));
         }
         $filter = new Tinebase_Model_Filter_FilterGroup(array());
         $filter->addFilter(new Tinebase_Model_Filter_Container('container_id', 'in', $containerIds, array('applicationName' => 'Timetracker', 'ignoreAcl' => true)));
         $backend = new Timetracker_Backend_Timeaccount();
         $result = $backend->search($filter);
         if ($_onlyIds) {
             $result = $result->getArrayOfIds();
         }
         $cache->save($result, $cacheId, array('container'));
     }
     return $result;
 }
Example #10
0
 /**
  * Gets total count of search with $_filter
  * 
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @return int
  */
 public function searchCount(Tinebase_Model_Filter_FilterGroup $_filter)
 {
     $_filter->addFilter(new Billing_Model_ASInvoiceCreditFilter('combi_type', 'in', array('INVOICE', 'CREDIT')));
     if ($this->_useSubselectForCount) {
         // use normal search query as subselect to get count -> select count(*) from (select [...]) as count
         $select = $this->_getSelect('*', $_getDeleted);
         $this->_addFilter($select, $_filter);
         $countSelect = $this->_db->select()->from($select, array('count' => 'COUNT(*)', '*' => '*'));
         //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $countSelect->__toString());
         $result = $this->_db->fetchOne($countSelect);
     } else {
         $select = $this->_getSelect(array('count' => 'COUNT(*)', '*' => '*'));
         $this->_addFilter($select, $_filter);
         //if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $select->__toString());
         $result = $this->_db->fetchOne($select);
     }
     return $result;
 }
Example #11
0
 protected function _addContainerFilter(Tinebase_Model_Filter_FilterGroup $_filter, $_containerId)
 {
     // custom filter gets added when created
     $_filter->createFilter('account_id', 'equals', Tinebase_Core::getPreference('Felamimail')->{Felamimail_Preference::DEFAULTACCOUNT});
     $_filter->addFilter($_filter->createFilter('folder_id', 'equals', $_containerId));
     #if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " filter " . print_r($_filter->toArray(), true));
 }
 /**
  * redefine required grants for get actions
  * 
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param string $_action get|update
  */
 public function checkFilterACL(Tinebase_Model_Filter_FilterGroup $_filter, $_action = 'get')
 {
     $hasGrantsFilter = FALSE;
     foreach ($_filter->getAclFilters() as $aclFilter) {
         if ($aclFilter instanceof Calendar_Model_GrantFilter) {
             $hasGrantsFilter = TRUE;
             break;
         }
     }
     if (!$hasGrantsFilter) {
         // force a grant filter
         // NOTE: actual grants are set via setRequiredGrants later
         $grantsFilter = $_filter->createFilter('grants', 'in', '@setRequiredGrants');
         $_filter->addFilter($grantsFilter);
     }
     parent::checkFilterACL($_filter, $_action);
     if ($_action == 'get') {
         $_filter->setRequiredGrants(array(Tinebase_Model_Grants::GRANT_FREEBUSY, Tinebase_Model_Grants::GRANT_READ, Tinebase_Model_Grants::GRANT_ADMIN));
     }
 }
 /**
  * you can define default filters here
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  */
 protected function _addDefaultFilter(Tinebase_Model_Filter_FilterGroup $_filter = NULL)
 {
     $lines = Sipgate_Controller_Line::getInstance()->search(new Sipgate_Model_LineFilter());
     if ($lines->count()) {
         $aclFilter = new Tinebase_Model_Filter_Text(array('field' => 'line_id', 'operator' => 'in', 'value' => $lines->id));
         $aclFilter->setIsImplicit(true);
         $_filter->addFilter($aclFilter);
     } else {
         $_filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'entry_id', 'operator' => 'equals', 'value' => 'impossible')));
     }
 }
 /**
  * Removes containers where current user has no access to
  * -> remove timetracker containers, too (those are managed within the timetracker)
  * 
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param string $_action get|update
  */
 public function checkFilterACL(Tinebase_Model_Filter_FilterGroup $_filter, $_action = 'get')
 {
     if ($_action == 'get') {
         $userApps = Tinebase_Core::getUser()->getApplications(TRUE);
         $filterAppIds = array();
         foreach ($userApps as $app) {
             if ($app->name !== 'Timetracker') {
                 $filterAppIds[] = $app->getId();
             }
         }
         $appFilter = $_filter->createFilter('application_id', 'in', $filterAppIds);
         $_filter->addFilter($appFilter);
     }
 }
 /**
  * get timeaccounts by grant
  *
  * @param array|string $_grant
  * @param boolean $_onlyIds
  * @return Tinebase_Record_RecordSet|array
  */
 public static function getTimeaccountsByAcl($_grant, $_onlyIds = FALSE)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' get grant: ' . print_r($_grant, true));
     }
     $containerIds = Tinebase_Container::getInstance()->getContainerByACL(Tinebase_Core::getUser()->getId(), 'Timetracker', $_grant, TRUE);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' got containers: ' . print_r($containerIds, true));
     }
     $filter = new Tinebase_Model_Filter_FilterGroup(array());
     // NOTE: use id filter instead of container filter because of poor performance of container filter (setValue)
     $filter->addFilter(new Tinebase_Model_Filter_Id('container_id', 'in', $containerIds));
     $backend = new Timetracker_Backend_Timeaccount();
     $result = $backend->search($filter);
     if ($_onlyIds) {
         $result = $result->getArrayOfIds();
     }
     return $result;
 }
Example #16
0
 public function printReceiptsByFilter($preview = false, $outputType, $filters, $userOptions, $types, $sort, $additionalOptions)
 {
     $additionalOptions = Zend_Json::decode($additionalOptions);
     if ($additionalOptions['addressLabels'] == true) {
         $this->printAddressLabelsByFilter($outputType, $filters, $userOptions, $types, $sort);
         return;
     }
     $sortField = 'creation_time';
     $sortDir = 'ASC';
     $sort = Zend_Json::decode($sort);
     $this->setUseSorting(true);
     if (is_array($sort) && array_key_exists('field', $sort) && array_key_exists('order', $sort)) {
         if (in_array($sort['field'], array('creation_time', 'order_nr'))) {
             $sortField = $sort['field'];
         }
         if (in_array($sort['order'], array('ASC', 'DESC'))) {
             $sortDir = $sort['order'];
         }
     }
     $this->setTypes(Zend_Json::decode($types));
     $this->setOutputType($outputType);
     $this->setPreview($preview);
     $this->setFilters($filters);
     $this->setUserOptions($userOptions);
     if ($additionalOptions['preview'] == true) {
         $this->setPreview(true);
     }
     if ($additionalOptions['copy'] == true) {
         $this->setCopy(true);
     }
     $filters = $this->createFilters();
     $firstGroup = new Tinebase_Model_Filter_FilterGroup(array(), 'AND');
     $firstGroup->addFilterGroup($filters);
     if (!$this->preview && !$this->copy) {
         // only print receipts with empty print date!
         $firstGroup->addFilter(new Tinebase_Model_Filter_Date('print_date', 'isnull'));
     }
     $typesGroup = new Tinebase_Model_Filter_FilterGroup(array(), 'OR');
     $inoviceFilter = null;
     $shippingFilter = null;
     if ($this->types['invoice'] == true) {
         $invoiceFilter = new Tinebase_Model_Filter_Text('type', 'equals', Billing_Model_Receipt::TYPE_INVOICE);
     }
     if ($this->types['credit'] == true) {
         $invoiceFilter = new Tinebase_Model_Filter_Text('type', 'equals', Billing_Model_Receipt::TYPE_CREDIT);
     }
     if ($this->types['shipping'] == true) {
         $shippingFilter = new Tinebase_Model_Filter_Text('type', 'equals', Billing_Model_Receipt::TYPE_SHIPPING);
     }
     if (!$invoiceFilter && !$shippingFilter) {
         $invoiceFilter = new Tinebase_Model_Filter_Text('type', 'equals', Billing_Model_Receipt::TYPE_INVOICE);
     }
     if ($invoiceFilter) {
         $typesGroup->addFilter($invoiceFilter);
     }
     if ($shippingFilter) {
         $typesGroup->addFilter($shippingFilter);
     }
     $firstGroup->addFilterGroup($typesGroup);
     $paging = new Tinebase_Model_Pagination(array('sort' => $sortField, 'dir' => $sortDir));
     // -> get ids only
     $this->receiptIds = $this->_receiptController->search($firstGroup, $paging, false, TRUE);
     $this->runTransaction(self::PROCESS_RECEIPTS);
 }
Example #17
0
 /**
  * search for preferences
  * 
  * @param  Tinebase_Model_Filter_FilterGroup    $_filter
  * @param  Tinebase_Model_Pagination            $_pagination
  * @param  boolean                              $_onlyIds
  * @return Tinebase_Record_RecordSet|array of preferences / pref ids
  */
 public function search(Tinebase_Model_Filter_FilterGroup $_filter = NULL, Tinebase_Model_Pagination $_pagination = NULL, $_onlyIds = FALSE)
 {
     // make sure account is set in filter
     $userId = Tinebase_Core::getUser()->getId();
     if (!$_filter->isFilterSet('account')) {
         $accountFilter = $_filter->createFilter('account', 'equals', array('accountId' => $userId, 'accountType' => Tinebase_Acl_Rights::ACCOUNT_TYPE_USER));
         $_filter->addFilter($accountFilter);
     } else {
         // only admins can search for other users prefs
         $accountFilter = $_filter->getAccountFilter();
         $accountFilterValue = $accountFilter->getValue();
         if ($accountFilterValue['accountId'] != $userId && $accountFilterValue['accountType'] == Tinebase_Acl_Rights::ACCOUNT_TYPE_USER) {
             if (!Tinebase_Acl_Roles::getInstance()->hasRight($this->_application, Tinebase_Core::getUser()->getId(), Tinebase_Acl_Rights_Abstract::ADMIN)) {
                 return new Tinebase_Record_RecordSet('Tinebase_Model_Preference');
             }
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_filter->toArray(), TRUE));
     }
     $paging = new Tinebase_Model_Pagination(array('dir' => 'ASC', 'sort' => array('name')));
     $allPrefs = parent::search($_filter, $_pagination, $_onlyIds);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r(is_array($allPrefs) ? $allPrefs : $allPrefs->toArray(), TRUE));
     }
     if (!$_onlyIds) {
         $this->_addDefaultAndRemoveUndefinedPrefs($allPrefs, $_filter);
         // get single matching preferences for each different pref
         $result = $this->getMatchingPreferences($allPrefs);
     } else {
         $result = $allPrefs;
     }
     return $result;
 }
 /**
  * Removes containers where current user has no access to
  *
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param string $_action get|update
  */
 public function checkFilterACL(Tinebase_Model_Filter_FilterGroup $_filter, $_action = 'get')
 {
     if (!$this->_doContainerACLChecks) {
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Container ACL disabled for ' . $_filter->getModelName() . '.');
         }
         return TRUE;
     }
     $aclFilters = $_filter->getAclFilters();
     if (!$aclFilters) {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Force a standard containerFilter (specialNode = all) as ACL filter.');
         }
         $containerFilter = $_filter->createFilter('container_id', 'specialNode', 'all', array('applicationName' => $_filter->getApplicationName()));
         $_filter->addFilter($containerFilter);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Setting filter grants for action ' . $_action);
     }
     switch ($_action) {
         case 'get':
             $_filter->setRequiredGrants(array(Tinebase_Model_Grants::GRANT_READ, Tinebase_Model_Grants::GRANT_ADMIN));
             break;
         case 'update':
             $_filter->setRequiredGrants(array(Tinebase_Model_Grants::GRANT_EDIT, Tinebase_Model_Grants::GRANT_ADMIN));
             break;
         case 'export':
             $_filter->setRequiredGrants(array(Tinebase_Model_Grants::GRANT_EXPORT, Tinebase_Model_Grants::GRANT_ADMIN));
             break;
         case 'sync':
             $_filter->setRequiredGrants(array(Tinebase_Model_Grants::GRANT_SYNC, Tinebase_Model_Grants::GRANT_ADMIN));
             break;
         default:
             throw new Tinebase_Exception_UnexpectedValue('Unknown action: ' . $_action);
     }
 }
 /**
  * you can define default filters here
  *
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  */
 protected function _addDefaultFilter(Tinebase_Model_Filter_FilterGroup $_filter = NULL)
 {
     if (!$_filter->isFilterSet('showHidden')) {
         $hiddenFilter = $_filter->createFilter('showHidden', 'equals', FALSE);
         $hiddenFilter->setIsImplicit(TRUE);
         $_filter->addFilter($hiddenFilter);
     }
 }
Example #20
0
 public function getReceiptsByOrderId($orderId, $type = null, $sortInfo = null)
 {
     $rController = Billing_Controller_Receipt::getInstance();
     $filterGroup = new Tinebase_Model_Filter_FilterGroup(array(), 'AND');
     $filter = new Tinebase_Model_Filter_Id('order_id', 'equals', $orderId);
     $filterGroup->addFilter($filter);
     if ($type) {
         $filter = new Tinebase_Model_Filter_Text('type', 'equals', $type);
         $filterGroup->addFilter($filter);
     }
     return $rController->search($filterGroup);
 }