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


PHP Tinebase_Record_RecordSet::getIndexById方法代码示例

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


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

示例1: resolveContainerAndAddPath

 /**
  * resolve node container and path
  * 
  * (1) add path to records 
  * (2) replace name with container record, if node name is a container id 
  *     / path is toplevel (shared/personal with useraccount
  * (3) add account grants of acl container to node
  * 
  * @param Tinebase_Record_RecordSet|Tinebase_Model_Tree_Node $_records
  * @param Tinebase_Model_Tree_Node_Path $_path
  * @param Tinebase_Model_Container $_container
  */
 public function resolveContainerAndAddPath($_records, Tinebase_Model_Tree_Node_Path $_path, Tinebase_Model_Container $_container = NULL)
 {
     $records = $_records instanceof Tinebase_Model_Tree_Node ? new Tinebase_Record_RecordSet('Tinebase_Model_Tree_Node', array($_records)) : $_records;
     if (!$_path->container) {
         // fetch top level container nodes
         if ($_container === NULL) {
             $containerIds = $_records->name;
             $containers = Tinebase_Container::getInstance()->getMultiple($containerIds);
         } else {
             $containers = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($_container));
         }
     }
     $app = Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName);
     $flatpathWithoutBasepath = Tinebase_Model_Tree_Node_Path::removeAppIdFromPath($_path->flatpath, $app);
     if ($records) {
         foreach ($records as $record) {
             $record->path = $flatpathWithoutBasepath . '/' . $record->name;
             $aclContainer = NULL;
             if (!$_path->container) {
                 // resolve container
                 if (!$record->name instanceof Tinebase_Model_Container) {
                     $idx = $containers->getIndexById($record->name);
                     if ($idx !== FALSE) {
                         $aclContainer = $containers[$idx];
                         $record->name = $aclContainer;
                         $record->path = $flatpathWithoutBasepath . '/' . $record->name->name;
                     }
                 }
             } else {
                 $aclContainer = $_path->container;
             }
             if ($aclContainer) {
                 $record->account_grants = Tinebase_Container::getInstance()->getGrantsOfAccount(Tinebase_Core::getUser(), $aclContainer)->toArray();
                 $aclContainer->account_grants = $record->account_grants;
                 // needed for sorting
                 $record->container_name = $aclContainer->name;
             }
         }
     }
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:52,代码来源:Node.php

示例2: updateApplications

 /**
  * updates installed applications. does nothing if no applications are installed
  *
  * @param Tinebase_Record_RecordSet $_applications
  * @return  array   messages
  */
 public function updateApplications(Tinebase_Record_RecordSet $_applications)
 {
     $this->_updatedApplications = 0;
     $smallestMajorVersion = NULL;
     $biggestMajorVersion = NULL;
     //find smallest major version
     foreach ($_applications as $application) {
         if ($smallestMajorVersion === NULL || $application->getMajorVersion() < $smallestMajorVersion) {
             $smallestMajorVersion = $application->getMajorVersion();
         }
         if ($biggestMajorVersion === NULL || $application->getMajorVersion() > $biggestMajorVersion) {
             $biggestMajorVersion = $application->getMajorVersion();
         }
     }
     $messages = array();
     // update tinebase first (to biggest major version)
     $tinebase = $_applications->filter('name', 'Tinebase')->getFirstRecord();
     if (!empty($tinebase)) {
         unset($_applications[$_applications->getIndexById($tinebase->getId())]);
         list($major, $minor) = explode('.', $this->getSetupXml('Tinebase')->version[0]);
         Setup_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updating Tinebase to version ' . $major . '.' . $minor);
         for ($majorVersion = $tinebase->getMajorVersion(); $majorVersion <= $major; $majorVersion++) {
             $messages += $this->updateApplication($tinebase, $majorVersion);
         }
     }
     // update the rest
     for ($majorVersion = $smallestMajorVersion; $majorVersion <= $biggestMajorVersion; $majorVersion++) {
         foreach ($_applications as $application) {
             if ($application->getMajorVersion() <= $majorVersion) {
                 $messages += $this->updateApplication($application, $majorVersion);
             }
         }
     }
     return array('messages' => $messages, 'updated' => $this->_updatedApplications);
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:41,代码来源:Controller.php

示例3: testGetIndexById

 public function testGetIndexById()
 {
     $idx = $this->object->getIndexById(1);
     $this->assertEquals(2, $idx);
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:5,代码来源:RecordSetTest.php

示例4: _setCfValueInRecord

 /**
  * set customfield value in record
  * 
  * @param Tinebase_Record_Abstract $record
  * @param Tinebase_Model_CustomField_Value $customField
  * @param Tinebase_Record_RecordSet $configs
  */
 protected function _setCfValueInRecord(Tinebase_Record_Abstract $record, Tinebase_Model_CustomField_Value $customField, Tinebase_Record_RecordSet $configs)
 {
     $recordCfs = $record->customfields;
     $idx = $configs->getIndexById($customField->customfield_id);
     if ($idx !== FALSE) {
         $config = $configs[$idx];
         if (strtolower($config->definition['type']) == 'record') {
             $value = $this->_getRecordTypeCfValue($config, $customField->value);
         } else {
             $value = $customField->value;
         }
         $recordCfs[$config->name] = $value;
     }
     // sort customfields by key
     if (is_array($recordCfs)) {
         ksort($recordCfs);
     }
     $record->customfields = $recordCfs;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:26,代码来源:CustomField.php

示例5: resolveAppRecords

 /**
  * resolved app records and fills the related_record property with the corresponding record
  * 
  * NOTE: With this, READ ACL is implicitly checked as non readable records won't get retuned!
  * 
  * @param  Tinebase_Record_RecordSet $_relations of Tinebase_Model_Relation
  * @param  boolean $_ignoreACL 
  * @return void
  * 
  * @todo    make getApplicationInstance work for tinebase record (Tinebase_Model_User for example)
  */
 protected function resolveAppRecords($_relations, $_ignoreACL = FALSE)
 {
     // separate relations by model
     $modelMap = array();
     foreach ($_relations as $relation) {
         if (!(isset($modelMap[$relation->related_model]) || array_key_exists($relation->related_model, $modelMap))) {
             $modelMap[$relation->related_model] = new Tinebase_Record_RecordSet('Tinebase_Model_Relation');
         }
         $modelMap[$relation->related_model]->addRecord($relation);
     }
     // fill related_record
     foreach ($modelMap as $modelName => $relations) {
         // check right
         $split = explode('_Model_', $modelName);
         $rightClass = $split[0] . '_Acl_Rights';
         $rightName = 'manage_' . strtolower($split[1]) . 's';
         if (class_exists($rightClass)) {
             $ref = new ReflectionClass($rightClass);
             $u = Tinebase_Core::getUser();
             // if a manage right is defined and the user has no manage_record or admin right, remove relations having this record class as related model
             if (is_object($u) && $ref->hasConstant(strtoupper($rightName)) && !$u->hasRight($split[0], $rightName) && !$u->hasRight($split[0], Tinebase_Acl_Rights::ADMIN)) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     $_relations->removeRecords($relations);
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Skipping relation due to no manage right: ' . $modelName);
                 }
                 continue;
             }
         }
         $getMultipleMethod = 'getMultiple';
         if ($modelName === 'Tinebase_Model_User') {
             // @todo add related backend here
             //$appController = Tinebase_User::factory($relations->related_backend);
             $appController = Tinebase_User::factory(Tinebase_User::getConfiguredBackend());
             $records = $appController->{$getMultipleMethod}($relations->related_id);
         } else {
             try {
                 $appController = Tinebase_Core::getApplicationInstance($modelName);
                 if (method_exists($appController, $getMultipleMethod)) {
                     $records = $appController->{$getMultipleMethod}($relations->related_id, $_ignoreACL);
                     // resolve record alarms
                     if (count($records) > 0 && $records->getFirstRecord()->has('alarms')) {
                         $appController->getAlarms($records);
                     }
                 } else {
                     throw new Tinebase_Exception_AccessDenied('Controller ' . get_class($appController) . ' has no method ' . $getMultipleMethod);
                 }
             } catch (Tinebase_Exception_AccessDenied $tea) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                     Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Removing relations from result. Got exception: ' . $tea->getMessage());
                 }
                 $_relations->removeRecords($relations);
                 continue;
             }
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Resolving " . count($relations) . " relations");
         }
         foreach ($relations as $relation) {
             $recordIndex = $records->getIndexById($relation->related_id);
             $relationIndex = $_relations->getIndexById($relation->getId());
             if ($recordIndex !== false) {
                 $_relations[$relationIndex]->related_record = $records[$recordIndex];
             } else {
                 // delete relation from set, as READ ACL is obviously not granted
                 if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                     Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " removing {$relation->related_model} {$relation->related_backend} {$relation->related_id} (ACL)");
                 }
                 unset($_relations[$relationIndex]);
             }
         }
     }
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:83,代码来源:Relations.php


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