当前位置: 首页>>代码示例>>PHP>>正文


PHP Tinebase_Backend_Sql_Abstract::traitGroup方法代码示例

本文整理汇总了PHP中Tinebase_Backend_Sql_Abstract::traitGroup方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Backend_Sql_Abstract::traitGroup方法的具体用法?PHP Tinebase_Backend_Sql_Abstract::traitGroup怎么用?PHP Tinebase_Backend_Sql_Abstract::traitGroup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Tinebase_Backend_Sql_Abstract的用法示例。


在下文中一共展示了Tinebase_Backend_Sql_Abstract::traitGroup方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: appendFilterSql

 /**
  * appends sql to given select statement
  *
  * @param Zend_Db_Select                $_select
  * @param Tinebase_Backend_Sql_Abstract $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $db = $_backend->getAdapter();
     // prepare value
     $value = $this->_value ? 1 : 0;
     if ($value) {
         // nothing to do -> show all contacts!
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Query all account contacts.');
         }
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Only query visible and enabled account contacts.');
         }
         if (Tinebase_Core::getUser() instanceof Tinebase_Model_FullUser) {
             $where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . '(' . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ' OR ' . $db->quoteInto($db->quoteIdentifier('accounts.id') . ' = ?', Tinebase_Core::getUser()->getId()) . ')' . ")";
         } else {
             $where = '/* is no user */ ' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'true', 'false') . ' OR /* is user */ (' . Tinebase_Backend_Sql_Command::getIfIsNull($db, $db->quoteIdentifier('accounts.id'), 'false', 'true') . ' AND ' . $db->quoteInto($db->quoteIdentifier('accounts.status') . ' = ?', 'enabled') . " AND " . $db->quoteInto($db->quoteIdentifier('accounts.visibility') . ' = ?', 'displayed') . ")";
         }
         $_select->where($where);
         $select = $_select instanceof Zend_Db_Select ? $_select : $_select->getSelect();
         $select = Tinebase_Backend_Sql_Abstract::traitGroup($db, $_backend->getTablePrefix(), $select);
         $_select instanceof Zend_Db_Select ? $_select = $select : $_select->setSelect($select);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contacts query ' . $_select->assemble());
         }
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:34,代码来源:ContactDisabledFilter.php

示例2: getGrantsForRecords

 /**
  * get grants for records
  * 
  * @param Tinebase_Record_RecordSet $records
  */
 public function getGrantsForRecords(Tinebase_Record_RecordSet $records)
 {
     $recordIds = $records->getArrayOfIds();
     if (empty($recordIds)) {
         return;
     }
     $select = $this->_getAclSelectByRecordIds($recordIds)->group(array('record_id', 'account_type', 'account_id'));
     Tinebase_Backend_Sql_Abstract::traitGroup($select);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . $select);
     }
     $stmt = $this->_db->query($select);
     $grantsData = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' grantsData: ' . print_r($grantsData, true));
     }
     foreach ($grantsData as $grantData) {
         $givenGrants = explode(',', $grantData['account_grants']);
         foreach ($givenGrants as $grant) {
             $grantData[$grant] = TRUE;
         }
         $recordGrant = new $this->_modelName($grantData, true);
         unset($recordGrant->account_grant);
         $record = $records->getById($recordGrant->record_id);
         if (!$record->grants instanceof Tinebase_Record_RecordSet) {
             $record->grants = new Tinebase_Record_RecordSet($this->_modelName);
         }
         $record->grants->addRecord($recordGrant);
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Records with grants: ' . print_r($records->toArray(), true));
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:38,代码来源:Grants.php

示例3: getByUserId

 /**
  * fetch one contact of a user identified by his user_id
  *
  * @param   int $_userId
  * @return  Addressbook_Model_Contact 
  * @throws  Addressbook_Exception_NotFound if contact not found
  */
 public function getByUserId($_userId)
 {
     $select = $this->_getSelect()->where($this->_db->quoteIdentifier('accounts.id') . ' = ?', $_userId)->limit(1);
     Tinebase_Backend_Sql_Abstract::traitGroup($select);
     $stmt = $this->_db->query($select);
     $queryResult = $stmt->fetch();
     $stmt->closeCursor();
     if (!$queryResult) {
         throw new Addressbook_Exception_NotFound('Contact with user id ' . $_userId . ' not found.');
     }
     $contact = $this->_rawDataToRecord($queryResult);
     return $contact;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:20,代码来源:Sql.php

示例4: _updateForeignKeys

 /**
  * update foreign key values
  * 
  * @param string $_mode create|update
  * @param Tinebase_Record_Interface $_record
  */
 protected function _updateForeignKeys($_mode, Tinebase_Record_Interface $_record)
 {
     if (!empty($this->_foreignTables)) {
         foreach ($this->_foreignTables as $modelName => $join) {
             if (!(isset($join['field']) || array_key_exists('field', $join))) {
                 continue;
             }
             $idsToAdd = array();
             $idsToRemove = array();
             if (!empty($_record->{$modelName})) {
                 $idsToAdd = Tinebase_Record_RecordSet::getIdsFromMixed($_record->{$modelName});
             }
             $transactionId = Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
             if ($_mode == 'update') {
                 $select = $this->_db->select();
                 $select->from(array($join['table'] => $this->_tablePrefix . $join['table']), array($join['field']))->where($this->_db->quoteIdentifier($join['table'] . '.' . $join['joinOn']) . ' = ?', $_record->getId());
                 Tinebase_Backend_Sql_Abstract::traitGroup($select);
                 $stmt = $this->_db->query($select);
                 $currentIds = $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
                 $stmt->closeCursor();
                 $idsToRemove = array_diff($currentIds, $idsToAdd);
                 $idsToAdd = array_diff($idsToAdd, $currentIds);
             }
             if (!empty($idsToRemove)) {
                 $where = '(' . $this->_db->quoteInto($this->_db->quoteIdentifier($this->_tablePrefix . $join['table'] . '.' . $join['joinOn']) . ' = ?', $_record->getId()) . ' AND ' . $this->_db->quoteInto($this->_db->quoteIdentifier($this->_tablePrefix . $join['table'] . '.' . $join['field']) . ' IN (?)', $idsToRemove) . ')';
                 $this->_db->delete($this->_tablePrefix . $join['table'], $where);
             }
             foreach ($idsToAdd as $id) {
                 $recordArray = array($join['joinOn'] => $_record->getId(), $join['field'] => $id);
                 $this->_db->insert($this->_tablePrefix . $join['table'], $recordArray);
             }
             Tinebase_TransactionManager::getInstance()->commitTransaction($transactionId);
         }
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:41,代码来源:Abstract.php

示例5: search

 /**
  * Calendar optimized search function
  * 
  * 1. get all events neglecting grants filter
  * 2. get all related container grants (via resolving)
  * 3. compute effective grants in PHP and only keep events 
  *    user has required grant for
  * 
  * @TODO rethink if an outer container filter could help
  *
  * @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)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Searching events ...');
     }
     if ($_pagination === NULL) {
         $_pagination = new Tinebase_Model_Pagination();
     }
     $getDeleted = is_object($_filter) && $_filter->getFilter('is_deleted');
     $select = parent::_getSelect('*', $getDeleted);
     $select->joinLeft(array('exdate' => $this->_tablePrefix . 'cal_exdate'), $this->_db->quoteIdentifier('exdate.cal_event_id') . ' = ' . $this->_db->quoteIdentifier($this->_tableName . '.id'), array('exdate' => $this->_dbCommand->getAggregate('exdate.exdate')));
     // NOTE: we join here as attendee and role filters need it
     $select->joinLeft(array('attendee' => $this->_tablePrefix . 'cal_attendee'), $this->_db->quoteIdentifier('attendee.cal_event_id') . ' = ' . $this->_db->quoteIdentifier('cal_events.id'), array());
     if (!$getDeleted) {
         $select->joinLeft(array('dispcontainer' => $this->_tablePrefix . 'container'), $this->_db->quoteIdentifier('dispcontainer.id') . ' = ' . $this->_db->quoteIdentifier('attendee.displaycontainer_id'), array());
         $select->where($this->_db->quoteIdentifier('dispcontainer.is_deleted') . ' = 0 OR ' . $this->_db->quoteIdentifier('dispcontainer.is_deleted') . 'IS NULL');
     }
     // remove grantsfilter here as we do grants computation in PHP
     $grantsFilter = $_filter->getFilter('grants');
     if ($grantsFilter) {
         $_filter->removeFilter('grants');
     }
     // clone the filter, as the filter is also used in the json frontend
     // and the calendar filter is used in the UI to
     $clonedFilters = clone $_filter;
     $calendarFilter = null;
     foreach ($clonedFilters as $filter) {
         if ($filter instanceof Calendar_Model_CalendarFilter) {
             $calendarFilter = $filter;
             $clonedFilters->removeFilter($filter);
             break;
         }
     }
     $this->_addFilter($select, $clonedFilters);
     $select->group($this->_tableName . '.' . 'id');
     Tinebase_Backend_Sql_Abstract::traitGroup($select);
     if ($calendarFilter) {
         $select1 = clone $select;
         $select2 = clone $select;
         $calendarFilter->appendFilterSql1($select1, $this);
         $calendarFilter->appendFilterSql2($select2, $this);
         $select = $this->getAdapter()->select()->union(array($select1, $select2));
     }
     $_pagination->appendPaginationSql($select);
     $stmt = $this->_db->query($select);
     $rows = (array) $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Event base rows fetched: ' . count($rows) . ' select: ' . $select);
     }
     $result = $this->_rawDataToRecordSet($rows);
     $this->_checkGrants($result, $grantsFilter);
     return $_onlyIds ? $result->{is_bool($_onlyIds) ? $this->_getRecordIdentifier() : $_onlyIds} : $result;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:68,代码来源:Sql.php

示例6: getContainerGrantsOfRecords

 /**
  * get grants for containers assigned to given account of multiple records
  *
  * @param   Tinebase_Record_RecordSet   $_records records to get the grants for
  * @param   string|Tinebase_Model_User  $_accountId the account to get the grants for
  * @param   string                      $_containerProperty container property
  * @param   string                      $_grantModel
  * @throws  Tinebase_Exception_NotFound
  * @return  array of containers|void
  */
 public function getContainerGrantsOfRecords(Tinebase_Record_RecordSet $_records, $_accountId, $_containerProperty = 'container_id', $_grantModel = 'Tinebase_Model_Grants')
 {
     $containerIds = array();
     foreach ($_records as $record) {
         if (isset($record[$_containerProperty]) && !isset($containerIds[Tinebase_Model_Container::convertContainerIdToInt($record[$_containerProperty])])) {
             $containerIds[Tinebase_Model_Container::convertContainerIdToInt($record[$_containerProperty])] = null;
         }
     }
     if (empty($containerIds)) {
         return array();
     }
     $accountId = $_accountId instanceof Tinebase_Record_Abstract ? $_accountId->getId() : $_accountId;
     $select = $this->_getSelect('*', TRUE)->where("{$this->_db->quoteIdentifier('container.id')} IN (?)", array_keys($containerIds))->join(array('container_acl' => SQL_TABLE_PREFIX . 'container_acl'), "{$this->_db->quoteIdentifier('container_acl.container_id')} = {$this->_db->quoteIdentifier('container.id')}", array('*', 'account_grants' => $this->_dbCommand->getAggregate('container_acl.account_grant')))->group('container.id', 'container_acl.account_type', 'container_acl.account_id');
     $this->addGrantsSql($select, $accountId, '*');
     Tinebase_Backend_Sql_Abstract::traitGroup($select);
     $stmt = $this->_db->query('/*' . __FUNCTION__ . '*/' . $select);
     $rows = $stmt->fetchAll(Zend_Db::FETCH_ASSOC);
     $containers = array();
     // add results to container ids and get grants array
     foreach ($rows as $row) {
         // NOTE id is non-ambiguous
         $row['id'] = $row['container_id'];
         $grantsArray = array_unique(explode(',', $row['account_grants']));
         $row['account_grants'] = $this->_getGrantsFromArray($grantsArray, $accountId, $_grantModel)->toArray();
         $containers[$row['id']] = new Tinebase_Model_Container($row, TRUE);
         try {
             $containers[$row['id']]->path = $containers[$row['id']]->getPath();
         } catch (Exception $e) {
             // @todo is it correct to catch all exceptions here?
             Tinebase_Exception::log($e);
         }
     }
     return $containers;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:44,代码来源:Container.php

示例7: getContexts

 /**
  * returns all contexts of a given tag
  *
  * @param  string $_tagId
  * @return array  array of application ids
  */
 public function getContexts($_tagId)
 {
     $select = $this->_db->select()->from(array('tags_context' => SQL_TABLE_PREFIX . 'tags_context'), array('application_id' => $this->_dbCommand->getAggregate('application_id')))->where($this->_db->quoteInto($this->_db->quoteIdentifier('tag_id') . ' = ?', $_tagId))->group('tag_id');
     Tinebase_Backend_Sql_Abstract::traitGroup($select);
     $apps = $this->_db->fetchOne($select);
     if ($apps === '0') {
         $apps = 'any';
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
         Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' got tag contexts: ' . $apps);
     }
     return explode(',', $apps);
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:19,代码来源:Tags.php


注:本文中的Tinebase_Backend_Sql_Abstract::traitGroup方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。