本文整理汇总了PHP中Tinebase_Model_Filter_FilterGroup::addFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Model_Filter_FilterGroup::addFilter方法的具体用法?PHP Tinebase_Model_Filter_FilterGroup::addFilter怎么用?PHP Tinebase_Model_Filter_FilterGroup::addFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Model_Filter_FilterGroup
的用法示例。
在下文中一共展示了Tinebase_Model_Filter_FilterGroup::addFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _advancedSearch
/**
* 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);
}
}
示例2: update_0
/**
* 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');
}
示例3: repairDanglingDisplaycontainerEvents
/**
* 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));
}
}
}
示例4: getValidContract
/**
* 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();
}
示例5: _addContainerFilter
/**
* (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));
}
示例6: checkFilterACL
/**
* 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);
}
}
示例7: _addContainerFilter
/**
* 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));
}
示例8: search
/**
* 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);
}
示例9: getTimeaccountsByAcl
/**
* 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;
}
示例10: searchCount
/**
* 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;
}
示例11: _addContainerFilter
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));
}
示例12: checkFilterACL
/**
* 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));
}
}
示例13: _addDefaultFilter
/**
* 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')));
}
}
示例14: checkFilterACL
/**
* 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);
}
}
示例15: getTimeaccountsByAcl
/**
* 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;
}