/** * 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)))))); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'model' => 'Calendar_Model_EventFilter'); $myEventsPFilter = $pfe->create(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->create(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->create(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->create(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)))))); }
/** * add more default favorites */ public function update_3() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Crm')->getId(), 'model' => 'Crm_Model_LeadFilter'); $pfe->create(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->create(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->create(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'); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $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->create(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->create(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->create(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'))))))); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Expressomail')->getId(), 'model' => 'Expressomail_Model_MessageFilter'); $myInboxPFilter = $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Expressomail_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => 'All inboxes of my email accounts', 'filters' => array(array('field' => 'path', 'operator' => 'in', 'value' => Expressomail_Model_MessageFilter::PATH_ALLINBOXES)))))); $myUnseenPFilter = $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => 'All unread mail from Inbox', 'description' => 'All unread mail of my Inbox', 'filters' => array(array('field' => 'flags', 'operator' => 'notin', 'value' => Zend_Mail_Storage::FLAG_SEEN), array('field' => 'path', 'operator' => 'in', 'value' => Expressomail_Model_MessageFilter::PATH_ALLINBOXES)))))); $myHighlightedPFilter = $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => 'All Highlighted mail from Inbox', 'description' => 'All highlighted mail of my Inbox', 'filters' => array(array('field' => 'flags', 'operator' => 'in', 'value' => Zend_Mail_Storage::FLAG_FLAGGED), array('field' => 'path', 'operator' => 'in', 'value' => Expressomail_Model_MessageFilter::PATH_ALLINBOXES)))))); $myDraftsPFilter = $pfe->create(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)))))); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Crm')->getId(), 'model' => 'Crm_Model_LeadFilter'); $closedStatus = Crm_Controller::getInstance()->getConfigSettings()->getEndedLeadstates(TRUE); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Crm_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All leads I have read grants for", 'filters' => array(array('field' => 'leadstate_id', 'operator' => 'notin', 'value' => $closedStatus)))))); $pfe->create(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->create(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->create(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')))))))); }
/** * 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'); }
/** * init favorites */ protected function _initializeFavorites() { // Products $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Sales')->getId(), 'model' => 'Sales_Model_ProductFilter'); $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Products", 'description' => "Products created by me", 'filters' => array(array('field' => 'created_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); // Contracts $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Sales')->getId(), 'model' => 'Sales_Model_ContractFilter'); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Contracts", 'description' => "Contracts created by me", 'filters' => array(array('field' => 'created_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); }
/** * added more default favorites * * @return void */ public function update_2() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId(), 'model' => 'Timetracker_Model_TimesheetFilter'); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timesheets today", 'description' => "Timesheets today", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'dayThis')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timesheets this week", 'description' => "Timesheets this week", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'weekThis')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timesheets last week", 'description' => "Timesheets last week", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'weekLast')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timesheets this month", 'description' => "Timesheets this month", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'monthThis')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Timesheets last month", 'description' => "Timesheets last month", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'monthLast')))))); $this->setApplicationVersion('Timetracker', '3.3'); }
/** * update to 5.1 * @return void */ public function update_0() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Courses')->getId(), 'model' => 'Courses_Model_CourseFilter'); $pfe->create(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'); }
/** * set up tests * */ public function setUp() { $user = Tinebase_Core::getUser(); $container = $user->getPersonalContainer('Tasks', $user, Tinebase_Model_Grants::GRANT_ADMIN); $container_id = $container[0]->getId(); $backend = new Tasks_Backend_Sql(); $testTask1 = new Tasks_Model_Task(array('container_id' => $container_id, 'created_by' => 6, 'creation_time' => '2009-03-31 17:35:00', 'is_deleted' => 0, 'deleted_time' => NULL, 'deleted_by' => NULL, 'percent' => 70, 'completed' => NULL, 'due' => '2009-04-30 17:35:00', 'description' => "Test Task", 'geo' => 0.2345, 'location' => 'here and there', 'organizer' => Tinebase_Core::getUser()->getId(), 'priority' => 2, 'summary' => 'our first test task', 'url' => 'http://www.testtask.com')); $backend->create($testTask1); $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $pfe->create(new Tinebase_Model_PersistentFilter(array('name' => Tasks_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All my tasks", 'account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId(), 'model' => 'Tasks_Model_TaskFilter', 'filters' => array(array('condition' => 'OR', 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => '/personal/' . Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT))))))); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId(), 'model' => 'Timetracker_Model_TimesheetFilter'); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Timesheets today", 'description' => "My Timesheets today", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'dayThis')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Timesheets this week", 'description' => "My Timesheets this week", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'weekThis')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Timesheets last week", 'description' => "My Timesheets last week", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'weekLast')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Timesheets this month", 'description' => "My Timesheets this month", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'monthThis')))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My Timesheets last month", 'description' => "My Timesheets last month", 'filters' => array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'start_date', 'operator' => 'within', 'value' => 'monthLast')))))); // Timeaccounts $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId(), 'model' => 'Timetracker_Model_TimeaccountFilter'); $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')))))); }
protected function setUp() { ########### define test device $testDevice = ActiveSync_Backend_DeviceTests::getTestDevice(); $this->objects['device'] = ActiveSync_Controller_Device::getInstance()->create($testDevice); ########### define test filter $filterBackend = new Tinebase_PersistentFilter_Backend_Sql(); try { $filter = $filterBackend->getByProperty('Sync Test', 'name'); } catch (Tinebase_Exception_NotFound $e) { $filter = new Tinebase_Model_PersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'account_id' => Tinebase_Core::getUser()->getId(), 'model' => 'Addressbook_Model_ContactFilter', 'filters' => array(array('field' => 'query', 'operator' => 'contains', 'value' => 'blabla')), 'name' => 'Sync Test', 'description' => 'Created by unit test')); $filter = $filterBackend->create($filter); } $this->objects['filter'] = $filter; }
/** * init favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId(), 'model' => 'Tasks_Model_TaskFilter'); $closedStatus = Tasks_Config::getInstance()->get(Tasks_Config::TASK_STATUS)->records->filter('is_open', 0); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Tasks_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All tasks of my taskslists", 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => '/personal/' . Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'status', 'operator' => 'notin', 'value' => $closedStatus->getId())))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My open tasks", 'description' => "My open tasks", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'status', 'operator' => 'notin', 'value' => $closedStatus->getId())))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My open tasks this week", 'description' => "My open tasks this week", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'due', 'operator' => 'within', 'value' => 'weekThis'), array('field' => 'status', 'operator' => 'notin', 'value' => $closedStatus->getId())))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All tasks for me", 'description' => "All tasks that I am responsible for", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All tasks that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Tasks without responsible", 'description' => "Tasks without responsible", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => '')))))); }
/** * create more persistent filters */ public function update_7() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $pfe->create(new Tinebase_Model_PersistentFilter(array('name' => "Awaiting response", 'description' => "Events I have not yet responded to", 'account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'model' => 'Calendar_Model_EventFilter', '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->create(new Tinebase_Model_PersistentFilter(array('name' => "Declined events", 'description' => "Events I have declined", 'account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'model' => 'Calendar_Model_EventFilter', '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->create(new Tinebase_Model_PersistentFilter(array('name' => "I'm organizer", 'description' => "Events I'm the organizer of", 'account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'model' => 'Calendar_Model_EventFilter', 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Addressbook_Model_Contact::CURRENTCONTACT))))); $this->setApplicationVersion('Calendar', '3.8'); }
/** * create favorites */ protected function _initializeFavorites() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_ContactFilter'); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Addressbook_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All contacts I have read grants for", 'filters' => array())))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My company", 'description' => "All coworkers in my company", 'filters' => array(array('field' => 'container_id', 'operator' => 'in', 'value' => array('id' => $this->_getInternalAddressbook()->getId(), 'path' => '/shared/' . $this->_getInternalAddressbook()->getId()))))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My contacts", 'description' => "All contacts in my Addressbooks", 'filters' => array(array('field' => 'container_id', 'operator' => 'in', 'value' => array('id' => 'personal', 'path' => '/personal/' . Tinebase_Model_User::CURRENTACCOUNT))))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All contacts that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); }
/** * testSearchIncludesSharedFavorites */ public function testSearchIncludesSharedFavorites() { $sharedFavorite = self::getPersitentFilter(); $sharedFavorite->name = 'PHPUnit shared filter'; $sharedFavorite->account_id = NULL; $backend = new Tinebase_PersistentFilter_Backend_Sql(); $persistentSharedFavirite = $backend->create($sharedFavorite); $exampleFilterData = self::getPersistentFilterData(); $savedFilterData = $this->testSaveFilter($exampleFilterData); $filterData = array(array('field' => 'model', 'operator' => 'equals', 'value' => 'Tasks_Model_TaskFilter'), array('field' => 'name', 'operator' => 'startswith', 'value' => 'PHPUnit')); $searchResult = $this->_uit->searchPersistentFilter($filterData, NULL); $this->assertGreaterThanOrEqual(2, $searchResult['totalcount']); $ids = array(); foreach ($searchResult['results'] as $filterData) { $ids[] = $filterData['id']; } $this->assertEquals(2, count(array_intersect($ids, array($persistentSharedFavirite->getId(), $savedFilterData['id'])))); }
/** * (non-PHPdoc) * @see ActiveSync/ActiveSync_TestCase::setUp() */ protected function setUp() { parent::setUp(); // replace email to make current user organizer and attendee $this->_testXMLInput = str_replace('*****@*****.**', Tinebase_Core::getUser()->accountEmailAddress, $this->_testXMLInput); $event = new Calendar_Model_Event(array('uid' => Tinebase_Record_Abstract::generateUID(), 'summary' => 'SyncTest', 'dtstart' => Tinebase_DateTime::now()->addMonth(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'dtend' => Tinebase_DateTime::now()->addMonth(1)->addHour(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'originator_tz' => 'Europe/Berlin', 'container_id' => $this->_getContainerWithSyncGrant()->getId(), Tinebase_Model_Grants::GRANT_EDIT => true, 'attendee' => new Tinebase_Record_RecordSet('Calendar_Model_Attender', array(array('user_id' => Tinebase_Core::getUser()->contact_id, 'user_type' => Calendar_Model_Attender::USERTYPE_USER, 'status' => Calendar_Model_Attender::STATUS_ACCEPTED))))); $event = Calendar_Controller_Event::getInstance()->create($event); $this->objects['event'] = $event; $event2MonthsBack = new Calendar_Model_Event(array('uid' => Tinebase_Record_Abstract::generateUID(), 'summary' => 'SyncTest', 'dtstart' => Tinebase_DateTime::now()->subMonth(2)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'dtend' => Tinebase_DateTime::now()->subMonth(2)->addHour(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'originator_tz' => 'Europe/Berlin', 'container_id' => $this->_getContainerWithSyncGrant()->getId(), Tinebase_Model_Grants::GRANT_EDIT => true)); $event = Calendar_Controller_Event::getInstance()->create($event2MonthsBack); $this->objects['event2MonthsBack'] = $event; $eventDaily = new Calendar_Model_Event(array('uid' => Tinebase_Record_Abstract::generateUID(), 'summary' => 'SyncTest', 'dtstart' => Tinebase_DateTime::now()->addMonth(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'dtend' => Tinebase_DateTime::now()->addMonth(1)->addHour(1)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'originator_tz' => 'Europe/Berlin', 'rrule' => 'FREQ=DAILY;INTERVAL=1;UNTIL=' . Tinebase_DateTime::now()->addMonth(1)->addDay(6)->setHour(22)->setMinute(59)->setSecond(59)->toString(Tinebase_Record_Abstract::ISO8601LONG), 'container_id' => $this->_getContainerWithSyncGrant()->getId(), Tinebase_Model_Grants::GRANT_EDIT => true)); $eventDaily = Calendar_Controller_Event::getInstance()->create($eventDaily); // compute recurset $recurSet = Calendar_Model_Rrule::computeRecurrenceSet($eventDaily, new Tinebase_Record_RecordSet('Calendar_Model_Event'), $eventDaily->dtstart, $eventDaily->rrule_until); // first deleted instance Calendar_Controller_Event::getInstance()->createRecurException($recurSet[0], true); // second deleted instance Calendar_Controller_Event::getInstance()->createRecurException($recurSet[1], true); // first exception instance $recurSet[2]->dtstart->addHour(2); $recurSet[2]->dtend->addHour(2); $recurSet[2]->summary = 'Test Exception 1'; Calendar_Controller_Event::getInstance()->createRecurException($recurSet[2]); // first exception instance $recurSet[3]->dtstart->addHour(3); $recurSet[3]->dtend->addHour(3); $recurSet[3]->summary = 'Test Exception 2'; Calendar_Controller_Event::getInstance()->createRecurException($recurSet[3]); // reread event from database again $eventDaily = Calendar_Controller_Event::getInstance()->get($eventDaily); #var_dump($eventDaily->toArray()); $this->objects['eventDaily'] = $eventDaily; Tinebase_Core::getPreference('ActiveSync')->setValue(ActiveSync_Preference::DEFAULTCALENDAR, $this->_getContainerWithSyncGrant()->getId()); ########### define test filter $filterBackend = new Tinebase_PersistentFilter_Backend_Sql(); try { $filter = $filterBackend->getByProperty('Calendar Sync Test', 'name'); } catch (Tinebase_Exception_NotFound $e) { $filter = new Tinebase_Model_PersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'account_id' => Tinebase_Core::getUser()->getId(), 'model' => 'Calendar_Model_EventFilter', 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->_getContainerWithSyncGrant()->getId())), 'name' => 'Calendar Sync Test', 'description' => 'Created by unit test')); $filter = $filterBackend->create($filter); } $this->objects['filter'] = $filter; ########### define test devices $palm = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_WEBOS); $palm->owner_id = $this->_testUser->getId(); $palm->calendarfilter_id = $this->objects['filter']->getId(); $this->objects['deviceWebOS'] = ActiveSync_Controller_Device::getInstance()->create($palm); $iphone = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_IPHONE); $iphone->owner_id = $this->_testUser->getId(); $iphone->calendarfilter_id = $this->objects['filter']->getId(); $this->objects['deviceIPhone'] = ActiveSync_Controller_Device::getInstance()->create($iphone); }
protected function setUp() { $this->_setGeoData = Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts(FALSE); $appName = 'Addressbook'; ############# TEST USER ########## $user = new Tinebase_Model_FullUser(array('accountLoginName' => 'tine20phpunit', 'accountDisplayName' => 'tine20phpunit', 'accountStatus' => 'enabled', 'accountExpires' => NULL, 'accountPrimaryGroup' => Tinebase_Group::getInstance()->getGroupByName('Users')->getId(), 'accountLastName' => 'Tine 2.0', 'accountFirstName' => 'PHPUnit', 'accountEmailAddress' => '*****@*****.**')); try { $user = Tinebase_User::getInstance()->getUserByLoginName($user->accountLoginName); } catch (Tinebase_Exception_NotFound $e) { $user = Tinebase_User::getInstance()->addUser($user); } $this->objects['user'] = $user; ############# TEST CONTACT ########## try { $containerWithSyncGrant = Tinebase_Container::getInstance()->getContainerByName($appName, 'ContainerWithSyncGrant', Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser()); } catch (Tinebase_Exception_NotFound $e) { $containerWithSyncGrant = new Tinebase_Model_Container(array('name' => 'ContainerWithSyncGrant', 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => Tinebase_Core::getUser(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($appName)->getId())); $containerWithSyncGrant = Tinebase_Container::getInstance()->addContainer($containerWithSyncGrant); } $this->objects['containerWithSyncGrant'] = $containerWithSyncGrant; try { $containerWithoutSyncGrant = Tinebase_Container::getInstance()->getContainerByName($appName, 'ContainerWithoutSyncGrant', Tinebase_Model_Container::TYPE_PERSONAL, Tinebase_Core::getUser()); } catch (Tinebase_Exception_NotFound $e) { $creatorGrants = array('account_id' => Tinebase_Core::getUser()->getId(), 'account_type' => Tinebase_Acl_Rights::ACCOUNT_TYPE_USER, Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_ADD => true, Tinebase_Model_Grants::GRANT_EDIT => true, Tinebase_Model_Grants::GRANT_DELETE => true, Tinebase_Model_Grants::GRANT_ADMIN => true); $grants = new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array($creatorGrants)); $containerWithoutSyncGrant = new Tinebase_Model_Container(array('name' => 'ContainerWithoutSyncGrant', 'type' => Tinebase_Model_Container::TYPE_PERSONAL, 'owner_id' => Tinebase_Core::getUser(), 'backend' => 'Sql', 'application_id' => Tinebase_Application::getInstance()->getApplicationByName($appName)->getId())); $containerWithSyncGrant = Tinebase_Container::getInstance()->addContainer($containerWithoutSyncGrant, $grants); } $this->objects['containerWithoutSyncGrant'] = $containerWithoutSyncGrant; $contact = 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', 'bday' => '1975-01-02 03:00:00', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'container_id' => $this->objects['containerWithSyncGrant']->id, 'role' => 'Role', 'n_given' => 'Lars', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars')); $contact = Addressbook_Controller_Contact::getInstance()->create($contact, FALSE); $this->objects['contact'] = $contact; $unSyncableContact = 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', 'bday' => '1975-01-02 03:00:00', 'email' => '*****@*****.**', 'email_home' => '*****@*****.**', 'container_id' => $this->objects['containerWithoutSyncGrant']->id, 'role' => 'Role', 'n_given' => 'Lars', 'n_family' => 'Kneschke', 'n_fileas' => 'Kneschke, Lars')); $unSyncableContact = Addressbook_Controller_Contact::getInstance()->create($unSyncableContact, FALSE); $this->objects['unSyncableContact'] = $unSyncableContact; ########### define test filter $filterBackend = new Tinebase_PersistentFilter_Backend_Sql(); try { $filter = $filterBackend->getByProperty('Contacts Sync Test', 'name'); } catch (Tinebase_Exception_NotFound $e) { $filter = new Tinebase_Model_PersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'account_id' => Tinebase_Core::getUser()->getId(), 'model' => 'Addressbook_Model_ContactFilter', 'filters' => array(array('field' => 'container_id', 'operator' => 'equals', 'value' => $this->objects['containerWithSyncGrant']->getId())), 'name' => 'Contacts Sync Test', 'description' => 'Created by unit test')); $filter = $filterBackend->create($filter); } $this->objects['filter'] = $filter; ########### define test devices $palm = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_WEBOS); $palm->contactsfilter_id = $this->objects['filter']->getId(); $this->objects['deviceWebOS'] = ActiveSync_Controller_Device::getInstance()->create($palm); $iphone = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_IPHONE); $iphone->contactsfilter_id = $this->objects['filter']->getId(); $this->objects['deviceIPhone'] = ActiveSync_Controller_Device::getInstance()->create($iphone); $htcAndroid = ActiveSync_Backend_DeviceTests::getTestDevice(Syncope_Model_Device::TYPE_ANDROID); $htcAndroid->contactsfilter_id = $this->objects['filter']->getId(); $this->objects['deviceAndroid'] = ActiveSync_Controller_Device::getInstance()->create($htcAndroid); }
/** * update to 3.11 * - add more default favorites */ public function update_10() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_ContactFilter'); try { $internalAddressbook = Tinebase_Container::getInstance()->getContainerByName('Addressbook', 'Internal Contacts', Tinebase_Model_Container::TYPE_SHARED); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My company", 'description' => "All coworkers in my company", 'filters' => array(array('field' => 'container_id', 'operator' => 'in', 'value' => array('id' => $internalAddressbook->getId(), 'path' => '/shared/' . $internalAddressbook->getId()))))))); } catch (Tinebase_Exception_NotFound $tenf) { // do not create filter } $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My contacts", 'description' => "All contacts in my Addressbooks", 'filters' => array(array('field' => 'container_id', 'operator' => 'in', 'value' => array('id' => 'personal', 'path' => '/personal/' . Tinebase_Model_User::CURRENTACCOUNT))))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All contacts that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); $this->setApplicationVersion('Addressbook', '3.11'); }
/** * update function (-> 3.18) * - add more default favorites */ public function update_17() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Felamimail')->getId(), 'model' => 'Felamimail_Model_MessageFilter'); $myUnseenPFilter = $pfe->create(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->create(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->create(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)))))); $this->setApplicationVersion('Felamimail', '3.18'); }
/** * add more default favorites */ public function update_3() { $pfe = new Tinebase_PersistentFilter_Backend_Sql(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Tasks')->getId(), 'model' => 'Tasks_Model_TaskFilter'); $closedIds = $this->_getClosedStatusIds(); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My open tasks", 'description' => "My open tasks", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'status_id', 'operator' => 'notin', 'value' => $closedIds)))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "My open tasks this week", 'description' => "My open tasks this week", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT), array('field' => 'due', 'operator' => 'within', 'value' => 'weekThis'), array('field' => 'status_id', 'operator' => 'notin', 'value' => $closedIds)))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All tasks for me", 'description' => "All tasks that I am responsible for", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Last modified by me", 'description' => "All tasks that I have last modified", 'filters' => array(array('field' => 'last_modified_by', 'operator' => 'equals', 'value' => Tinebase_Model_User::CURRENTACCOUNT)))))); $pfe->create(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Tasks without responsible", 'description' => "Tasks without responsible", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => '')))))); $this->setApplicationVersion('Tasks', '3.4'); }