Ejemplo n.º 1
0
 /**
  * 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');
 }
Ejemplo n.º 2
0
 /**
  * tear down tests
  *
  */
 public function tearDown()
 {
     $pfe = new Tinebase_PersistentFilter_Backend_Sql();
     $pfe->deleteByProperty('All my tasks', 'description');
     $backend = new Tasks_Backend_Sql();
     $backend->deleteByProperty("Test Task", "description");
 }
Ejemplo n.º 3
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))))));
 }
Ejemplo n.º 4
0
 /**
  * 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))))));
 }
 /**
  * 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))))));
 }
Ejemplo n.º 6
0
 /**
  * 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');
 }
Ejemplo n.º 7
0
 /**
  * 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')))))));
 }
Ejemplo n.º 8
0
 /**
  * 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'))))))));
 }
Ejemplo n.º 9
0
 /**
  * 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))))));
 }
Ejemplo n.º 10
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');
 }
Ejemplo n.º 11
0
 /**
  * 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'))))));
 }
 /**
  * update favorites to new filter syntax and update to 5.2
  *
  * @return void
  */
 public function update_1()
 {
     $pfBackend = new Tinebase_PersistentFilter_Backend_Sql();
     $filters = $pfBackend->getAll();
     $timetrackerFilters = $filters->filter('application_id', Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId());
     foreach ($timetrackerFilters as $pfilter) {
         foreach ($pfilter->filters as $filter) {
             if (in_array($filter->getField(), array('timeaccount_id')) && $filter instanceof Tinebase_Model_Filter_ForeignId) {
                 $values = array();
                 foreach ($filter->getValue() as $idx => $subfilter) {
                     $values[$idx] = $subfilter;
                     if (in_array($subfilter['field'], array('id'))) {
                         $values[$idx]['field'] = ':' . $subfilter['field'];
                     }
                 }
                 $filter->setValue($values);
                 $pfBackend->update($pfilter);
             }
         }
     }
     $this->setApplicationVersion('Timetracker', '5.2');
 }
Ejemplo n.º 13
0
 /**
  * update favorites to new filter syntax and update to 5.0 
  * 
  * @return void
  */
 public function update_0()
 {
     $filters = Tinebase_PersistentFilter::getInstance()->getAll();
     $crmFilters = $filters->filter('application_id', Tinebase_Application::getInstance()->getApplicationByName('Crm')->getId());
     $pfBackend = new Tinebase_PersistentFilter_Backend_Sql();
     foreach ($crmFilters as $pfilter) {
         foreach ($pfilter->filters as $filter) {
             if (in_array($filter->getField(), array('contact', 'product', 'task')) && $filter instanceof Tinebase_Model_Filter_Relation) {
                 $values = array();
                 foreach ($filter->getValue() as $idx => $subfilter) {
                     $values[$idx] = $subfilter;
                     if (in_array($subfilter['field'], array('relation_type', 'id'))) {
                         $values[$idx]['field'] = ':' . $subfilter['field'];
                     }
                 }
                 $filter->setValue($values);
                 $pfBackend->update($pfilter);
             }
         }
     }
     $this->setApplicationVersion('Crm', '5.1');
 }
Ejemplo n.º 14
0
 /**
  * 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' => ''))))));
 }
Ejemplo n.º 15
0
 /**
  * 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');
 }
Ejemplo n.º 16
0
 /**
  * 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');
 }
Ejemplo n.º 17
0
 /**
  * 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');
 }
Ejemplo n.º 18
0
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     // remove accounts for group member tests
     try {
         Tinebase_User::getInstance()->deleteUser($this->objects['user']->accountId);
     } catch (Exception $e) {
         // do nothing
     }
     Addressbook_Controller_Contact::getInstance()->delete(array($this->objects['contact']->getId(), $this->objects['unSyncableContact']->getId()));
     Tinebase_Container::getInstance()->deleteContainer($this->objects['containerWithSyncGrant']);
     Tinebase_Container::getInstance()->deleteContainer($this->objects['containerWithoutSyncGrant']);
     ActiveSync_Controller_Device::getInstance()->delete($this->objects['deviceWebOS']);
     ActiveSync_Controller_Device::getInstance()->delete($this->objects['deviceIPhone']);
     $filterBackend = new Tinebase_PersistentFilter_Backend_Sql();
     $filterBackend->delete($this->objects['filter']->getId());
     Addressbook_Controller_Contact::getInstance()->setGeoDataForContacts($this->_setGeoData);
 }
Ejemplo n.º 19
0
 /**
  * (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);
 }
Ejemplo n.º 20
0
 /**
  * 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');
 }
Ejemplo n.º 21
0
 /**
  * Tears down the fixture
  * This method is called after a test is executed.
  *
  * @access protected
  */
 protected function tearDown()
 {
     ActiveSync_Controller_Device::getInstance()->delete($this->objects['device']);
     $filterBackend = new Tinebase_PersistentFilter_Backend_Sql();
     $filterBackend->delete($this->objects['filter']->getId());
 }
 /**
  * add default grants to existing filters
  */
 protected function _addGrantsToExistingFilters()
 {
     $pfBackend = new Tinebase_PersistentFilter_Backend_Sql();
     $filters = $pfBackend->getAll();
     $pfGrantsBackend = new Tinebase_Backend_Sql_Grants(array('modelName' => 'Tinebase_Model_PersistentFilterGrant', 'tableName' => 'filter_acl'));
     $pfGrantsBackend->getGrantsForRecords($filters);
     foreach ($filters as $filter) {
         if (count($filter->grants) > 0) {
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Filter ' . $filter->name . ' already has grants.');
             }
             continue;
         }
         $grant = new Tinebase_Model_PersistentFilterGrant(array('account_type' => $filter->isPersonal() ? Tinebase_Acl_Rights::ACCOUNT_TYPE_USER : Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE, 'account_id' => $filter->account_id, 'record_id' => $filter->getId()));
         $grant->sanitizeAccountIdAndFillWithAllGrants();
         $filter->grants = new Tinebase_Record_RecordSet('Tinebase_Model_PersistentFilterGrant');
         $filter->grants->addRecord($grant);
         if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
             Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Updating filter "' . $filter->name . '" with grant: ' . print_r($grant->toArray(), true));
         }
         Tinebase_PersistentFilter::getInstance()->setGrants($filter);
     }
 }
Ejemplo n.º 23
0
 /**
  * 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))))));
 }
Ejemplo n.º 24
0
 /**
  * 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');
 }
 /**
  * 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']))));
 }