コード例 #1
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())));
 }
 /**
  * test searching records by record as a customfield type
  * https://forge.tine20.org/mantisbt/view.php?id=6730
  */
 public function testSearchByRecord()
 {
     $cf = self::getCustomField(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_Contact', 'definition' => array('type' => 'record', "recordConfig" => array("value" => array("records" => "Tine.Sales.Model.Contract")))));
     $this->_instance->addCustomField($cf);
     $contract = Sales_Controller_Contract::getInstance()->create(new Sales_Model_Contract(array('number' => Tinebase_Record_Abstract::generateUID(10), 'title' => Tinebase_Record_Abstract::generateUID(10), 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('Sales_Model_Contract')->getId())));
     // contact1 with customfield record = contract
     $contact1 = new Addressbook_Model_Contact(array('n_given' => 'Rita', 'n_family' => 'Blütenrein'));
     $contact1->customfields = array($cf->name => $contract->getId());
     $contact1 = Addressbook_Controller_Contact::getInstance()->create($contact1, false);
     // contact2 with customfield record is not set -> should act like without this record
     $contact2 = new Addressbook_Model_Contact(array('n_given' => 'Rainer', 'n_family' => 'Blütenrein'));
     $contact2 = Addressbook_Controller_Contact::getInstance()->create($contact2, false);
     $json = new Addressbook_Frontend_Json();
     $result = $json->searchContacts(array(array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "equals", "value" => array("cfId" => $cf->getId(), "value" => $contract->getId()))))))), array());
     $this->assertEquals(1, $result['totalcount'], 'One Record should have been found where cf-record = contract (Rita Blütenrein)');
     $this->assertEquals('Rita', $result['results'][0]['n_given'], 'The Record should be Rita Blütenrein');
     $result = $json->searchContacts(array(array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "not", "value" => array("cfId" => $cf->getId(), "value" => $contract->getId())), array('field' => 'n_family', 'operator' => 'equals', 'value' => 'Blütenrein')))))), array());
     $this->assertEquals(1, $result['totalcount'], 'One Record should have been found where cf-record is not set (Rainer Blütenrein)');
     $this->assertEquals('Rainer', $result['results'][0]['n_given'], 'The Record should be Rainer Blütenrein');
     // search using the same cf filter in an or - filter
     $contract2 = Sales_Controller_Contract::getInstance()->create(new Sales_Model_Contract(array('number' => Tinebase_Record_Abstract::generateUID(10), 'title' => Tinebase_Record_Abstract::generateUID(10), 'container_id' => Tinebase_Container::getInstance()->getDefaultContainer('Sales_Model_Contract')->getId())));
     $contact2->customfields = array($cf->name => $contract2->getId());
     $contact2 = Addressbook_Controller_Contact::getInstance()->update($contact2, false);
     $result = $json->searchContacts(array(array("condition" => "OR", "filters" => array(array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "equals", "value" => array("cfId" => $cf->getId(), "value" => $contract->getId())))), array("condition" => "AND", "filters" => array(array("field" => "customfield", "operator" => "equals", "value" => array("cfId" => $cf->getId(), "value" => $contract2->getId()))))))), array());
     $this->assertEquals(2, $result['totalcount'], 'Rainer and Rita should have been found.');
     $this->assertEquals('Blütenrein', $result['results'][0]['n_family'], 'Rainer and Rita should have been found.');
     $this->assertEquals('Blütenrein', $result['results'][1]['n_family'], 'Rainer and Rita should have been found.');
 }
コード例 #3
0
 /**
  * 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;
 }
コード例 #4
0
 /**
  * test get application by name and id
  * 
  * @return void
  */
 public function testGetApplicationById()
 {
     $admin = Tinebase_Application::getInstance()->getApplicationByName('Admin');
     $adminById = Tinebase_Application::getInstance()->getApplicationById($admin->getId());
     $this->assertTrue($adminById instanceof Tinebase_Model_Application);
     $this->assertEquals($admin, $adminById);
 }
コード例 #5
0
 /**
  * Backend
  *
  * @var ExampleApplication_Frontend_Json
  */
 public function setUp()
 {
     // enable courses app
     Tinebase_Application::getInstance()->setApplicationState(array(Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId()), Tinebase_Application::ENABLED);
     parent::setUp();
     $this->_json = new ExampleApplication_Frontend_Json();
 }
コード例 #6
0
 /**
  * init favorites
  */
 protected function _initializeFavorites()
 {
     $pfe = new Tinebase_PersistentFilter_Backend_Sql();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('SimpleFAQ')->getId(), 'model' => 'SimpleFAQ_Model_FaqFilter');
     $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => SimpleFAQ_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All FAQs of my FAQ Lists", 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => '/personal/' . Tinebase_Model_User::CURRENTACCOUNT))))));
     $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All FAQs that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT))))));
 }
コード例 #7
0
 /**
  * init key fields
  */
 protected function _initializeKeyFields()
 {
     // create status config
     $cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
     $statusConfig = array('name' => ExampleApplication_Config::EXAMPLE_STATUS, 'records' => array(array('id' => 'COMPLETED', 'value' => 'Completed', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/ok.png', 'system' => true), array('id' => 'CANCELLED', 'value' => 'Cancelled', 'is_open' => 0, 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png', 'system' => true), array('id' => 'IN-PROCESS', 'value' => 'In process', 'is_open' => 1, 'icon' => 'images/oxygen/16x16/actions/view-refresh.png', 'system' => true)));
     $cb->create(new Tinebase_Model_Config(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('ExampleApplication')->getId(), 'name' => ExampleApplication_Config::EXAMPLE_STATUS, 'value' => json_encode($statusConfig))));
 }
コード例 #8
0
 protected function _updateLeadConfig()
 {
     // get all configs for crm from DB
     $crmApp = Tinebase_Application::getInstance()->getApplicationByName('Crm');
     // either put default to DB or delete form DB
     $cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
     $configRecords = $cb->search(new Tinebase_Model_ConfigFilter(array(array('field' => 'application_id', 'operator' => 'equals', 'value' => $crmApp->getId()))));
     $appDefaults = $configRecords->filter('name', 'appdefaults')->getFirstRecord();
     foreach (array('leadstate', 'leadtype', 'leadsource') as $oldValueName) {
         $keyFieldName = $oldValueName . 's';
         $DBconfig = $configRecords->filter('name', $keyFieldName)->getFirstRecord();
         // only update if custom config is found and if it is still in old format
         if ($DBconfig && strpos($DBconfig->value, $oldValueName) !== false) {
             $decodedConfig = json_decode($DBconfig->value, true);
             foreach ($decodedConfig as $key => $oldRecord) {
                 $decodedConfig[$key]['value'] = $oldRecord[$oldValueName];
                 unset($decodedConfig[$key][$oldValueName]);
             }
             // if no app defaults: use the first record as default
             $default = isset($appDefaults[$keyFieldName]) ? $appDefaults[$keyFieldName] : $decodedConfig[0]['id'];
             $DBconfig->value = json_encode(array('records' => $decodedConfig, 'default' => $default));
             $cb->update($DBconfig);
         }
     }
     if ($appDefaults) {
         $cb->delete($appDefaults->getId());
     }
 }
コード例 #9
0
 /**
  * init the default persistentfilters
  */
 protected function _initializeFavorites()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Inventory')->getId(), 'model' => 'Inventory_Model_InventoryItemFilter');
     // default persistent filter for all records
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All Inventory Items", 'description' => "All existing Inventory Items", 'filters' => array()))));
 }
コード例 #10
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     parent::setUp();
     $this->_json = new Filemanager_Frontend_Json();
     $this->_fsController = Tinebase_FileSystem::getInstance();
     $this->_application = Tinebase_Application::getInstance()->getApplicationByName('Filemanager');
 }
コード例 #11
0
 /**
  * update to 5.1
  * @return void
  */
 public function update_0()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Courses')->getId(), 'model' => 'Courses_Model_CourseFilter');
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Courses_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All courses", 'filters' => array(array('field' => 'is_deleted', 'operator' => 'equals', 'value' => '0'))))));
     $this->setApplicationVersion('Courses', '5.1');
 }
コード例 #12
0
 /**
  * init favorites
  */
 protected function _initializeKeyFields()
 {
     $cb = new Tinebase_Backend_Sql(array('modelName' => 'Tinebase_Model_Config', 'tableName' => 'config'));
     $attendeeRolesConfig = array('name' => Calendar_Config::ATTENDEE_ROLES, 'records' => array(array('id' => 'REQ', 'value' => 'Required', 'system' => true), array('id' => 'OPT', 'value' => 'Optional', 'system' => true)));
     $cb->create(new Tinebase_Model_Config(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'name' => Calendar_Config::ATTENDEE_ROLES, 'value' => json_encode($attendeeRolesConfig))));
     $attendeeStatusConfig = array('name' => Calendar_Config::ATTENDEE_STATUS, 'records' => array(array('id' => 'NEEDS-ACTION', 'value' => 'No response', 'icon' => 'images/oxygen/16x16/actions/mail-mark-unread-new.png', 'system' => true), array('id' => 'ACCEPTED', 'value' => 'Accepted', 'icon' => 'images/oxygen/16x16/actions/ok.png', 'system' => true), array('id' => 'DECLINED', 'value' => 'Declined', 'icon' => 'images/oxygen/16x16/actions/dialog-cancel.png', 'system' => true), array('id' => 'TENTATIVE', 'value' => 'Tentative', 'icon' => 'images/calendar-response-tentative.png', 'system' => true)));
     $cb->create(new Tinebase_Model_Config(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'name' => Calendar_Config::ATTENDEE_STATUS, 'value' => json_encode($attendeeStatusConfig))));
 }
 /**
  * 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;
 }
コード例 #14
0
 /**
  * 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->_json = new Filemanager_Frontend_Json();
     $this->_fsController = Tinebase_FileSystem::getInstance();
     $this->_application = Tinebase_Application::getInstance()->getApplicationByName('Filemanager');
     $this->_setupTestContainers();
 }
コード例 #15
0
 /**
  * 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';
 }
 /**
  * init favorites
  */
 protected function _initializeFavorites()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'model' => 'Calendar_Model_EventFilter');
     $myEventsPFilter = $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Calendar_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All events I attend", 'filters' => array(array('field' => 'attender', 'operator' => 'equals', 'value' => array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => Addressbook_Model_Contact::CURRENTCONTACT)), array('field' => 'attender_status', 'operator' => 'notin', 'value' => array('DECLINED')))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Awaiting response", 'description' => "Events I have not yet responded to", 'filters' => array(array('field' => 'attender', 'operator' => 'equals', 'value' => array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => Addressbook_Model_Contact::CURRENTCONTACT)), array('field' => 'attender_status', 'operator' => 'in', 'value' => array(Calendar_Model_Attender::STATUS_NEEDSACTION, Calendar_Model_Attender::STATUS_TENTATIVE)))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Declined events", 'description' => "Events I have declined", 'filters' => array(array('field' => 'attender', 'operator' => 'equals', 'value' => array('user_type' => Calendar_Model_Attender::USERTYPE_USER, 'user_id' => Addressbook_Model_Contact::CURRENTCONTACT)), array('field' => 'attender_status', 'operator' => 'in', 'value' => array(Calendar_Model_Attender::STATUS_DECLINED)))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "I'm organizer", 'description' => "Events I'm the organizer of", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT))))));
 }
 /**
  * init favorites
  */
 protected function _initializeFavorites()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Phone')->getId(), 'model' => 'Phone_Model_CallFilter');
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Calls this week", 'description' => "Incoming and outgoing calls of this week", 'filters' => array(array('field' => 'start', 'operator' => 'within', 'value' => 'weekThis'))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Calls last week", 'description' => "Incoming and outgoing calls of last week", 'filters' => array(array('field' => 'start', 'operator' => 'within', 'value' => 'weekLast'))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Calls this month", 'description' => "Incoming and outgoing calls of this month", 'filters' => array(array('field' => 'start', 'operator' => 'within', 'value' => 'monthThis'))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Calls last month", 'description' => "Incoming and outgoing calls of last month", 'filters' => array(array('field' => 'start', 'operator' => 'within', 'value' => 'monthLast'))))));
 }
 /**
  * init favorites
  */
 protected function _initializeFavorites()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Felamimail')->getId(), 'model' => 'Felamimail_Model_MessageFilter');
     $myInboxPFilter = $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Felamimail_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => 'All inboxes of my email accounts', 'filters' => array(array('field' => 'path', 'operator' => 'in', 'value' => Felamimail_Model_MessageFilter::PATH_ALLINBOXES))))));
     $myUnseenPFilter = $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => 'All unread mail', 'description' => 'All unread mail of my email accounts', 'filters' => array(array('field' => 'flags', 'operator' => 'notin', 'value' => Zend_Mail_Storage::FLAG_SEEN))))));
     $myHighlightedPFilter = $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => 'All highlighted mail', 'description' => 'All highlighted mail of my email accounts', 'filters' => array(array('field' => 'flags', 'operator' => 'in', 'value' => Zend_Mail_Storage::FLAG_FLAGGED))))));
     $myDraftsPFilter = $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => 'All drafts', 'description' => 'All mails with the draft flag', 'filters' => array(array('field' => 'flags', 'operator' => 'in', 'value' => Zend_Mail_Storage::FLAG_DRAFT))))));
 }
コード例 #19
0
 /**
  * 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';
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (empty(Tinebase_Core::getConfig()->filesdir)) {
         $this->markTestSkipped('filesystem base path not found');
     }
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     Tinebase_FileSystem::getInstance()->initializeApplication(Tinebase_Application::getInstance()->getApplicationByName('Addressbook'));
     clearstatcache();
 }
コード例 #21
0
 /**
  * returns registry data of PersistentFilter.
  *
  * @return array
  */
 public static function getAllPersistentFilters()
 {
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $obj = new Tinebase_Frontend_Json_PersistentFilter();
         // return only filters of activated apps
         $applicationIds = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->getArrayOfIds();
         return $obj->searchPersistentFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()), array('field' => 'application_id', 'operator' => 'in', 'value' => $applicationIds)), NULL);
     }
 }
コード例 #22
0
 /**
  * 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;
 }
コード例 #23
0
 /**
  * init favorites
  */
 protected function _initializeFavorites()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Projects')->getId(), 'model' => 'Projects_Model_ProjectFilter');
     $closedStatus = Projects_Config::getInstance()->get(Projects_Config::PROJECT_STATUS)->records->filter('is_open', 0);
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Projects_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All my open projects", 'filters' => array(array('field' => 'contact', 'operator' => 'AND', 'value' => array(array('field' => ':relation_type', 'operator' => 'in', 'value' => Projects_Config::getInstance()->get(Projects_Config::PROJECT_ATTENDEE_ROLE)->records->id), array('field' => ':id', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT))), array('field' => 'status', 'operator' => 'notin', 'value' => $closedStatus->getId()))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My projects that I'm responsible for", 'description' => "All my open projects that I am responsible for", 'filters' => array(array('field' => 'contact', 'operator' => 'AND', 'value' => array(array('field' => ':relation_type', 'operator' => 'in', 'value' => array('RESPONSIBLE')), array('field' => ':id', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT))), array('field' => 'status', 'operator' => 'notin', 'value' => $closedStatus->getId()))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My waiting projects", 'description' => "My projects that are on hold", 'filters' => array(array('field' => 'contact', 'operator' => 'AND', 'value' => array(array('field' => ':relation_type', 'operator' => 'in', 'value' => Projects_Config::getInstance()->get(Projects_Config::PROJECT_ATTENDEE_ROLE)->records->id), array('field' => ':id', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT))), array('field' => 'status', 'operator' => 'in', 'value' => array('NEEDS-ACTION')))))));
 }
 /**
  * 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;
 }
コード例 #25
0
 /**
  * add more default favorites
  */
 public function update_3()
 {
     $pfe = Tinebase_PersistentFilter::getInstance();
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Crm')->getId(), 'model' => 'Crm_Model_LeadFilter');
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All leads that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My leads", 'description' => "All leads that I am responsible for", 'filters' => array(array('field' => 'contact', 'operator' => 'AND', 'value' => array(array('field' => 'id', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT))))))));
     $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Leads with overdue tasks", 'description' => "Leads with overdue tasks", 'filters' => array(array('field' => 'task', 'operator' => 'AND', 'value' => array(array('field' => 'due', 'operator' => 'before', 'value' => 'dayThis'))))))));
     $this->setApplicationVersion('Crm', '3.4');
 }
コード例 #26
0
 /**
  * add one record
  *
  * @param   Tinebase_Record_Interface $_record
  * @return  Tinebase_Record_Interface
  * @throws  Tinebase_Exception_AccessDenied
  */
 public function create(Tinebase_Record_Interface $_record)
 {
     // create a calendar for this resource
     $container = Tinebase_Container::getInstance()->addContainer(new Tinebase_Model_Container(array('name' => $_record->name, 'type' => Tinebase_Model_Container::TYPE_SHARED, 'backend' => $this->_backend->getType(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($this->_applicationName)->getId())), NULL, TRUE);
     // remove default admin
     $grants = Tinebase_Container::getInstance()->setGrants($container->getId(), new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array(array('account_id' => '0', 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, Tinebase_Model_Grants::GRANT_FREEBUSY => true))), TRUE, FALSE);
     $_record->container_id = $container->getId();
     return parent::create($_record);
 }
コード例 #27
0
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (empty(Tinebase_Core::getConfig()->filesdir)) {
         $this->markTestSkipped('filesystem base path not found');
     }
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $this->_basePath = 'tine20:///' . Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId() . '/internal/phpunit';
     Tinebase_FileSystem::getInstance()->initializeApplication(Tinebase_Application::getInstance()->getApplicationByName('Tinebase'));
     clearstatcache();
 }
 /**
  * Sets up the fixture.
  * This method is called before a test is executed.
  *
  * @access protected
  */
 protected function setUp()
 {
     if (empty(Tinebase_Core::getConfig()->filesdir)) {
         $this->markTestSkipped('filesystem base path not found');
     }
     Tinebase_TransactionManager::getInstance()->startTransaction(Tinebase_Core::getDb());
     $this->_controller = new Tinebase_FileSystem();
     $this->_basePath = '/' . Tinebase_Application::getInstance()->getApplicationByName('Tinebase')->getId() . '/folders/' . Tinebase_Model_Container::TYPE_SHARED;
     $this->_controller->initializeApplication(Tinebase_Application::getInstance()->getApplicationByName('Tinebase'));
 }
コード例 #29
0
 /**
  * the constructor
  *
  * don't use the constructor. use the singleton
  */
 private function __construct()
 {
     $this->_applicationName = 'HumanResources';
     $this->_backend = new HumanResources_Backend_Contract();
     $this->_modelName = 'HumanResources_Model_Contract';
     $this->_purgeRecords = FALSE;
     $this->_useSales = Tinebase_Application::getInstance()->isInstalled('Sales', TRUE);
     // activate this if you want to use containers
     $this->_doContainerACLChecks = FALSE;
 }
コード例 #30
0
 /**
  * create default favorites and update to 5.3
  *
  * @return void
  */
 public function update_2()
 {
     // Timeaccounts
     $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId(), 'model' => 'Timetracker_Model_TimeaccountFilter');
     $pfe = new Tinebase_PersistentFilter_Backend_Sql();
     $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timeaccounts to bill", 'description' => "Timeaccounts to bill", 'filters' => array(array('field' => 'status', 'operator' => 'equals', 'value' => 'to bill'))))));
     $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timeaccounts not yet billed", 'description' => "Timeaccounts not yet billed", 'filters' => array(array('field' => 'status', 'operator' => 'equals', 'value' => 'not yet billed'))))));
     $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timeaccounts already billed", 'description' => "Timeaccounts already billed", 'filters' => array(array('field' => 'status', 'operator' => 'equals', 'value' => 'billed'))))));
     $this->setApplicationVersion('Timetracker', '5.3');
 }