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


PHP Tinebase_Record_RecordSet::toArray方法代码示例

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


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

示例1: testToArray

 /**
  * test toArray() implementation
  */
 public function testToArray()
 {
     $resultArray = $this->object->toArray();
     for ($i = 0; $i < count($this->object); $i++) {
         $this->assertEquals($this->object[$i]->toArray(), $resultArray[$i]);
     }
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:10,代码来源:RecordSetTest.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: fromTine20RecordSet

 /**
  * convert Tinebase_Record_RecordSet to Sabre\VObject\Component
  *
  * @param  Tinebase_Record_RecordSet  $_records
  * @return Sabre\VObject\Component
  */
 public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Events: ' . print_r($_records->toArray(), true));
     }
     // required vcalendar fields
     $version = Tinebase_Application::getInstance()->getApplicationByName('Calendar')->version;
     $vcalendar = new \Sabre\VObject\Component\VCalendar(array('PRODID' => "-//tine20.com//Tine 2.0 Calendar V{$version}//EN", 'VERSION' => '2.0', 'CALSCALE' => 'GREGORIAN'));
     if (isset($this->_method)) {
         $vcalendar->add('METHOD', $this->_method);
     }
     $originatorTz = $_records->getFirstRecord() ? $_records->getFirstRecord()->originator_tz : NULL;
     if (empty($originatorTz)) {
         throw new Tinebase_Exception_Record_Validation('originator_tz needed for conversion to Sabre\\VObject\\Component');
     }
     try {
         $vcalendar->add(new Sabre_VObject_Component_VTimezone($originatorTz));
     } catch (Exception $e) {
         Tinebase_Exception::log($e);
         throw new Tinebase_Exception_Record_Validation('Bad Timezone: ' . $originatorTz);
     }
     foreach ($_records as $_record) {
         $this->_convertCalendarModelEvent($vcalendar, $_record);
         if ($_record->exdate instanceof Tinebase_Record_RecordSet) {
             $_record->exdate->addIndices(array('is_deleted'));
             $eventExceptions = $_record->exdate->filter('is_deleted', false);
             foreach ($eventExceptions as $eventException) {
                 $this->_convertCalendarModelEvent($vcalendar, $eventException, $_record);
             }
         }
     }
     $this->_afterFromTine20Model($vcalendar);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' card ' . $vcalendar->serialize());
     }
     return $vcalendar;
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:43,代码来源:Abstract.php

示例4: getPathOfNode

 /**
  * get path of node
  * 
  * @param Tinebase_Model_Tree_Node|string $node
  * @param boolean $getPathAsString
  * @return array|string
  */
 public function getPathOfNode($node, $getPathAsString = FALSE)
 {
     $node = $node instanceof Tinebase_Model_Tree_Node ? $node : $this->get($node);
     $nodesPath = new Tinebase_Record_RecordSet('Tinebase_Model_Tree_Node', array($node));
     while ($node->parent_id) {
         $node = $this->get($node->parent_id);
         $nodesPath->addRecord($node);
     }
     $result = $getPathAsString ? '/' . implode('/', array_reverse($nodesPath->name)) : array_reverse($nodesPath->toArray());
     return $result;
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:18,代码来源:FileSystem.php

示例5: _updateDependentRecords


//.........这里部分代码省略.........
  * @param Tinebase_Record_Interface $_oldRecord
  * @param string $_property
  * @param array $_fieldConfig
  */
 protected function _updateDependentRecords(Tinebase_Record_Interface $_record, Tinebase_Record_Interface $_oldRecord, $_property, $_fieldConfig)
 {
     if (!(isset($_fieldConfig['dependentRecords']) || array_key_exists('dependentRecords', $_fieldConfig)) || !$_fieldConfig['dependentRecords']) {
         return;
     }
     if (!isset($_fieldConfig['refIdField'])) {
         throw new Tinebase_Exception_Record_DefinitionFailure('If a record is dependent, a refIdField has to be defined!');
     }
     // don't handle dependent records on property if it is set to null or doesn't exist.
     if ($_record->{$_property} === NULL || !$_record->has($_property)) {
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Skip updating dependent records (got NULL) on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName . ' with id = "' . $_record->getId() . '"');
         }
         return;
     }
     $ccn = $_fieldConfig['controllerClassName'];
     $controller = $ccn::getInstance();
     $recordClassName = $_fieldConfig['recordClassName'];
     $filterClassName = $_fieldConfig['filterClassName'];
     $existing = new Tinebase_Record_RecordSet($recordClassName);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_record->{$_property}, TRUE));
     }
     if (!empty($_record->{$_property}) && $_record->{$_property}) {
         // legacy - should be already done in frontend json - remove if all record properties are record sets before getting to controller
         if (is_array($_record->{$_property})) {
             $rs = new Tinebase_Record_RecordSet($recordClassName);
             foreach ($_record->{$_property} as $recordArray) {
                 $rec = new $recordClassName(array(), true);
                 $rec->setFromJsonInUsersTimezone($recordArray);
                 $rs->addRecord($rec);
             }
             $_record->{$_property} = $rs;
         }
         $idProperty = $_record->{$_property}->getFirstRecord()->getIdProperty();
         // legacy end
         $oldFilter = new $filterClassName(array(array('field' => $idProperty, 'operator' => 'in', 'value' => $_record->{$_property}->getId())));
         $oldRecords = $controller->search($oldFilter);
         foreach ($_record->{$_property} as $record) {
             $record->{$_fieldConfig['refIdField']} = $_record->getId();
             // update record if ID exists and has a length of 40 (it has a length of 10 if it is a timestamp)
             if ($record->getId() && strlen($record->getId()) == 40) {
                 // do not try to update if the record hasn't changed
                 $oldRecord = $oldRecords->getById($record->getId());
                 if ($oldRecord && !empty($oldRecord->diff($record)->diff)) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updating dependent record with id = "' . $record->getId() . '" on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName);
                     }
                     $existing->addRecord($controller->update($record));
                 } else {
                     $existing->addRecord($record);
                 }
                 // create if is not existing already
             } else {
                 // try to find if it already exists (with corrupted id)
                 if ($record->getId() == NULL) {
                     $crc = $controller->create($record);
                     $existing->addRecord($crc);
                     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Creating dependent record with id = "' . $crc->getId() . '" on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName);
                     }
                 } else {
                     try {
                         $prevRecord = $controller->get($record->getId());
                         if (!empty($prevRecord->diff($record)->diff)) {
                             $existing->addRecord($controller->update($record));
                         } else {
                             $existing->addRecord($record);
                         }
                     } catch (Tinebase_Exception_NotFound $e) {
                         $record->id = NULL;
                         $crc = $controller->create($record);
                         $existing->addRecord($crc);
                         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Creating dependent record with id = "' . $crc->getId() . '" on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName);
                         }
                     }
                 }
             }
         }
     }
     $filter = new $filterClassName(isset($_fieldConfig['addFilters']) ? $_fieldConfig['addFilters'] : array(), 'AND');
     $filter->addFilter(new Tinebase_Model_Filter_Text($_fieldConfig['refIdField'], 'equals', $_record->getId()));
     // an empty array will remove all records on this property
     if (!empty($_record->{$_property})) {
         $filter->addFilter(new Tinebase_Model_Filter_Id('id', 'notin', $existing->getId()));
     }
     $deleteIds = $controller->search($filter, NULL, FALSE, TRUE);
     if (!empty($deleteIds)) {
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Deleting dependent records with id = "' . print_r($deleteIds, 1) . '" on property ' . $_property . ' for ' . $this->_applicationName . ' ' . $this->_modelName);
         }
         $controller->delete($deleteIds);
     }
     $_record->{$_property} = $existing->toArray();
 }
开发者ID:bitExpert,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:101,代码来源:Abstract.php

示例6: getRules

 /**
  * get rules for account
  * 
  * @param string $_accountId
  * @return Tinebase_Record_RecordSet of Felamimail_Model_Sieve_Rule
  */
 public function getRules($_accountId)
 {
     $result = new Tinebase_Record_RecordSet('Felamimail_Model_Sieve_Rule');
     $script = $this->_getSieveScript($_accountId);
     if ($script !== NULL) {
         foreach ($script->getRules() as $fsr) {
             $rule = new Felamimail_Model_Sieve_Rule();
             $rule->setFromFSR($fsr);
             $result->addRecord($rule);
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($result->toArray(), TRUE));
         }
     } else {
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Sieve script empty or could not parse it.');
         }
     }
     return $result;
 }
开发者ID:rodrigofns,项目名称:ExpressoLivre3,代码行数:26,代码来源:Sieve.php

示例7: _addSharedTags

 /**
  * add/create shared tags if they don't exist
  *
  * @param   array $_tags array of tag strings
  * @return  Tinebase_Record_RecordSet with Tinebase_Model_Tag
  */
 protected function _addSharedTags($_tags)
 {
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Adding tags: ' . print_r($_tags, TRUE));
     }
     $result = new Tinebase_Record_RecordSet('Tinebase_Model_Tag');
     foreach ($_tags as $tagData) {
         $tagData = is_array($tagData) ? $tagData : array('name' => $tagData);
         $tagName = trim($tagData['name']);
         // only check non-empty tags
         if (empty($tagName)) {
             continue;
         }
         $createTag = isset($this->_options['shared_tags']) && $this->_options['shared_tags'] == 'create';
         $tagToAdd = $this->_getSingleTag($tagName, $tagData, $createTag);
         if ($tagToAdd) {
             $result->addRecord($tagToAdd);
         }
     }
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($result->toArray(), TRUE));
     }
     return $result;
 }
开发者ID:hernot,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:30,代码来源:Abstract.php

示例8: toArray

 /**
  * returns existing nodes info as array
  * 
  * @return array
  */
 public function toArray()
 {
     $this->getExistingNodesInfo()->setTimezone(Tinebase_Core::getUserTimezone());
     return array('existingnodesinfo' => $this->_existingNodes->toArray());
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:10,代码来源:NodeExists.php

示例9: testResourceAttendeeGrants

 /**
  * assert status authkey with editGrant
  * assert stauts can be set with editGrant
  * assert stauts can't be set without editGrant
  */
 public function testResourceAttendeeGrants()
 {
     $editableResoureData = $this->testSaveResource();
     $nonEditableResoureData = $this->testSaveResource(array('readGrant'));
     $event = $this->_getEvent(TRUE);
     $event->attendee = new Tinebase_Record_RecordSet('Calendar_Model_Attender', array(array('user_type' => Calendar_Model_Attender::USERTYPE_RESOURCE, 'user_id' => $editableResoureData['id'], 'status' => Calendar_Model_Attender::STATUS_ACCEPTED), array('user_type' => Calendar_Model_Attender::USERTYPE_RESOURCE, 'user_id' => $nonEditableResoureData['id'], 'status' => Calendar_Model_Attender::STATUS_ACCEPTED)));
     $persistentEventData = $this->_uit->saveEvent($event->toArray());
     $attendee = new Tinebase_Record_RecordSet('Calendar_Model_Attender', $persistentEventData['attendee']);
     $this->assertEquals(1, count($attendee->filter('status', Calendar_Model_Attender::STATUS_ACCEPTED)), 'one accepted');
     $this->assertEquals(1, count($attendee->filter('status', Calendar_Model_Attender::STATUS_NEEDSACTION)), 'one needs action');
     $this->assertEquals(1, count($attendee->filter('status_authkey', '/[a-z0-9]+/', TRUE)), 'one has authkey');
     $attendee->status = Calendar_Model_Attender::STATUS_TENTATIVE;
     $persistentEventData['attendee'] = $attendee->toArray();
     $updatedEventData = $this->_uit->saveEvent($persistentEventData);
     $attendee = new Tinebase_Record_RecordSet('Calendar_Model_Attender', $updatedEventData['attendee']);
     $this->assertEquals(1, count($attendee->filter('status', Calendar_Model_Attender::STATUS_TENTATIVE)), 'one tentative');
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:22,代码来源:JsonTests.php

示例10: _inspectBeforeUpdate

 protected function _inspectBeforeUpdate($_record, $_oldRecord)
 {
     // if empty, no changes have been made
     // @todo: lookforward: parts - parameter
     if (empty($_record->freedays)) {
         return;
     }
     $freeDays = new Tinebase_Record_RecordSet('HumanResources_Model_FreeDay');
     $fc = HumanResources_Controller_FreeDay::getInstance();
     $freetimeId = $_record->getId();
     foreach ($_record->freedays as $freedayArray) {
         $freedayArray['freetime_id'] = $freetimeId;
         $freeday = new HumanResources_Model_FreeDay($freedayArray);
         if ($freeday->id) {
             $freeDays->addRecord($fc->update($freeday));
         } else {
             $freeDays->addRecord($fc->create($freeday));
         }
     }
     $filter = new HumanResources_Model_FreeDayFilter(array(), 'AND');
     $filter->addFilter(new Tinebase_Model_Filter_Text('freetime_id', 'equals', $_record->getId()));
     $filter->addFilter(new Tinebase_Model_Filter_Id('id', 'notin', $freeDays->id));
     $deleteFreedays = HumanResources_Controller_FreeDay::getInstance()->search($filter);
     // update first and last date
     $freeDays->sort('date', 'ASC');
     $_record->firstday_date = $freeDays->getFirstRecord()->date;
     $freeDays->sort('date', 'DESC');
     $_record->lastday_date = $freeDays->getFirstRecord()->date;
     $_record->days_count = $freeDays->count();
     $fc->delete($deleteFreedays->id);
     $_record->freedays = $freeDays->toArray();
     if ($_record->type == 'sickness') {
         $this->_handleOverwrittenVacation($_record);
     }
 }
开发者ID:ingoratsdorf,项目名称:Tine-2.0-Open-Source-Groupware-and-CRM,代码行数:35,代码来源:FreeTime.php


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