本文整理汇总了PHP中Tinebase_Record_RecordSet::removeRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::removeRecord方法的具体用法?PHP Tinebase_Record_RecordSet::removeRecord怎么用?PHP Tinebase_Record_RecordSet::removeRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::removeRecord方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemoveRecord
public function testRemoveRecord()
{
$idLess1 = $this->object->find('string', 'idLess1');
$countBefore = $this->object->count();
$this->object->removeRecord($idLess1);
$this->assertEquals($countBefore - 1, $this->object->count(), 'recordSet count should decrease by 1');
foreach ($this->object as $record) {
$this->assertFalse($record === $idLess1, 'idLess1 is still in set');
}
}
示例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);
$records->removeRecord($record);
if (!$record->grants instanceof Tinebase_Record_RecordSet) {
$record->grants = new Tinebase_Record_RecordSet($this->_modelName);
}
$record->grants->addRecord($recordGrant);
// NOTICE: this is strange - we have to remove the record and add it
// again to make sure that grants are updated ...
// maybe we should add a "replace" method?
$records->addRecord($record);
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' Records with grants: ' . print_r($records->toArray(), true));
}
}
示例3: mergeRecurrenceSet
/**
* merges Recurrences of given events into the given event set
*
* @param Tinebase_Record_RecordSet $_events
* @param Tinebase_DateTime $_from
* @param Tinebase_DateTime $_until
* @return void
*/
public static function mergeRecurrenceSet($_events, $_from, $_until)
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " from: {$_from} until: {$_until}");
}
//compute recurset
$candidates = $_events->filter('rrule', "/^FREQ.*/", TRUE);
foreach ($candidates as $candidate) {
try {
$exceptions = $_events->filter('recurid', "/^{$candidate->uid}-.*/", TRUE);
$recurSet = Calendar_Model_Rrule::computeRecurrenceSet($candidate, $exceptions, $_from, $_until);
foreach ($recurSet as $event) {
$_events->addRecord($event);
}
// check if candidate/baseEvent has an exception itself -> in this case remove baseEvent from set
if (is_array($candidate->exdate) && in_array($candidate->dtstart, $candidate->exdate)) {
$_events->removeRecord($candidate);
}
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Could not compute recurSet of event: {$candidate->getId()}");
}
Tinebase_Exception::log($e);
continue;
}
}
}
示例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;
}
$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: _freeBusyCleanup
/**
* cleanup search results (freebusy)
*
* @param Tinebase_Record_RecordSet $_events
* @param string $_action
*/
protected function _freeBusyCleanup(Tinebase_Record_RecordSet $_events, $_action)
{
foreach ($_events as $event) {
$doFreeBusyCleanup = $event->doFreeBusyCleanup();
if ($doFreeBusyCleanup && $_action !== 'get') {
$_events->removeRecord($event);
}
}
}