Exemplo n.º 1
0
 /**
  * 
  * 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();
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
Exemplo n.º 5
0
 /**
  * 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();
 }
Exemplo n.º 6
0
 /**
  * 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());
     }
 }
Exemplo n.º 7
0
 /**
  * resolve tag ids to tag record
  * 
  * @todo find a generic solution for this!
  */
 protected function _resolveClientRecordTags()
 {
     if (!$this->_clientRecord->has('tags') || empty($this->_clientRecord->tags)) {
         return;
     }
     $tags = new Tinebase_Record_RecordSet('Tinebase_Model_Tag');
     foreach ($this->_clientRecord->tags as $tag) {
         if (is_string($tag)) {
             $tag = Tinebase_Tags::getInstance()->get($tag);
         }
         $tags->addRecord($tag);
     }
     $this->_clientRecord->tags = $tags;
 }
 public function __construct(array $_values = array())
 {
     $this->_id = Tinebase_Record_Abstract::generateUID();
     foreach ($_values as $key => $value) {
         $this->{$key} = $value;
     }
 }
Exemplo n.º 9
0
 /**
  * overwrite constructor to add more filters
  *
  * @param mixed $_data
  * @param bool $_bypassFilters
  * @param mixed $_convertDates
  * @return void
  */
 public function __construct($_data = NULL, $_bypassFilters = false, $_convertDates = true)
 {
     // set default value if field is empty
     $this->_filters['nat'] = new Zend_Filter_Empty('no');
     $this->_filters['cfd_time'] = new Zend_Filter_Empty(0);
     parent::__construct($_data, $_bypassFilters, $_convertDates);
 }
Exemplo n.º 10
0
 /**
  * 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 */');
 }
 /**
  * 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;
         }
     }
 }
Exemplo n.º 12
0
 public function setFromArray(array $_data)
 {
     if (empty($_data['job_id']) || $_data['job_id'] == "") {
         unset($_data['job_id']);
     }
     parent::setFromArray($_data);
 }
 /**
  * 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');
 }
 /**
  * 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');
 }
 /**
  * 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']);
 }
 /**
  * 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;
 }
 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']);
 }
 /**
  * (non-PHPdoc)
  * @see tine20/Tinebase/Record/Abstract::setFromArray()
  */
 public function setFromArray(array $_data)
 {
     if (isset($_data['records']) && is_array($_data['records'])) {
         $_data['records'] = new Tinebase_Record_RecordSet($this->_keyFieldRecordModel, $_data['records'], TRUE);
     }
     parent::setFromArray($_data);
 }
Exemplo n.º 19
0
 /**
  * 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);
     }
 }
Exemplo n.º 20
0
 public function setFromArray(array $_data)
 {
     if (empty($_data['termination_date']) || $_data['termination_date'] == "") {
         unset($_data['termination_date']);
     }
     parent::setFromArray($_data);
 }
 /**
  * appends sql to given select statement
  *
  * @param  Zend_Db_Select                    $_select
  * @param  Tinebase_Backend_Sql_Abstract     $_backend
  */
 public function appendFilterSql($_select, $_backend)
 {
     $correlationName = Tinebase_Record_Abstract::generateUID(30);
     $db = $_backend->getAdapter();
     $_select->joinLeft(array($correlationName => $db->table_prefix . 'adb_list_m_role'), $db->quoteIdentifier($correlationName . '.contact_id') . ' = ' . $db->quoteIdentifier('addressbook.id'), array());
     $_select->where($db->quoteIdentifier($correlationName . '.list_role_id') . ' IN (?)', (array) $this->_value);
 }
Exemplo n.º 22
0
 /**
  * overwrite constructor to add more filters
  *
  * @param mixed $_data
  * @param bool $_bypassFilters
  * @param mixed $_convertDates
  * @return void
  */
 public function __construct($_data = NULL, $_bypassFilters = false, $_convertDates = true)
 {
     // strip time information from datetime string
     $this->_filters['start_date'] = new Zend_Filter_PregReplace('/(\\d{4}-\\d{2}-\\d{2}).*/', '$1');
     // set start_time to NULL if not set
     $this->_filters['start_time'] = new Zend_Filter_Empty(NULL);
     return parent::__construct($_data, $_bypassFilters, $_convertDates);
 }
 /**
  * testBackslashInDescription
  *
  * @see 0009176: iCal adds another backslash to description field
  */
 public function testBackslashInDescription()
 {
     $event = new Calendar_Model_Event(array('summary' => 'CalDAV test', 'dtstart' => Tinebase_DateTime::now(), 'dtend' => Tinebase_DateTime::now()->addHour(1), 'description' => 'lalala \\\\', 'originator_tz' => 'Europe/Berlin', 'creation_time' => Tinebase_DateTime::now(), 'uid' => Tinebase_Record_Abstract::generateUID(), 'seq' => 1));
     $converter = Calendar_Convert_Event_VCalendar_Factory::factory(Calendar_Convert_Event_VCalendar_Factory::CLIENT_MACOSX);
     $vevent = $converter->fromTine20Model($event)->serialize();
     $convertedEvent = $converter->toTine20Model($vevent);
     $this->assertEquals($event->description, $convertedEvent->description);
 }
 /**
  * (non-PHPdoc)
  * @see Tinebase/Record/Tinebase_Record_Abstract#setFromArray($_data)
  */
 public function setFromArray(array $_data)
 {
     parent::setFromArray($_data);
     // always set url here (or is there a better place?)
     if ($this->getId()) {
         $this->url = $this->getDownloadUrl();
     }
 }
Exemplo n.º 25
0
 /**
  * sets record related properties
  * 
  * @param string _name of property
  * @param mixed _value of property
  * @throws Tinebase_Exception_InvalidArgument
  */
 public function __set($_name, $_value)
 {
     switch ($_name) {
         case 'application_id':
             $_value = Tinebase_Model_Application::convertApplicationIdToInt($_value);
     }
     parent::__set($_name, $_value);
 }
 /**
  * test to create a new directory
  */
 public function testCreateDirectory()
 {
     $randomName = Tinebase_Record_Abstract::generateUID();
     $collection = new Addressbook_Frontend_WebDAV(\Sabre\CardDAV\Plugin::ADDRESSBOOK_ROOT . '/' . Tinebase_Core::getUser()->contact_id, true);
     $collection->createDirectory($randomName);
     $container = Tinebase_Container::getInstance()->getContainerByName('Addressbook', $randomName, Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser());
     $this->assertTrue($container instanceof Tinebase_Model_Container);
 }
 /**
  * Test create a scheduled import
  */
 public function createScheduledImport($source = 'http://localhost/test.ics')
 {
     $id = Tinebase_Record_Abstract::generateUID();
     $import = new Tinebase_Model_Import(array('id' => $id, 'user_id' => $this->_originalTestUser->getId(), 'interval' => Tinebase_Model_Import::INTERVAL_HOURLY, 'model' => Calendar_Controller::getInstance()->getDefaultModel(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'container_id' => $this->_testCalendar->getId(), 'sourcetype' => Tinebase_Model_Import::SOURCETYPE_REMOTE, 'source' => $source, 'options' => json_encode(array('forceUpdateExisting' => TRUE, 'import_defintion' => NULL, 'plugin' => 'Calendar_Import_Ical'))));
     $record = $this->_uit->create($import);
     $this->assertEquals(Calendar_Controller::getInstance()->getDefaultModel(), $this->_uit->get($id)->model);
     return $record;
 }
 /**
  * (non-PHPdoc)
  * @see Tinebase/Record/Tinebase_Record_Abstract#setFromArray($_data)
  */
 public function setFromArray(array $_data)
 {
     parent::setFromArray($_data);
     // always set url here (or is there a better place?)
     if ($this->getId()) {
         $this->url = Tinebase_Core::getHostname() . '/download/show/' . $this->getId();
     }
 }
 /**
  * Test create a access log and logout to set logout time
  *
  * @see 0010728: Strange error in tine20 log when performing logout from Web
  */
 public function testSetLogout()
 {
     $accessLog = new Tinebase_Model_AccessLog(array('ip' => '127.0.0.1', 'li' => Tinebase_DateTime::now(), 'result' => Zend_Auth_Result::SUCCESS, 'clienttype' => 'unittest', 'login_name' => 'unittest', 'user_agent' => 'phpunit', 'sessionid' => Tinebase_Record_Abstract::generateUID()), true);
     $this->_uit->setSessionId($accessLog);
     $this->_uit->create($accessLog);
     $accessLog = $this->_uit->setLogout();
     $this->assertEquals(Tinebase_DateTime::now()->toString(), $accessLog->lo->toString(), 'logout time mismatch/empty: ' . print_r($accessLog, true));
 }
 /**
  * sets the record related properties from user generated input.
  * 
  * Input-filtering and validation by Zend_Filter_Input can enabled and disabled
  *
  * @param array $_data            the new data to set
  */
 public function setFromArray(array $_data)
 {
     foreach (array('emailForwards', 'emailAliases') as $arrayField) {
         if (isset($_data[$arrayField]) && !is_array($_data[$arrayField])) {
             $_data[$arrayField] = explode(',', preg_replace('/ /', '', $_data[$arrayField]));
         }
     }
     parent::setFromArray($_data);
 }