本文整理汇总了PHP中Tinebase_Record_Abstract类的典型用法代码示例。如果您正苦于以下问题:PHP Tinebase_Record_Abstract类的具体用法?PHP Tinebase_Record_Abstract怎么用?PHP Tinebase_Record_Abstract使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Tinebase_Record_Abstract类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getPaymentMethodFromRecordOrDefault
/**
*
* Get the payment method (foreign record) in given record, or use default, if not set
* @param Tinebase_Record_Abstract $record
* @param unknown_type $fieldForeignId
*/
public function getPaymentMethodFromRecordOrDefault(Tinebase_Record_Abstract $record, $fieldForeignId)
{
if ($record->__get($fieldForeignId)) {
return $record->getForeignRecord($fieldForeignId, $this);
}
return $this->getDefaultPaymentMethod();
}
示例2: fromTine20Model
/**
* convert Tasks_Model_Task to \Sabre\VObject\Component
*
* @param Tasks_Model_Task $_record
* @return \Sabre\VObject\Component
*/
public function fromTine20Model(Tinebase_Record_Abstract $_record)
{
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' event ' . print_r($_record->toArray(), true));
}
$vcalendar = new \Sabre\VObject\Component\VCalendar();
// required vcalendar fields
$version = Tinebase_Application::getInstance()->getApplicationByName('Tasks')->version;
$vcalendar->PRODID = "-//tine20.com//Tine 2.0 Tasks V{$version}//EN";
$vcalendar->VERSION = '2.0';
$vcalendar->CALSCALE = 'GREGORIAN';
// catch exceptions for unknown timezones
try {
$vcalendar->add(new Sabre_VObject_Component_VTimezone($_record->originator_tz));
} catch (Exception $e) {
if (Tinebase_Core::isLogLevel(Zend_Log::WARN)) {
Tinebase_Core::getLogger()->warn(__METHOD__ . '::' . __LINE__ . ' timezone exception ' . $e->getMessage());
}
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' timezone exception ' . $e->getTraceAsString());
}
}
$this->_convertTasksModelTask($vcalendar, $_record);
$this->_afterFromTine20Model($vcalendar);
if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' card ' . $vcalendar->serialize());
}
return $vcalendar;
}
示例3: fromTine20Model
/**
* converts Addressbook_Model_Contact to vcard
*
* @param Addressbook_Model_Contact $_record
* @return \Sabre\VObject\Component\VCard
*/
public function fromTine20Model(Tinebase_Record_Abstract $_record)
{
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' contact ' . print_r($_record->toArray(), true));
}
// initialize vcard object
$card = $this->_fromTine20ModelRequiredFields($_record);
$card->add('TEL', $_record->tel_work, array('TYPE' => array('WORK', 'VOICE')));
$card->add('TEL', $_record->tel_home, array('TYPE' => array('HOME', 'VOICE')));
$card->add('TEL', $_record->tel_cell, array('TYPE' => 'CELL'));
$card->add('TEL', $_record->tel_cell_private, array('TYPE' => 'OTHER'));
$card->add('TEL', $_record->tel_fax, array('TYPE' => array('FAX', 'WORK')));
$card->add('TEL', $_record->tel_fax_home, array('TYPE' => array('FAX', 'HOME')));
$card->add('ADR', array(null, $_record->adr_one_street2, $_record->adr_one_street, $_record->adr_one_locality, $_record->adr_one_region, $_record->adr_one_postalcode, $_record->adr_one_countryname), array('TYPE' => 'WORK'));
$card->add('ADR', array(null, $_record->adr_two_street2, $_record->adr_two_street, $_record->adr_two_locality, $_record->adr_two_region, $_record->adr_two_postalcode, $_record->adr_two_countryname), array('TYPE' => 'HOME'));
$card->add('EMAIL', $_record->email, array('TYPE' => 'PREF'));
$card->add('EMAIL', $_record->email_home);
$card->add('URL', $_record->url, array('TYPE' => 'WORK'));
$card->add('URL', $_record->url_home, array('TYPE' => 'HOME'));
$card->add('NOTE', $_record->note);
$this->_fromTine20ModelAddBirthday($_record, $card);
$this->_fromTine20ModelAddPhoto($_record, $card);
$this->_fromTine20ModelAddGeoData($_record, $card);
$this->_fromTine20ModelAddCategories($_record, $card);
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' card ' . $card->serialize());
}
return $card;
}
示例4: _recordToRawData
/**
* converts record into raw data for adapter
*
* @param Tinebase_Record_Abstract $_record
* @return array
*/
protected function _recordToRawData($_record)
{
if (is_object($_record->filters)) {
$_record->filters->removeId();
}
$rawData = $_record->toArray();
$rawData['filters'] = Zend_Json::encode($rawData['filters']);
return $rawData;
}
示例5: fromTine20Model
/**
* converts Tinebase_Record_Abstract to external format
*
* @param Tinebase_Record_Abstract $_record
* @return mixed
*/
public function fromTine20Model(Tinebase_Record_Abstract $_record)
{
if (!$_record) {
return array();
}
$_record->setTimezone(Tinebase_Core::get(Tinebase_Core::USERTIMEZONE));
$_record->bypassFilters = true;
Tinebase_Model_Container::resolveContainerOfRecord($_record);
return $_record->toArray();
}
示例6: appendDependentRecords
/**
* Append contacts by foreign key (record embedding)
*
* @param Tinebase_Record_Abstract $record
* @return void
*/
protected function appendDependentRecords($record)
{
if ($record->__get('batch_dta_id')) {
$this->appendForeignRecordToRecord($record, 'batch_dta_id', 'batch_dta_id', 'id', new Billing_Backend_BatchJobDta());
}
if ($record->__get('open_item_id')) {
$this->appendForeignRecordToRecord($record, 'open_item_id', 'open_item_id', 'id', new Billing_Backend_OpenItem());
}
if ($record->__get('payment_id')) {
$this->appendForeignRecordToRecord($record, 'payment_id', 'payment_id', 'id', new Billing_Backend_Payment());
}
}
示例7: __construct
public function __construct(array $_values = array())
{
$this->_id = Tinebase_Record_Abstract::generateUID();
foreach ($_values as $key => $value) {
$this->{$key} = $value;
}
}
示例8: appendFilterSql
/**
* appends sql to given select statement
*
* @param Zend_Db_Select $_select
* @param Tinebase_Backend_Sql_Abstract $_backend
* @throws Tinebase_Exception_UnexpectedValue
*/
public function appendFilterSql($_select, $_backend)
{
// don't take empty filter into account
if (empty($this->_value) || !is_array($this->_value) || !isset($this->_value['cfId']) || empty($this->_value['cfId']) || !isset($this->_value['value'])) {
return;
} else {
if ($this->_operator == 'in') {
throw new Tinebase_Exception_UnexpectedValue('Operator "in" not supported.');
}
}
// make sure $correlationName is a string
$correlationName = Tinebase_Record_Abstract::generateUID() . $this->_value['cfId'] . 'cf';
if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Adding custom field filter: ' . print_r($this->_value, true));
}
$db = Tinebase_Core::getDb();
$idProperty = $db->quoteIdentifier($this->_options['idProperty']);
// per left join we add a customfield column named as the customfield and filter this joined column
// NOTE: we name the column we join like the customfield, to be able to join multiple customfield criteria (multiple invocations of this function)
$what = array($correlationName => SQL_TABLE_PREFIX . 'customfield');
$on = $db->quoteIdentifier("{$correlationName}.record_id") . " = {$idProperty} AND " . $db->quoteIdentifier("{$correlationName}.customfield_id") . " = " . $db->quote($this->_value['cfId']);
$_select->joinLeft($what, $on, array());
$valueIdentifier = $db->quoteIdentifier("{$correlationName}.value");
if ($this->_value['value'] === '') {
$where = $db->quoteInto($valueIdentifier . ' IS NULL OR ' . $valueIdentifier . ' = ?', $this->_value['value']);
} else {
$value = $this->_replaceWildcards($this->_value['value']);
$where = $db->quoteInto($valueIdentifier . $this->_opSqlMap[$this->_operator]['sqlop'], $value);
}
$_select->where($where . ' /* add cf filter */');
}
示例9: __construct
/**
* overwritten parent constructor to load configuration, calls parent constructor
*
* supported configuration keys:
* logruntime => prepend time passed since request started
* logdifftime => prepend time passed since last log message
*
* @param string $format
*/
function __construct(string $format = null)
{
parent::__construct($format);
if (!self::$_prefix) {
self::$_prefix = Tinebase_Record_Abstract::generateUID(5);
}
if (self::$_starttime === NULL) {
self::$_starttime = Tinebase_Core::get(Tinebase_Core::STARTTIME);
if (self::$_starttime === NULL) {
self::$_starttime = microtime(true);
}
}
if (self::$_logruntime === NULL || self::$_logdifftime === NULL) {
$config = Tinebase_Core::getConfig();
if ($config->logger->logruntime) {
self::$_logruntime = true;
} else {
self::$_logruntime = false;
}
if ($config->logger->logdifftime) {
self::$_logdifftime = true;
} else {
self::$_logdifftime = false;
}
}
}
示例10: setUp
/**
* set up tests
*
*/
protected function setUp()
{
parent::setUp();
$this->_instance = Tinebase_Notes::getInstance();
$this->_objects['contact'] = new Addressbook_Model_Contact(array('id' => Tinebase_Record_Abstract::generateUID(), 'n_family' => 'phpunit notes contact'));
$this->_objects['record'] = array('id' => $this->_objects['contact']->getId(), 'model' => 'Addressbook_Model_Contact', 'backend' => 'Sql');
}
示例11: testTimeaccountContractFilter
/**
* test timeaccount - sales contract filter
* also tests Tinebase_Model_Filter_ExplicitRelatedRecord
*/
public function testTimeaccountContractFilter()
{
$this->_getTimeaccount(array('title' => 'TA1', 'number' => 12345, 'description' => 'UnitTest'), true);
$ta1 = $this->_timeaccountController->get($this->_lastCreatedRecord['id']);
$this->_getTimeaccount(array('title' => 'TA2', 'number' => 12346, 'description' => 'UnitTest'), true);
$ta2 = $this->_timeaccountController->get($this->_lastCreatedRecord['id']);
$cId = Tinebase_Container::getInstance()->getDefaultContainer('Sales_Model_Contract')->getId();
$contract = Sales_Controller_Contract::getInstance()->create(new Sales_Model_Contract(array('title' => 'testRelateTimeaccount', 'number' => Tinebase_Record_Abstract::generateUID(), 'container_id' => $cId)));
$ta1->relations = array($this->_getRelation($contract, $ta1));
$this->_timeaccountController->update($ta1);
// search by contract
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'contract', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'equals', 'value' => $contract->getId())))));
$filterArray = $f->toArray();
$this->assertEquals($contract->getId(), $filterArray[0]['value'][0]['value']['id']);
$result = $this->_timeaccountController->search($f);
$this->assertEquals(1, $result->count());
$this->assertEquals('TA1', $result->getFirstRecord()->title);
// test empty filter (without contract)
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'contract', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'equals', 'value' => null))), array('field' => 'description', 'operator' => 'equals', 'value' => 'UnitTest')));
$result = $this->_timeaccountController->search($f);
$this->assertEquals(1, $result->count(), 'Only one record should have been found!');
$this->assertEquals('TA2', $result->getFirstRecord()->title);
// test generic relation filter
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'foreignRecord', 'operator' => 'AND', 'value' => array('appName' => 'Sales', 'linkType' => 'relation', 'modelName' => 'Contract', 'filters' => array('field' => 'query', 'operator' => 'contains', 'value' => 'TA1')))));
$result = $this->_timeaccountController->search($f);
$this->assertEquals(1, $result->count());
$this->assertEquals('TA1', $result->getFirstRecord()->title);
// test "not" operator
$f = new Timetracker_Model_TimeaccountFilter(array(array('field' => 'contract', 'operator' => 'AND', 'value' => array(array('field' => ':id', 'operator' => 'not', 'value' => $contract->getId()))), array('field' => 'description', 'operator' => 'equals', 'value' => 'UnitTest')));
$result = $this->_timeaccountController->search($f);
// TODO is this correct? do we expect the timaccount without contract to be missing from results?
$this->assertEquals(0, $result->count(), 'No record should be found');
}
示例12: setUp
/**
* Sets up the fixture.
*
* This method is called before a test is executed.
*/
protected function setUp()
{
Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
// we need that because the voip db tables can have a different prefix
Tinebase_Core::set('voipdbTablePrefix', SQL_TABLE_PREFIX);
$phoneId = Tinebase_Record_Abstract::generateUID();
$this->_objects['location'] = new Voipmanager_Model_Snom_Location(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => 'phpunit test location', 'registrar' => 'registrar'));
$this->_objects['software'] = new Voipmanager_Model_Snom_Software(array('id' => Tinebase_Record_Abstract::generateUID()));
$this->_objects['setting'] = new Voipmanager_Model_Snom_Setting(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => Tinebase_Record_Abstract::generateUID(), 'description' => Tinebase_Record_Abstract::generateUID(), 'language_w' => true));
$this->_objects['phonesettings'] = new Voipmanager_Model_Snom_PhoneSettings(array('phone_id' => $phoneId, 'language' => 'Deutsch'));
$this->_objects['template'] = new Voipmanager_Model_Snom_Template(array('id' => Tinebase_Record_Abstract::generateUID(), 'name' => 'phpunit test location', 'software_id' => $this->_objects['software']->getId(), 'setting_id' => $this->_objects['setting']->getId()));
$this->_objects['phone'] = new Voipmanager_Model_Snom_Phone(array('id' => $phoneId, 'macaddress' => "1234567890cd", 'location_id' => $this->_objects['location']->getId(), 'template_id' => $this->_objects['template']->getId(), 'current_model' => 'snom320', 'redirect_event' => 'none'));
$this->_objects['phoneOwner'] = array('account_id' => Zend_Registry::get('currentAccount')->getId(), 'account_type' => 'user');
$rights = new Tinebase_Record_RecordSet('Voipmanager_Model_Snom_PhoneRight', array($this->_objects['phoneOwner']));
$this->_objects['phone']->rights = $rights;
// create phone, location, template
$snomLocationBackend = new Voipmanager_Backend_Snom_Location();
$snomTemplateBackend = new Voipmanager_Backend_Snom_Template();
$snomSoftwareBackend = new Voipmanager_Backend_Snom_Software();
$snomPhoneBackend = new Voipmanager_Backend_Snom_Phone();
$snomSettingBackend = new Voipmanager_Backend_Snom_Setting();
$snomPhoneSettingsBackend = new Voipmanager_Backend_Snom_PhoneSettings();
$snomSoftwareBackend->create($this->_objects['software']);
$snomLocationBackend->create($this->_objects['location']);
$snomTemplateBackend->create($this->_objects['template']);
$snomSettingBackend->create($this->_objects['setting']);
$snomPhoneBackend->create($this->_objects['phone']);
$snomPhoneSettingsBackend->create($this->_objects['phonesettings']);
}
示例13: _doConversions
/**
* do conversions
*
* @param array $_data
* @return array
*/
protected function _doConversions($_data)
{
$result = parent::_doConversions($_data);
if ((isset($result['warranty']) || array_key_exists('warranty', $result)) && empty($_data['warranty'])) {
unset($result['warranty']);
}
if ((isset($result['invoice_date']) || array_key_exists('invoice_date', $result)) && empty($_data['invoice_date'])) {
unset($result['invoice_date']);
}
if ((isset($result["name"]) || array_key_exists("name", $result)) && $result['name'] == "") {
$result['name'] = "!Not defined!";
}
if ((isset($result["inventory_id"]) || array_key_exists("inventory_id", $result)) && $result['inventory_id'] == "") {
$result['inventory_id'] = Tinebase_Record_Abstract::generateUID(40);
}
if (isset($result["costcentre"]) || array_key_exists("costcentre", $result)) {
$result["costcentre"] = $c = Sales_Controller_CostCenter::getInstance()->search(new Sales_Model_CostCenterFilter(array(array('field' => 'number', 'operator' => 'equals', 'value' => $result["costcentre"]))))->getFirstRecord();
}
if (isset($result["status"]) || array_key_exists("status", $result)) {
$statusRecord = Inventory_Config::getInstance()->get(Inventory_Config::INVENTORY_STATUS)->getKeyfieldRecordByValue($result["status"]);
if (empty($statusRecord)) {
$statusRecord = Inventory_Config::getInstance()->get(Inventory_Config::INVENTORY_STATUS)->getKeyfieldDefault();
}
$result["status"] = $statusRecord['id'];
}
return $result;
}
示例14: testToArrayJsonNonExisting
public function testToArrayJsonNonExisting()
{
$nonExistingId = Tinebase_Record_Abstract::generateUID();
$filter = new Addressbook_Model_ContactIdFilter('id', 'equals', $nonExistingId);
$filterArray = $filter->toArray(TRUE);
$this->assertEquals($nonExistingId, $filterArray['value']);
}
示例15: setFromArray
/**
* convert remark to array if json encoded
*
* @see Tinebase_Record_Abstract::setFromArray
*
* @param array $_data the new data to set
*
* @todo always json::encode remarks? / add options field that is always json encoded
*/
public function setFromArray(array $_data)
{
parent::setFromArray($_data);
if ($this->remark && is_string($this->remark) && strpos($this->remark, '{') === 0) {
$this->remark = Zend_Json::decode($this->remark);
}
}