本文整理汇总了PHP中Tinebase_Record_RecordSet::getById方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::getById方法的具体用法?PHP Tinebase_Record_RecordSet::getById怎么用?PHP Tinebase_Record_RecordSet::getById使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::getById方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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));
}
}
示例2: getInvoice
/**
* Return a single record
*
* @param string $id
* @return array record data
*/
public function getInvoice($id)
{
$invoice = $this->_get($id, Sales_Controller_Invoice::getInstance());
$json = new Tinebase_Convert_Json();
$resolvedProducts = new Tinebase_Record_RecordSet('Sales_Model_Product');
$productController = Sales_Controller_Product::getInstance();
foreach ($invoice['relations'] as &$relation) {
if ($relation['related_model'] == "Sales_Model_ProductAggregate") {
if (!($product = $resolvedProducts->getById($relation['related_record']['product_id']))) {
$product = $productController->get($relation['related_record']['product_id']);
$resolvedProducts->addRecord($product);
}
$relation['related_record']['product_id'] = $json->fromTine20Model($product);
}
}
return $invoice;
}
示例3: diff
/**
* compares two recordsets / only compares the ids / returns all records that are different in an array:
* - removed -> all records that are in $this but not in $_recordSet
* - added -> all records that are in $_recordSet but not in $this
* - modified -> array of diffs for all different records that are in both record sets
*
* @param Tinebase_Record_RecordSet $recordSet
* @return Tinebase_Record_RecordSetDiff
*/
public function diff($recordSet)
{
if (!$recordSet instanceof Tinebase_Record_RecordSet) {
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Did not get Tinebase_Record_RecordSet, skipping diff(' . $this->_recordClass . ')');
}
return new Tinebase_Record_RecordSetDiff(array('model' => $this->getRecordClassName()));
}
if ($this->getRecordClassName() !== $recordSet->getRecordClassName()) {
throw new Tinebase_Exception_InvalidArgument('can only compare recordsets with the same type of records');
}
$existingRecordsIds = $this->getArrayOfIds();
$toCompareWithRecordsIds = $recordSet->getArrayOfIds();
$removedIds = array_diff($existingRecordsIds, $toCompareWithRecordsIds);
$addedIds = array_diff($toCompareWithRecordsIds, $existingRecordsIds);
$modifiedIds = array_intersect($existingRecordsIds, $toCompareWithRecordsIds);
$removed = new Tinebase_Record_RecordSet($this->getRecordClassName());
$added = new Tinebase_Record_RecordSet($this->getRecordClassName());
$modified = new Tinebase_Record_RecordSet('Tinebase_Record_Diff');
foreach ($addedIds as $id) {
$added->addRecord($recordSet->getById($id));
}
// consider records without id, too
foreach ($recordSet->getIdLessIndexes() as $index) {
$added->addRecord($recordSet->getByIndex($index));
}
foreach ($removedIds as $id) {
$removed->addRecord($this->getById($id));
}
// consider records without id, too
foreach ($this->getIdLessIndexes() as $index) {
$removed->addRecord($this->getByIndex($index));
}
foreach ($modifiedIds as $id) {
$diff = $this->getById($id)->diff($recordSet->getById($id));
if (!$diff->isEmpty()) {
$modified->addRecord($diff);
}
}
$result = new Tinebase_Record_RecordSetDiff(array('model' => $this->getRecordClassName(), 'added' => $added, 'removed' => $removed, 'modified' => $modified));
return $result;
}
示例4: _sendNotificationToResponsibles
/**
* sends a notification email to all responsibles of imported leads
*
* @throws Tinebase_Exception_Record_NotAllowed
*
* @see TODO add issue
*/
protected function _sendNotificationToResponsibles()
{
$responsibles = new Tinebase_Record_RecordSet('Addressbook_Model_Contact');
$leadsByResponsibleId = array();
foreach ($this->_importResult['results'] as $importedRecord) {
// add responsibles if not already in record set and add lead to $leadsByResponsibleId
$responsiblesForImportedLead = $importedRecord->getResponsibles();
foreach ($responsiblesForImportedLead as $responsible) {
if (!$responsibles->getById($responsible->getId())) {
$responsibles->addRecord($responsible);
$leadsByResponsibleId[$responsible->getId()] = new Tinebase_Record_RecordSet('Crm_Model_Lead');
}
$leadsByResponsibleId[$responsible->getId()]->addRecord($importedRecord);
}
}
foreach ($responsibles as $responsible) {
if (isset($leadsByResponsibleId[$responsible->getId()])) {
$this->_sendNotificationToResponsible($responsible, $leadsByResponsibleId[$responsible->getId()]);
}
}
}