本文整理汇总了PHP中Tinebase_Record_RecordSet::getFirstRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_RecordSet::getFirstRecord方法的具体用法?PHP Tinebase_Record_RecordSet::getFirstRecord怎么用?PHP Tinebase_Record_RecordSet::getFirstRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tinebase_Record_RecordSet
的用法示例。
在下文中一共展示了Tinebase_Record_RecordSet::getFirstRecord方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetFirstRecord
public function testGetFirstRecord()
{
$obj = new Tinebase_Record_RecordSet('Tinebase_Record_DummyRecord');
$r0 = new Tinebase_Record_DummyRecord(array('id' => 0), true);
$r1 = new Tinebase_Record_DummyRecord(array('id' => 1), true);
$obj->addRecord($r0);
$obj->addRecord($r1);
$this->assertTrue($obj->getFirstRecord() === $r0);
$obj->removeRecord($r0);
$this->assertTrue($obj->getFirstRecord() === $r1);
}
示例2: processIteration
/**
* @param Tinebase_Record_RecordSet $_records
* @throws Tinebase_Exception_NotImplemented
*/
public function processIteration($_records)
{
$record = $_records->getFirstRecord();
$converter = Tinebase_Convert_Factory::factory($record);
$resolved = $converter->fromTine20Model($record);
$this->_docTemplate->setValue('salutation_letter', $this->_getSalutation($resolved));
$this->_docTemplate->setValue('salutation_resolved', $this->_getShortSalutation($resolved));
parent::processIteration($_records);
}
示例3: getLastOpenItem
public function getLastOpenItem(Tinebase_Record_RecordSet $batchJobMonitionItems)
{
if ($batchJobMonitionItems->getCount() == 0) {
throw new Billing_Exception_OpenItem('Recordset does not contain any monition open items and therefore no related order.');
}
$batchJobMonitionItems->sort('open_item_id', 'DESC');
$record = $batchJobMonitionItems->getFirstRecord();
$openItem = $record->getForeignRecord('open_item_id', Billing_Controller_OpenItem::getInstance());
return $openItem;
}
示例4: 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;
}
示例5: _inspectBeforeCreate
/**
* inspect creation of one record (before create)
*
* @param Tinebase_Record_Interface $_record
* @return void
*/
protected function _inspectBeforeCreate(Tinebase_Record_Interface $_record)
{
$this->_freedaysToCreate = new Tinebase_Record_RecordSet('HumanResources_Model_FreeDay');
if (is_array($_record->employee_id)) {
$_record->employee_id = $_record->employee_id['id'];
}
if ($_record->freedays && !empty($_record->freedays)) {
foreach ($_record->freedays as $fd) {
if (!$fd instanceof HumanResources_Model_FreeDay) {
$fd = new HumanResources_Model_FreeDay($fd);
}
$this->_freedaysToCreate->addRecord($fd);
}
// normalize first-, last date and days_count
$this->_freedaysToCreate->sort('date', 'ASC');
$_record->firstday_date = $this->_freedaysToCreate->getFirstRecord()->date;
$this->_freedaysToCreate->sort('date', 'DESC');
$_record->lastday_date = $this->_freedaysToCreate->getFirstRecord()->date;
$_record->days_count = $this->_freedaysToCreate->count();
} else {
$_record->firstday_date = NULL;
}
}
示例6: _multipleRecordsToJson
/**
* returns multiple records prepared for json transport
*
* @param Tinebase_Record_RecordSet $_records Tinebase_Record_Abstract
* @param Tinebase_Model_Filter_FilterGroup $_filter
* @param Tinebase_Model_Pagination $_pagination
* @return array data
*/
protected function _multipleRecordsToJson(Tinebase_Record_RecordSet $_records, $_filter = NULL, $_pagination = NULL)
{
$result = array();
if ($_records->getFirstRecord()) {
$converter = Tinebase_Convert_Factory::factory($_records->getFirstRecord());
$result = $converter->fromTine20RecordSet($_records, $_filter, $_pagination);
}
return $result;
}
示例7: resolveMultipleUsers
/**
* resolves users of given record
*
* @param Tinebase_Record_RecordSet $_records
* @param string|array $_userProperties
* @param bool $_addNonExistingUsers
* @return void
*/
public function resolveMultipleUsers(Tinebase_Record_RecordSet $_records, $_userProperties, $_addNonExistingUsers = FALSE)
{
$userIds = array();
foreach ((array) $_userProperties as $property) {
// don't break if property is not in record
try {
$userIds = array_merge($userIds, $_records->{$property});
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' Records of class ' . get_class($_records->getFirstRecord()) . ' does not have property ' . $property);
}
}
}
$userIds = array_unique($userIds);
foreach ($userIds as $index => $userId) {
if (empty($userId)) {
unset($userIds[$index]);
}
}
// if no data return
if (empty($userIds)) {
return;
}
$users = $this->getMultiple($userIds);
$nonExistingUser = $this->getNonExistentUser();
foreach ($_records as $record) {
foreach ((array) $_userProperties as $property) {
if ($record->{$property} && is_string($record->{$property})) {
$idx = $users->getIndexById($record->{$property});
$user = $idx !== false ? $users[$idx] : NULL;
if (!$user && $_addNonExistingUsers) {
$user = $nonExistingUser;
}
if ($user) {
$record->{$property} = $user;
}
}
}
}
}
示例8: _moveMessagesToTrash
/**
* move messages to trash
*
* @param Tinebase_Record_RecordSet $_messagesInFolder
* @param string $_folderId
* @return boolean did we move messages?
*/
protected function _moveMessagesToTrash(Tinebase_Record_RecordSet $_messagesInFolder, $_folderId)
{
// messages should be moved to trash -> need to determine the trash folder for the account of the folder that contains the messages
$targetFolder = Expressomail_Controller_Account::getInstance()->getSystemFolder($_messagesInFolder->getFirstRecord()->account_id, Expressomail_Model_Folder::FOLDER_TRASH);
if ($_folderId === $targetFolder->id) {
return FALSE;
}
try {
$this->_moveMessagesInFolderOnSameAccount($_messagesInFolder, $targetFolder);
} catch (Tinebase_Exception_NotFound $tenf) {
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' No trash folder found - skipping messages in this folder.');
}
return FALSE;
}
return TRUE;
}
示例9: joinTempFiles
/**
* joins all given tempfiles in given order to a single new tempFile
*
* @param Tinebase_Record_RecordSet $_tempFiles
* @return Tinebase_Model_TempFile
*/
public function joinTempFiles($_tempFiles)
{
$path = tempnam(Tinebase_Core::getTempDir(), 'tine_tempfile_');
$name = preg_replace('/\\.\\d+\\.chunk$/', '', $_tempFiles->getFirstRecord()->name);
$type = $_tempFiles->getFirstRecord()->type;
$size = 0.0;
$fJoin = fopen($path, 'w+b');
foreach ($_tempFiles as $tempFile) {
$fChunk = @fopen($tempFile->path, "rb");
if (!$fChunk) {
throw new Tinebase_Exception_UnexpectedValue("Can not open chunk {$tempFile->id}");
}
// NOTE: stream_copy_to_stream is about 15% slower
while (!feof($fChunk)) {
$bytesWritten = fwrite($fJoin, fread($fChunk, 2097152));
$size += (double) $bytesWritten;
}
fclose($fChunk);
}
fclose($fJoin);
return $this->createTempFile($path, $name, $type, $size);
}
示例10: _validateConstraintsConfig
/**
* validate constraints from the own and the other side.
* this may be very expensive, if there are many constraints to check.
*
* @param string $ownModel
* @param Tinebase_Record_RecordSet $relations
* @throws Tinebase_Exception_InvalidRelationConstraints
*/
protected function _validateConstraintsConfig($ownModel, $relations, $toDelete = array(), $toUpdate = array())
{
if (!$relations->count()) {
return;
}
$relatedModels = array_unique($relations->related_model);
$relatedIds = array_unique($relations->related_id);
$toDelete = is_array($toDelete) ? $toDelete : array();
$toUpdate = is_array($toUpdate) ? $toUpdate : array();
$excludeCount = array_merge($toDelete, $toUpdate);
$ownId = $relations->getFirstRecord()->own_id;
// find out all models having a constraints config
$allModels = $relatedModels;
$allModels[] = $ownModel;
$allModels = array_unique($allModels);
$constraintsConfigs = self::getConstraintsConfigs($allModels);
$relatedConstraints = $this->_backend->countRelatedConstraints($ownModel, $relations, $excludeCount);
$groups = array();
foreach ($relations as $relation) {
$groups[] = $relation->related_model . '--' . $relation->type . '--' . $relation->own_id;
}
$myConstraints = array_count_values($groups);
$groups = array();
foreach ($relations as $relation) {
if (!in_array($relation->getId(), $excludeCount)) {
$groups[] = $relation->own_model . '--' . $relation->type . '--' . $relation->related_id;
}
}
foreach ($relatedConstraints as $relC) {
for ($i = 0; $i < $relC['count']; $i++) {
$groups[] = $relC['id'];
}
}
$allConstraints = array_count_values($groups);
foreach ($constraintsConfigs as $cc) {
foreach ($cc['config'] as $config) {
$group = $cc['relatedRecordClassName'] . '--' . $config['type'];
$idGroup = $group . '--' . $ownId;
if (isset($myConstraints[$idGroup]) && ($config['max'] > 0 && $config['max'] < $myConstraints[$idGroup])) {
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Constraints validation failed from the own side! ' . print_r($cc, 1));
}
throw new Tinebase_Exception_InvalidRelationConstraints();
}
// TODO: if the other side gets the config reverted here, validating constrains failes here on multiple update
foreach ($relatedIds as $relatedId) {
$idGroup = $group . '--' . $relatedId;
if (isset($allConstraints[$idGroup]) && ($config['max'] > 0 && $config['max'] < $allConstraints[$idGroup])) {
if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Constraints validation failed from the other side! ' . print_r($cc, 1));
}
throw new Tinebase_Exception_InvalidRelationConstraints();
}
}
}
}
}