本文整理汇总了PHP中Tinebase_Record_RecordSet::getId方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::getId方法的具体用法?PHP Tinebase_Record_RecordSet::getId怎么用?PHP Tinebase_Record_RecordSet::getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::getId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _removeFixtures
protected function _removeFixtures()
{
if ($this->_customerRecords) {
Sales_Controller_Customer::getInstance()->delete($this->_customerRecords->getId());
}
if ($this->_contactRecords) {
$this->_contactController->delete($this->_contactRecords->getId());
}
if ($this->_addressRecords) {
$this->_addressController->delete($this->_addressRecords->getId());
}
if ($this->_contractRecords) {
Sales_Controller_Contract::getInstance()->delete($this->_contractRecords->getId());
}
$paController = Sales_Controller_ProductAggregate::getInstance();
$paController->deleteByFilter(new Sales_Model_ProductAggregateFilter(array()));
$this->_invoiceController = Sales_Controller_Invoice::getInstance();
$this->_invoiceController->deleteByFilter(new Sales_Model_InvoiceFilter(array()));
}
示例2: getPathsForRecords
/**
* getPathsForRecords
*
* @param Tinebase_Record_Interface|Tinebase_Record_RecordSet $records
* @return Tinebase_Record_RecordSet
* @throws Tinebase_Exception_NotFound
*/
public function getPathsForRecords($records)
{
$ids = $records instanceof Tinebase_Record_Interface ? array($records->getId()) : $records->getArrayOfIds();
return $this->search(new Tinebase_Model_PathFilter(array(array('field' => 'record_id', 'operator' => 'in', 'value' => $ids))));
}
示例3: getAlarmsOfRecord
/**
* get all alarms of given record(s) / adds record_id index to result set
*
* @param string $_model model to get alarms for
* @param string|array|Tinebase_Record_Interface|Tinebase_Record_RecordSet $_recordId record id(s) to get alarms for
* @param boolean $_onlyIds
* @return Tinebase_Record_RecordSet|array of ids
*/
public function getAlarmsOfRecord($_model, $_recordId, $_onlyIds = FALSE)
{
if ($_recordId instanceof Tinebase_Record_RecordSet) {
$recordId = $_recordId->getArrayOfIds();
} else {
if ($_recordId instanceof Tinebase_Record_Interface) {
$recordId = $_recordId->getId();
} else {
$recordId = $_recordId;
}
}
//if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " model: '$_model' id:" . print_r((array)$recordId, true));
$filter = new Tinebase_Model_AlarmFilter(array(array('field' => 'model', 'operator' => 'equals', 'value' => $_model), array('field' => 'record_id', 'operator' => 'in', 'value' => (array) $recordId)));
$result = $this->_backend->search($filter, NULL, $_onlyIds);
// NOTE: Adding indices to empty recordsets breaks empty tests
if (count($result) > 0 && $result instanceof Tinebase_Record_RecordSet) {
$result->addIndices(array('record_id'));
}
return $result;
}
示例4: mergeContracts
/**
* merges source contracts into the target contract (relations and products)
*
* @param Sales_Model_Contract $targetContract
* @param Tinebase_Record_RecordSet $sourceContracts
*/
public function mergeContracts(Sales_Model_Contract $targetContract, Tinebase_Record_RecordSet $sourceContracts)
{
// handle relations (duplicates get skipped)
foreach ($sourceContracts as $sourceContract) {
Tinebase_Relations::getInstance()->transferRelations($sourceContract->getId(), $targetContract->getId(), 'Sales_Model_Contract');
}
// handle products
$filter = new Sales_Model_ProductAggregateFilter(array());
$filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'contract_id', 'operator' => 'in', 'value' => $sourceContracts->getId())));
$products = Sales_Controller_ProductAggregate::getInstance()->search($filter);
foreach ($products as $product) {
$product->contract_id = $targetContract->getId();
Sales_Controller_ProductAggregate::getInstance()->update($product);
}
return true;
}
示例5: _updateDependentRecords
/**
* updates dependent records on update the parent record
*
* @param Tinebase_Record_Interface $_record
* @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);
}
//.........这里部分代码省略.........
示例6: _getDefaultPhoneFilter
/**
* Gets the phone id filter for the first record in the given recordset
*
* @param Tinebase_Record_RecordSet $userPhones
* @return Tinebase_Model_Filter_Abstract
*/
protected function _getDefaultPhoneFilter($userPhones)
{
if ($userPhones->count()) {
$filter = new Phone_Model_CallFilter(array('id' => 'defaultAdded', 'field' => 'phone_id', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'in', 'value' => $userPhones->getId()))));
} else {
$filter = new Tinebase_Model_Filter_Text(array('id' => 'defaultAdded', 'field' => 'id', 'operator' => 'equals', 'value' => 'notexists'));
}
return $filter;
}
示例7: createRecurException
/**
* creates an exception instance of a recurring event
*
* NOTE: deleting persistent exceptions is done via a normal delete action
* and handled in the deleteInspection
*
* @param Calendar_Model_Event $_event
* @param bool $_deleteInstance
* @param bool $_allFollowing
* @param bool $_checkBusyConflicts
* @return Calendar_Model_Event exception Event | updated baseEvent
*
* @todo replace $_allFollowing param with $range
* @deprecated replace with create/update/delete
*/
public function createRecurException($_event, $_deleteInstance = FALSE, $_allFollowing = FALSE, $_checkBusyConflicts = FALSE)
{
$baseEvent = $this->getRecurBaseEvent($_event);
if ($baseEvent->last_modified_time != $_event->last_modified_time) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . " It is not allowed to create recur instance if it is clone of base event");
}
throw new Tinebase_Timemachine_Exception_ConcurrencyConflict('concurrency conflict!');
}
// // Maybe Later
// // exdates needs to stay in baseEvents container
// if ($_event->container_id != $baseEvent->container_id) {
// throw new Calendar_Exception_ExdateContainer();
// }
// check if this is an exception to the first occurence
if ($baseEvent->getId() == $_event->getId()) {
if ($_allFollowing) {
throw new Exception('please edit or delete complete series!');
}
// NOTE: if the baseEvent gets a time change, we can't compute the recurdid w.o. knowing the original dtstart
$recurid = $baseEvent->setRecurId($baseEvent->getId());
unset($baseEvent->recurid);
$_event->recurid = $recurid;
}
// just do attender status update if user has no edit grant
if ($this->_doContainerACLChecks && !$baseEvent->{Tinebase_Model_Grants::GRANT_EDIT}) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " user has no editGrant for event: '{$baseEvent->getId()}'. Only creating exception for attendee status");
}
if ($_event->attendee instanceof Tinebase_Record_RecordSet) {
foreach ($_event->attendee as $attender) {
if ($attender->status_authkey) {
$exceptionAttender = $this->attenderStatusCreateRecurException($_event, $attender, $attender->status_authkey, $_allFollowing);
}
}
}
if (!isset($exceptionAttender)) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG) && $_event->attendee instanceof Tinebase_Record_RecordSet) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Failed to update attendee: " . print_r($_event->attendee->toArray(), true));
}
throw new Tinebase_Exception_AccessDenied('Failed to update attendee, status authkey might be missing');
}
return $this->get($exceptionAttender->cal_event_id);
}
// NOTE: recurid is computed by rrule recur computations and therefore is already part of the event.
if (empty($_event->recurid)) {
throw new Exception('recurid must be present to create exceptions!');
}
// we do notifications ourself
$sendNotifications = $this->sendNotifications(FALSE);
// EDIT for baseEvent is checked above, CREATE, DELETE for recur exceptions is implied with it
$doContainerACLChecks = $this->doContainerACLChecks(FALSE);
$db = $this->_backend->getAdapter();
$transactionId = Tinebase_TransactionManager::getInstance()->startTransaction($db);
$exdate = new Tinebase_DateTime(substr($_event->recurid, -19));
$exdates = is_array($baseEvent->exdate) ? $baseEvent->exdate : array();
$originalDtstart = $_event->getOriginalDtStart();
$originalEvent = Calendar_Model_Rrule::computeNextOccurrence($baseEvent, new Tinebase_Record_RecordSet('Calendar_Model_Event'), $originalDtstart);
if ($_allFollowing != TRUE) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Adding exdate for: '{$_event->recurid}'");
}
array_push($exdates, $exdate);
$baseEvent->exdate = $exdates;
$updatedBaseEvent = $this->update($baseEvent, FALSE);
if ($_deleteInstance == FALSE) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . " Creating persistent exception for: '{$_event->recurid}'");
}
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . " Recur exception: " . print_r($_event->toArray(), TRUE));
}
$_event->base_event_id = $baseEvent->getId();
$_event->setId(NULL);
unset($_event->rrule);
unset($_event->exdate);
foreach (array('attendee', 'notes', 'alarms') as $prop) {
if ($_event->{$prop} instanceof Tinebase_Record_RecordSet) {
$_event->{$prop}->setId(NULL);
}
}
$originalDtstart = $_event->getOriginalDtStart();
$dtStartHasDiff = $originalDtstart->compare($_event->dtstart) != 0;
// php52 compat
if (!$dtStartHasDiff) {
//.........这里部分代码省略.........