本文整理汇总了PHP中Tinebase_Record_RecordSet::addIndices方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::addIndices方法的具体用法?PHP Tinebase_Record_RecordSet::addIndices怎么用?PHP Tinebase_Record_RecordSet::addIndices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::addIndices方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _sortFolders
/**
* sort folder record set
* - begin with INBOX + other standard/system folders, add other folders
*
* @param Tinebase_Record_RecordSet $_folders
* @param string $_parentFolder
* @return Tinebase_Record_RecordSet
*/
protected function _sortFolders(Tinebase_Record_RecordSet $_folders, $_parentFolder)
{
$sortedFolders = new Tinebase_Record_RecordSet('Felamimail_Model_Folder');
$_folders->sort('localname', 'ASC', 'natcasesort');
$_folders->addIndices(array('globalname'));
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Sorting subfolders of "' . $_parentFolder . '".');
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($_folders->globalname, TRUE));
}
foreach ($this->_systemFolders as $systemFolderName) {
$folders = $_folders->filter('globalname', '@^' . $systemFolderName . '$@i', TRUE);
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . $systemFolderName . ' => ' . print_r($folders->toArray(), TRUE));
if (count($folders) > 0) {
$sortedFolders->addRecord($folders->getFirstRecord());
}
}
foreach ($_folders as $folder) {
if (!in_array(strtolower($folder->globalname), $this->_systemFolders)) {
$sortedFolders->addRecord($folder);
}
}
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($sortedFolders->globalname, TRUE));
return $sortedFolders;
}
示例2: _rawDataToRecordSet
/**
* converts raw data from adapter into a set of records
*
* @param array $_rawData of arrays
* @return Tinebase_Record_RecordSet
*/
protected function _rawDataToRecordSet(array $_rawData)
{
$events = new Tinebase_Record_RecordSet($this->_modelName);
$events->addIndices(array('rrule', 'recurid'));
foreach ($_rawData as $rawEvent) {
$rawEvent['rrule_constraints'] = Tinebase_Helper::is_json($rawEvent['rrule_constraints']) ? json_decode($rawEvent['rrule_constraints'], true) : NULL;
$events->addRecord(new Calendar_Model_Event($rawEvent, true));
}
$this->appendForeignRecordSetToRecordSet($events, 'attendee', 'id', Calendar_Backend_Sql_Attendee::FOREIGNKEY_EVENT, $this->_attendeeBackend);
return $events;
}
示例3: _getExceptionsMigration
/**
* computes an returns the migration for event exceptions
*
* @param Tinebase_Record_RecordSet $_currentPersistentExceptions
* @param Tinebase_Record_RecordSet $_newPersistentExceptions
*/
protected function _getExceptionsMigration($_currentPersistentExceptions, $_newPersistentExceptions)
{
$migration = array();
// add indices and sort to speedup things
$_currentPersistentExceptions->addIndices(array('dtstart'))->sort('dtstart');
$_newPersistentExceptions->addIndices(array('dtstart'))->sort('dtstart');
// get dtstarts
$currDtStart = $_currentPersistentExceptions->getOriginalDtStart();
$newDtStart = $_newPersistentExceptions->getOriginalDtStart();
// compute migration in terms of dtstart
$toDeleteDtStart = array_diff($currDtStart, $newDtStart);
$toCreateDtStart = array_diff($newDtStart, $currDtStart);
$toUpdateDtSTart = array_intersect($currDtStart, $newDtStart);
$migration['toDelete'] = $this->_filterEventsByDTStarts($_currentPersistentExceptions, $toDeleteDtStart);
$migration['toCreate'] = $this->_filterEventsByDTStarts($_newPersistentExceptions, $toCreateDtStart);
$migration['toUpdate'] = $this->_filterEventsByDTStarts($_newPersistentExceptions, $toUpdateDtSTart);
// get ids for toUpdate
$idxIdMap = $this->_filterEventsByDTStarts($_currentPersistentExceptions, $toUpdateDtSTart)->getId();
$migration['toUpdate']->setByIndices('id', $idxIdMap, true);
// filter exceptions marked as don't touch
foreach ($migration['toUpdate'] as $toUpdate) {
if ($toUpdate->seq === -1) {
$migration['toUpdate']->removeRecord($toUpdate);
}
}
return $migration;
}
示例4: resolveGroupMembers
/**
* resolves group members and adds/removes them if nesesary
*
* NOTE: If a user is listed as user and as groupmember, we supress the groupmember
*
* NOTE: The role to assign to a new group member is not always clear, as multiple groups
* might be the 'source' of the group member. To deal with this, we take the role of
* the first group when we add new group members
*
* @param Tinebase_Record_RecordSet $_attendee
* @return void
*/
public static function resolveGroupMembers($_attendee)
{
if (!$_attendee instanceof Tinebase_Record_RecordSet) {
return;
}
$_attendee->addIndices(array('user_type'));
// flatten user_ids (not groups for group/list handling bellow)
foreach ($_attendee as $attendee) {
if ($attendee->user_type != Calendar_Model_Attender::USERTYPE_GROUP && $attendee->user_id instanceof Tinebase_Record_Abstract) {
$attendee->user_id = $attendee->user_id->getId();
}
}
$groupAttendee = $_attendee->filter('user_type', Calendar_Model_Attender::USERTYPE_GROUP);
$allCurrGroupMembers = $_attendee->filter('user_type', Calendar_Model_Attender::USERTYPE_GROUPMEMBER);
$allCurrGroupMembersContactIds = $allCurrGroupMembers->user_id;
$allGroupMembersContactIds = array();
foreach ($groupAttendee as $groupAttender) {
#$groupAttenderMemberIds = Tinebase_Group::getInstance()->getGroupMembers($groupAttender->user_id);
#$groupAttenderContactIds = Tinebase_User::getInstance()->getMultiple($groupAttenderMemberIds)->contact_id;
#$allGroupMembersContactIds = array_merge($allGroupMembersContactIds, $groupAttenderContactIds);
$listId = null;
if ($groupAttender->user_id instanceof Addressbook_Model_List) {
$listId = $groupAttender->user_id->getId();
} else {
if ($groupAttender->user_id !== NULL) {
$group = Tinebase_Group::getInstance()->getGroupById($groupAttender->user_id);
if (!empty($group->list_id)) {
$listId = $group->list_id;
}
} else {
if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Group attender ID missing');
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' ' . print_r($groupAttender->toArray(), TRUE));
}
}
}
if ($listId !== null) {
$groupAttenderContactIds = Addressbook_Controller_List::getInstance()->get($listId)->members;
$allGroupMembersContactIds = array_merge($allGroupMembersContactIds, $groupAttenderContactIds);
$toAdd = array_diff($groupAttenderContactIds, $allCurrGroupMembersContactIds);
foreach ($toAdd as $userId) {
$_attendee->addRecord(new Calendar_Model_Attender(array('user_type' => Calendar_Model_Attender::USERTYPE_GROUPMEMBER, 'user_id' => $userId, 'role' => $groupAttender->role)));
}
}
}
$toDel = array_diff($allCurrGroupMembersContactIds, $allGroupMembersContactIds);
foreach ($toDel as $idx => $contactId) {
$attender = $allCurrGroupMembers->find('user_id', $contactId);
$_attendee->removeRecord($attender);
}
// calculate double members (groupmember + user)
$groupmembers = $_attendee->filter('user_type', Calendar_Model_Attender::USERTYPE_GROUPMEMBER);
$users = $_attendee->filter('user_type', Calendar_Model_Attender::USERTYPE_USER);
$doublicates = array_intersect($users->user_id, $groupmembers->user_id);
foreach ($doublicates as $user_id) {
$attender = $groupmembers->find('user_id', $user_id);
$_attendee->removeRecord($attender);
}
}
示例5: testRegexpFilter
public function testRegexpFilter()
{
$recordSet = new Tinebase_Record_RecordSet('Tinebase_Record_DummyRecord');
$recordSet->addRecord(new Tinebase_Record_DummyRecord(array('id' => '100', 'string' => 'bommel-1'), true));
$recordSet->addRecord(new Tinebase_Record_DummyRecord(array('id' => '200', 'string' => 'super-1'), true));
$recordSet->addRecord(new Tinebase_Record_DummyRecord(array('id' => '300', 'string' => 'bommel-2'), true));
$filterResultWOIndices = $recordSet->filter('string', '/^bommel.*/', TRUE);
$this->assertEquals(2, count($filterResultWOIndices));
$this->assertEquals(array(100, 300), $filterResultWOIndices->getArrayOfIds());
$recordSet->addIndices(array('string'));
$filterResultWIndices = $recordSet->filter('string', '/^bommel.*/', TRUE);
$this->assertEquals(count($filterResultWOIndices), count($filterResultWIndices));
$this->assertEquals(array(100, 300), $filterResultWIndices->getArrayOfIds());
}
示例6: processMoveIteration
/**
* move messages
*
* @param Tinebase_Record_RecordSet $_messages
* @param mixed $_targetFolder can be one of: Felamimail_Model_Folder or Felamimail_Model_Folder::FOLDER_TRASH (constant)
* @return Tinebase_Record_RecordSet of Felamimail_Model_Folder
*/
public function processMoveIteration($_messages, $_targetFolder)
{
$_messages->addIndices(array('folder_id'));
$movedMessages = FALSE;
foreach (array_unique($_messages->folder_id) as $folderId) {
$movedMessages = $this->_moveMessagesByFolder($_messages, $folderId, $_targetFolder) || $movedMessages;
}
if (!$movedMessages) {
// no messages have been moved -> return empty record set
$result = new Tinebase_Record_RecordSet('Felamimail_Model_Folder');
} else {
// delete messages in local cache
$number = $this->_backend->delete($_messages->getArrayOfIds());
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Deleted ' . $number . ' messages from cache');
}
$result = $this->_updateCountsAfterMove($_messages);
}
return $result;
}
示例7: addMultipleModificationSystemNotes
/**
* add multiple modification system nodes
*
* @param Tinebase_Record_RecordSet $_mods
* @param string $_userId
* @param string $modelName
*/
public function addMultipleModificationSystemNotes($_mods, $_userId, $modelName = null)
{
$_mods->addIndices(array('record_id'));
foreach ($_mods->record_id as $recordId) {
$modsOfRecord = $_mods->filter('record_id', $recordId);
$this->addSystemNote($recordId, $_userId, Tinebase_Model_Note::SYSTEM_NOTE_NAME_CHANGED, $modsOfRecord, 'Sql', $modelName);
}
}