Beispiel #1
0
 /**
  * the singleton pattern
  *
  * @return Tinebase_Container
  */
 public static function getInstance()
 {
     if (self::$_instance === NULL) {
         self::$_instance = new Tinebase_Container();
     }
     return self::$_instance;
 }
 /**
  * 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');
 }
 /**
  * tear down tests
  */
 protected function tearDown()
 {
     parent::tearDown();
     if ($this->_testContainer) {
         Tinebase_Container::getInstance()->deleteContainer($this->_testContainer);
     }
 }
Beispiel #4
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $GLOBALS['Addressbook_Backend_SqlTest'] = array_key_exists('Addressbook_Backend_SqlTest', $GLOBALS) ? $GLOBALS['Addressbook_Backend_SqlTest'] : array();
     $this->_backend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
     $personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Addressbook', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
     $container = $personalContainer[0];
     $this->objects['initialContact'] = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'jpegphoto' => file_get_contents(dirname(__FILE__) . '/../../Tinebase/ImageHelper/phpunit-logo.gif'), 'note' => 'Bla Bla Bla', 'container_id' => $container->id, 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars', 'n_given' => 'Lars', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
     $this->objects['updatedContact'] = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'note' => 'Bla Bla Bla', 'container_id' => $container->id, 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars', 'n_given' => 'Lars', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
     return;
     $this->expectFailure['TestRecord']['testSetId'][] = array('2', '3');
     $this->expectFailure['TestRecord']['testSetId'][] = array('30000000', '3000000000000000000000000000');
     $this->expectSuccess['TestRecord']['testSetId'][] = array('2', '2');
     $this->expectFailure['TestRecordBypassFilters']['testSetIdBypassFilters'][] = array('2', '3');
     $this->expectFailure['TestRecordBypassFilters']['testSetIdBypassFilters'][] = array('30000000', '3000000000000000000000000000');
     $this->expectSuccess['TestRecordBypassFilters']['testSetIdBypassFilters'][] = array('2', '2');
     $this->expectSuccess['TestRecord']['testSetFromArray'][] = array(array('test_1' => '2', 'test_2' => NULL), 'test_1');
     $this->expectFailure['TestRecord']['testSetFromArrayException'][] = array('Tinebase_Exception_Record_Validation', array('test_2' => 'string'));
     $this->expectFailure['TestRecord']['testSetTimezoneException'][] = array('Exception', 'UTC');
     $dummy = array('test_id' => 2, 'test_2' => '', 'date_single' => $date->get(Tinebase_Record_Abstract::ISO8601LONG), 'date_multiple' => '');
     $this->expectSuccess['TestRecord']['testToArray'][] = array($dummy);
     $this->expectSuccess['TestRecord']['__set'][] = array('test_3', 4);
     $this->expectSuccess['TestRecord']['__get'][] = array('test_3', 4);
     $this->expectSuccess['TestRecord']['test__isset'][] = array('test_id');
     $this->expectFailure['TestRecord']['test__isset'][] = array('string');
     $this->expectFailure['TestRecord']['test__setException'][] = array('UnexpectedValueException', 'test_100');
     $this->expectFailure['TestRecord']['test__getException'][] = array('UnexpectedValueException', 'test_100');
     $this->expectFailure['TestRecord']['testOffsetUnset'][] = array('Tinebase_Exception_Record_NotAllowed', 'test_2');
 }
 /**
  * inits (adds) some test users
  *
  */
 public function initTestUsers()
 {
     $personas = array('jsmith' => 'John Smith', 'sclever' => 'Susan Clever', 'pwulf' => 'Paul Wulf', 'jmcblack' => 'James McBlack', 'rwright' => 'Roberta Wright');
     foreach ($personas as $login => $fullName) {
         try {
             $user = Tinebase_User::getInstance()->getFullUserByLoginName($login);
         } catch (Tinebase_Exception_NotFound $e) {
             list($given, $last) = explode(' ', $fullName);
             $group = Tinebase_Group::getInstance()->getGroupByName('Users');
             $groupId = $group->getId();
             $user = new Tinebase_Model_FullUser(array('accountLoginName' => $login, 'accountPrimaryGroup' => $groupId, 'accountDisplayName' => $fullName, 'accountLastName' => $last, 'accountFirstName' => $given, 'accountFullName' => $fullName, 'accountEmailAddress' => $login . '@tine20.org'));
             if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
                 $internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
                 $user->container_id = $internalAddressbook->getId();
                 $contact = Admin_Controller_User::getInstance()->createOrUpdateContact($user);
                 $user->contact_id = $contact->getId();
             }
             $user = Tinebase_User::getInstance()->addUser($user);
             Tinebase_Group::getInstance()->addGroupMember($groupId, $user);
             if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
                 $listBackend = new Addressbook_Backend_List();
                 $listBackend->addListMember($group->list_id, $user->contact_id);
             }
             // give additional testusers the same password as the primary test account
             Tinebase_User::getInstance()->setPassword($user, Zend_Registry::get('testConfig')->password);
         }
         $personas[$login] = $user;
     }
     Zend_Registry::set('personas', $personas);
 }
 /**
  * repair groups
  * 
  * * add missing lists
  * * checks if list container has been deleted (and hides groups if that's the case)
  * 
  * @see 0010401: add repair script for groups without list_ids
  */
 public function repairGroups()
 {
     $count = 0;
     $be = new Tinebase_Group_Sql();
     $listBackend = new Addressbook_Backend_List();
     $groups = $be->getGroups();
     foreach ($groups as $group) {
         if ($group->list_id == null) {
             $list = Addressbook_Controller_List::getInstance()->createByGroup($group);
             $group->list_id = $list->getId();
             $group->visibility = Tinebase_Model_Group::VISIBILITY_DISPLAYED;
             if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                 Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Add missing list for group ' . $group->name);
             }
             $be->updateGroupInSqlBackend($group);
             $count++;
         } else {
             if ($group->visibility === Tinebase_Model_Group::VISIBILITY_DISPLAYED) {
                 try {
                     $list = $listBackend->get($group->list_id);
                     $listContainer = Tinebase_Container::getInstance()->get($list->container_id);
                 } catch (Tinebase_Exception_NotFound $tenf) {
                     if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
                         Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Hide group ' . $group->name . ' without list / list container.');
                     }
                     $group->visibility = Tinebase_Model_Group::VISIBILITY_HIDDEN;
                     $be->updateGroupInSqlBackend($group);
                     $count++;
                 }
             }
         }
     }
     echo $count . " groups repaired!\n";
 }
 public function setCalendarProperties(Tinebase_Model_Container $calendarContainer, array $calendar)
 {
     if (isset($calendar['color']) && $calendarContainer->color !== $calendar['color']) {
         $calendarContainer->color = $calendar['color'];
         Tinebase_Container::getInstance()->update($calendarContainer);
     }
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $this->_backend = Addressbook_Backend_Factory::factory(Addressbook_Backend_Factory::SQL);
     $personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Addressbook', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
     $this->_container = $personalContainer[0];
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $_SERVER['HTTP_USER_AGENT'] = 'FooBar User Agent';
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(FALSE);
     $this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId())));
 }
 /**
  * try to add a faq record
  * 
  * @return array
  */
 public function testAddFaq()
 {
     $faq = new SimpleFAQ_Model_Faq(array('answer' => 'was geht?', 'question' => 'einiges', 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('SimpleFAQ_Model_Faq')->getId()));
     $result = $this->_instance->saveFaq($faq->toArray());
     $this->assertEquals($faq->question, $result['question']);
     return $result;
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId())));
     Tinebase_Container::getInstance()->addGrants($this->objects['initialContainer'], Tinebase_Acl_Rights::ACCOUNT_TYPE_GROUP, Tinebase_Core::getUser()->accountPrimaryGroup, array(Tinebase_Model_Grants::GRANT_READ));
     // must be defined for Calendar/Frontend/WebDAV/Event.php
     $_SERVER['REQUEST_URI'] = 'foobar';
 }
 /**
  * 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);
 }
 /**
  * converts Tinebase_Record_Abstract to external format
  *
  * @param  Tinebase_Record_Abstract $_record
  * @return mixed
  */
 public function fromTine20Model(Tinebase_Record_Abstract $_record)
 {
     $jsonData = parent::fromTine20Model($_record);
     if (Tinebase_Core::getUser()->hasRight('Calendar', Calendar_Acl_Rights::MANAGE_RESOURCES)) {
         $jsonData['grants'] = Tinebase_Container::getInstance()->getGrantsOfContainer($_record->container_id, TRUE)->toArray();
         $jsonData['grants'] = Tinebase_Frontend_Json_Container::resolveAccounts($jsonData['grants']);
     }
     return $jsonData;
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  */
 public function setUp()
 {
     parent::setUp();
     $this->objects['initialContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId())));
     $this->objects['sharedContainer'] = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => Tinebase_Record_Abstract::generateUID(), 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId())));
     $prefs = new Tasks_Preference();
     $prefs->setValue(Tasks_Preference::DEFAULTTASKLIST, $this->objects['initialContainer']->getId());
     $_SERVER['REQUEST_URI'] = 'lars';
 }
 /**
  * creates the initial folder for new accounts
  *
  * @param mixed[int|Tinebase_Model_User] $_account   the accountd object
  * @return Tinebase_Record_RecordSet                            of subtype Tinebase_Model_Container
  */
 public function createPersonalFolder($_accountId)
 {
     $translation = Tinebase_Translation::getTranslation('ExampleApplication');
     $account = Tinebase_User::getInstance()->getUserById($_accountId);
     $newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal example records"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => $_accountId, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId()));
     $personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer);
     $container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
     return $container;
 }
 /**
  * creates the initial folder for new accounts
  *
  * @param mixed[int|Tinebase_Model_User] $_account   the accountd object
  * @return Tinebase_Record_RecordSet                            of subtype Tinebase_Model_Container
  */
 public function createPersonalFolder($_account)
 {
     $translation = Tinebase_Translation::getTranslation($this->_applicationName);
     $account = Tinebase_User::getInstance()->getUserById($_account);
     $newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal Projects"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => $account->getId(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId(), 'model' => static::$_defaultModel));
     $personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer);
     $container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
     return $container;
 }
 /**
  * resolve some config settings
  * 
  * @param array $_settings
  */
 protected function _resolveConfigSettings($_settings)
 {
     foreach ($_settings as $key => $value) {
         if ($key === Admin_Model_Config::DEFAULTINTERNALADDRESSBOOK && $value) {
             $_settings[$key] = Tinebase_Container::getInstance()->get($value)->toArray();
         }
     }
     return $_settings;
 }
 /**
  * test simple import from file into a not existing container
  * 
  *  - the calendar should be created
  */
 public function testSimpleImportIntoNewContainer()
 {
     $importer = new Calendar_Import_Ical(array('container_id' => 'unittest_not_existing'));
     $result = $importer->importFile(dirname(__FILE__) . '/files/simple.ics');
     $importedContainerId = Tinebase_Container::getInstance()->getContainerByName('Calendar', 'unittest_not_existing', Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser()->getId())->getId();
     $events = Calendar_Controller_Event::getInstance()->search(new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $importedContainerId))), NULL);
     $this->assertEquals($importedContainerId, Tinebase_Container::getInstance()->getContainerById($importedContainerId)->getId());
     $this->assertEquals(6, $events->count(), 'events was not imported');
 }
 /**
  * append grants acl filter
  * 
  * @param Zend_Db_Select $select
  * @param Tinebase_Backend_Sql_Abstract $backend
  * @param Tinebase_Model_User $user
  */
 protected function _appendGrantsFilter($select, $backend, $user)
 {
     $db = $backend->getAdapter();
     $select->join(array($this->_aclTableName => SQL_TABLE_PREFIX . $this->_aclTableName), "{$db->quoteIdentifier($this->_aclTableName . '.record_id')} = {$db->quoteIdentifier($backend->getTableName() . '.id')}", array());
     Tinebase_Container::addGrantsSql($select, $user, $this->_requiredGrants, $this->_aclTableName);
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' $select after appending grants sql: ' . $select);
     }
 }
 /**
  * test import duplicate data
  *
  * @return array
  */
 public function testImportDuplicates()
 {
     $internalContainer = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED);
     $options = array('container_id' => $internalContainer->getId());
     $result = $this->_doImport($options, 'adb_tine_import_csv', new Addressbook_Model_ContactFilter(array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $internalContainer->getId()))));
     $this->assertGreaterThan(0, $result['duplicatecount'], 'no duplicates.');
     $this->assertTrue($result['exceptions'] instanceof Tinebase_Record_RecordSet);
     return $result;
 }
 /**
  * 
  * @return array
  */
 protected function _createSupplier()
 {
     $container = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser()->getId(), 'Addressbook_Model_Contact', 'WRITE');
     $containerContracts = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser()->getId(), 'Sales_Model_Contract', 'WRITE');
     $container = $container->getFirstRecord();
     $contact1 = $this->_contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Yiting', 'n_family' => 'Huang', 'container_id' => $container->getId())));
     $contact2 = $this->_contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Hans Friedrich', 'n_family' => 'Ochs', 'container_id' => $container->getId())));
     $customerData = array('name' => 'Worldwide Electronics International', 'cpextern_id' => $contact1->getId(), 'cpintern_id' => $contact2->getId(), 'number' => 4294967, 'iban' => 'CN09234098324098234598', 'bic' => '0239580429570923432444', 'url' => 'http://wwei.cn', 'vatid' => '239rc9mwqe9c2q', 'credit_term' => '30', 'currency' => 'EUR', 'curreny_trans_rate' => 7.034, 'discount' => 12.5, 'adr_prefix1' => 'no prefix 1', 'adr_prefix2' => 'no prefix 2', 'adr_street' => 'Mao st. 2000', 'adr_postalcode' => '1', 'adr_locality' => 'Shanghai', 'adr_region' => 'Shanghai', 'adr_countryname' => 'China', 'adr_pobox' => '7777777');
     return $this->_json->saveSupplier($customerData);
 }
Beispiel #22
0
 /**
  * test to set container grants with filter and overwrite old grants
  */
 public function testSetContainerGrantsWithFilterAndOverwrite()
 {
     $nameFilter = 'Tine 2.0 Admin Account';
     $filter = new Tinebase_Model_ContainerFilter(array(array('field' => 'application_id', 'operator' => 'equals', 'value' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId()), array('field' => 'name', 'operator' => 'contains', 'value' => $nameFilter)));
     $count = Tinebase_Container::getInstance()->searchCount($filter);
     $out = $this->_cliHelper(array('namefilter="' . $nameFilter . '"', 'accountId=' . Tinebase_Core::getUser()->getId(), 'grants=privateGrant,adminGrant', 'overwrite=1'), $count);
     $grants = Tinebase_Container::getInstance()->getGrantsOfContainer($this->_container);
     $this->assertTrue($grants->getFirstRecord()->privateGrant == 1);
     $this->assertTrue($grants->getFirstRecord()->adminGrant == 1);
 }
 /**
  * testGetFileList
  */
 public function testGetFileList()
 {
     $downloadLink = $this->testCreateDownloadLink();
     $basePath = '/' . Tinebase_Model_Container::TYPE_PERSONAL . '/' . Tinebase_Core::getUser()->accountLoginName . '/' . Tinebase_Container::getInstance()->getDefaultContainer('Filemanager_Model_Node')->name;
     $directories = array($basePath . '/one', $basePath . '/two');
     Filemanager_Controller_Node::getInstance()->createNodes($directories, Tinebase_Model_Tree_Node::TYPE_FOLDER);
     $fileList = $this->_getUit()->getFileList($downloadLink, array());
     $this->assertGreaterThan(1, count($fileList));
     $this->assertNotNull($fileList->filter('name', 'one')->getFirstRecord());
 }
 /**
  * creates the initial folder for new accounts
  *
  * @param mixed[int|Tinebase_Model_User] $_account   the accountd object
  * @return Tinebase_Record_RecordSet                            of subtype Tinebase_Model_Container
  */
 public function createPersonalFolder($_accountId)
 {
     $translation = Tinebase_Translation::getTranslation('Projects');
     $accountId = Tinebase_Model_User::convertUserIdToInt($_accountId);
     $account = Tinebase_User::getInstance()->getUserById($accountId);
     $newContainer = new Tinebase_Model_Container(array('name' => sprintf($translation->_("%s's personal Projects"), $account->accountFullName), 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Projects')->getId()));
     $personalContainer = Tinebase_Container::getInstance()->addContainer($newContainer, NULL, FALSE, $accountId);
     $container = new Tinebase_Record_RecordSet('Tinebase_Model_Container', array($personalContainer));
     return $container;
 }
 /**
  * update from 6.0 to 6.1
  *
  * @return void
  */
 public function update_0()
 {
     $app = Tinebase_Application::getInstance()->getApplicationByName('Filemanager');
     $filter = new Tinebase_Model_ContainerFilter(array(array('field' => 'application_id', 'operator' => 'equals', 'value' => $app->getId())), 'AND');
     $results = Tinebase_Container::getInstance()->search($filter);
     foreach ($results as $container) {
         $container->model = 'Filemanager_Model_Node';
         Tinebase_Container::getInstance()->update($container);
     }
     $this->setApplicationVersion('Filemanager', '6.1');
 }
 /**
  * Sets up the fixture.
  * 
  * This method is called before a test is executed.
  */
 protected function setUp()
 {
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $this->_backend = new Crm_Backend_Lead();
     $personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Crm', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
     if ($personalContainer->count() === 0) {
         $this->_testContainer = Tinebase_Container::getInstance()->addPersonalContainer(Zend_Registry::get('currentAccount')->accountId, 'Crm', 'PHPUNIT');
     } else {
         $this->_testContainer = $personalContainer[0];
     }
 }
 /**
  *
  * @return array
  */
 protected function _createPurchaseInvoice()
 {
     $container = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser()->getId(), 'Addressbook_Model_Contact', 'WRITE');
     $containerContracts = Tinebase_Container::getInstance()->getSharedContainer(Tinebase_Core::getUser()->getId(), 'Sales_Model_Contract', 'WRITE');
     $container = $container->getFirstRecord();
     $contact1 = $this->_contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Yiting', 'n_family' => 'Huang', 'container_id' => $container->getId())));
     $contact2 = $this->_contactController->create(new Addressbook_Model_Contact(array('n_given' => 'Hans Friedrich', 'n_family' => 'Ochs', 'container_id' => $container->getId())));
     $customerData = array('name' => 'Worldwide Electronics International', 'cpextern_id' => $contact1->getId(), 'cpintern_id' => $contact2->getId(), 'number' => 54321, 'iban' => 'CN09234098324098234598', 'bic' => '0239580429570923432444', 'url' => 'http://wwei.cn', 'vatid' => '239rc9mwqe9c2q', 'credit_term' => '30', 'currency' => 'EUR', 'curreny_trans_rate' => 7.034, 'discount' => 12.5, 'adr_prefix1' => 'no prefix 1', 'adr_prefix2' => 'no prefix 2', 'adr_street' => 'Mao st. 2000', 'adr_postalcode' => '1', 'adr_locality' => 'Shanghai', 'adr_region' => 'Shanghai', 'adr_countryname' => 'China', 'adr_pobox' => '7777777');
     $purchaseData = array('number' => 'R-12345', 'description' => 'test', 'discount' => 0, 'due_in' => 10, 'date' => '2015-03-17 00:00:00', 'due_at' => '2015-03-27 00:00:00', 'price_net' => 10, 'sales_tax' => 19, 'price_tax' => 1.9, 'price_gross' => 11.9, 'price_gross2' => 1, 'price_total' => 12.9, 'relations' => array(array('own_model' => 'Sales_Model_PurchaseInvoice', 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'related_model' => 'Sales_Model_Supplier', 'related_record' => $customerData, 'type' => 'SUPPLIER')));
     return $this->_json->savePurchaseInvoice($purchaseData);
 }
 /**
  * create vacation templates folder
  */
 public static function createVacationTemplatesFolder()
 {
     $templateContainer = Tinebase_Container::getInstance()->createSystemContainer('Expressomail', 'Vacation Templates', Expressomail_Config::VACATION_TEMPLATES_CONTAINER_ID);
     try {
         Tinebase_FileSystem::getInstance()->createContainerNode($templateContainer);
     } catch (Tinebase_Exception_Backend $teb) {
         if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) {
             Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not create vacation template folder: ' . $teb);
         }
     }
 }
 /**
  * create reporting templates folder
  */
 public static function createReportTemplatesFolder()
 {
     $templateContainer = Tinebase_Container::getInstance()->createSystemContainer('HumanResources', 'Report Templates', HumanResources_Config::REPORT_TEMPLATES_CONTAINER_ID);
     try {
         Tinebase_FileSystem::getInstance()->createContainerNode($templateContainer);
     } catch (Tinebase_Exception_Backend $teb) {
         if (Tinebase_Core::isLogLevel(Zend_Log::ERR)) {
             Tinebase_Core::getLogger()->err(__METHOD__ . '::' . __LINE__ . ' Could not create template folder: ' . $teb);
         }
     }
 }
Beispiel #30
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     $GLOBALS['Addressbook_Controller_ListTest'] = array_key_exists('Addressbook_Controller_ListTest', $GLOBALS) ? $GLOBALS['Addressbook_ListControllerTest'] : array();
     $personalContainer = Tinebase_Container::getInstance()->getPersonalContainer(Zend_Registry::get('currentAccount'), 'Addressbook', Zend_Registry::get('currentAccount'), Tinebase_Model_Grants::GRANT_EDIT);
     $container = $personalContainer[0];
     $this->objects['contact1'] = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'assistent' => 'Cornelius Weiß', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'note' => 'Bla Bla Bla', 'container_id' => $container->getId(), 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Contact1', 'n_fileas' => 'Contact1, List', 'n_given' => 'List', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
     $this->objects['contact1'] = Addressbook_Controller_Contact::getInstance()->create($this->objects['contact1'], FALSE);
     $this->objects['contact2'] = new Addressbook_Model_Contact(array('adr_one_countryname' => 'DE', 'adr_one_locality' => 'Hamburg', 'adr_one_postalcode' => '24xxx', 'adr_one_region' => 'Hamburg', 'adr_one_street' => 'Pickhuben 4', 'adr_one_street2' => 'no second street', 'adr_two_countryname' => 'DE', 'adr_two_locality' => 'Hamburg', 'adr_two_postalcode' => '24xxx', 'adr_two_region' => 'Hamburg', 'adr_two_street' => 'Pickhuben 4', 'adr_two_street2' => 'no second street2', 'assistent' => 'Cornelius Weiß', 'bday' => '1975-01-02 03:04:05', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'note' => 'Bla Bla Bla', 'container_id' => $container->getId(), 'role' => 'Role', 'title' => 'Title', 'url' => 'http://www.tine20.org', 'url_home' => 'http://www.tine20.com', 'n_family' => 'Contact2', 'n_fileas' => 'Contact2, List', 'n_given' => 'List', 'n_middle' => 'no middle name', 'n_prefix' => 'no prefix', 'n_suffix' => 'no suffix', 'org_name' => 'Metaways Infosystems GmbH', 'org_unit' => 'Tine 2.0', 'tel_assistent' => '+49TELASSISTENT', 'tel_car' => '+49TELCAR', 'tel_cell' => '+49TELCELL', 'tel_cell_private' => '+49TELCELLPRIVATE', 'tel_fax' => '+49TELFAX', 'tel_fax_home' => '+49TELFAXHOME', 'tel_home' => '+49TELHOME', 'tel_pager' => '+49TELPAGER', 'tel_work' => '+49TELWORK'));
     $this->objects['contact2'] = Addressbook_Controller_Contact::getInstance()->create($this->objects['contact2'], FALSE);
     $this->objects['initialList'] = new Addressbook_Model_List(array('name' => 'initial list', 'container_id' => $container->getId(), 'members' => array($this->objects['contact1'], $this->objects['contact2'])));
 }