/** * 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())))); }
/** * 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'); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = Tinebase_PersistentFilter::getInstance(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('SimpleFAQ')->getId(), 'model' => 'SimpleFAQ_Model_FaqFilter'); $pfe->createDuringSetup(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->createDuringSetup(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 = 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'))))))); }
/** * 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)))))); }
/** * 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('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)))))); }
/** * 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'); }
/** * create favorites */ protected function _initializeFavorites() { $pfe = Tinebase_PersistentFilter::getInstance(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('HumanResources')->getId(), 'model' => 'HumanResources_Model_EmployeeFilter'); $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Currently employed employees", 'description' => "Employees which are currently employed", 'filters' => array(array('field' => 'is_employed', 'operator' => 'equals', 'value' => 1)))))); $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All employees", 'description' => "All available employees", 'filters' => array())))); // Accounts $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('HumanResources')->getId(), 'model' => 'HumanResources_Model_AccountFilter'); $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All accounts", 'description' => "All available accounts", 'filters' => array())))); }
/** * 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 = Tinebase_PersistentFilter::getInstance(); $pfe->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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() { $pfe = Tinebase_PersistentFilter::getInstance(); $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->createDuringSetup(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->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')))))))); }
/** * update from 5.1 -> 5.2 * - default contracts & products * * @return void */ public function update_1() { // Products $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Sales')->getId(), 'model' => 'Sales_Model_ProductFilter'); $pfe = Tinebase_PersistentFilter::getInstance(); $pfe->createDuringSetup(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->createDuringSetup(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)))))); $this->setApplicationVersion('Sales', '5.2'); }
/** * added more default favorites * * @return void */ public function update_2() { $pfe = Tinebase_PersistentFilter::getInstance(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId(), 'model' => 'Timetracker_Model_TimesheetFilter'); $pfe->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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'); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = Tinebase_PersistentFilter::getInstance(); $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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "Tasks without responsible", 'description' => "Tasks without responsible", 'filters' => array(array('field' => 'organizer', 'operator' => 'equals', 'value' => '')))))); }
/** * init favorites */ protected function _initializeFavorites() { $pfe = Tinebase_PersistentFilter::getInstance(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId(), 'model' => 'Timetracker_Model_TimesheetFilter'); $pfe->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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')))))); }
/** * init favorites */ protected function _initializeFavorites() { // Products $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Sales')->getId(), 'model' => 'Sales_Model_ProductFilter'); $pfe = Tinebase_PersistentFilter::getInstance(); $pfe->createDuringSetup(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['model'] = 'Sales_Model_ContractFilter'; $pfe->createDuringSetup(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)))))); // Customers $commonValues['model'] = 'Sales_Model_CustomerFilter'; $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All Customers", 'description' => "All customer records", 'filters' => array())))); // Offers $commonValues['model'] = 'Sales_Model_OfferFilter'; $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => "All Offers", 'description' => "All offer records", 'filters' => array())))); Sales_Setup_Update_Release8::createDefaultFavoritesForSub20(); Sales_Setup_Update_Release8::createDefaultFavoritesForSub22(); Sales_Setup_Update_Release8::createDefaultFavoritesForSub24(); }
/** * update favorites to new filter syntax and update to 5.2 * * @return void */ public function update_1() { $filters = Tinebase_PersistentFilter::getInstance()->getAll(); $timetrackerFilters = $filters->filter('application_id', Tinebase_Application::getInstance()->getApplicationByName('Timetracker')->getId()); $pfBackend = new Tinebase_PersistentFilter_Backend_Sql(); 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'); }
/** * 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'); }
/** * returns multiple records prepared for json transport * * @param Tinebase_Record_RecordSet $_records Tinebase_Record_Abstract * @param Tinebase_Model_Filter_FilterGroup * @param Tinebase_Model_Pagination $_pagination * @return array data * * @todo move to converter * @todo get multiple grants at once */ protected function _multipleRecordsToJson(Tinebase_Record_RecordSet $_records, $_filter = NULL, $_pagination = NULL) { $result = parent::_multipleRecordsToJson($_records, $_filter); foreach ($result as $idx => $recordArray) { $recordIdx = $_records->getIndexById($recordArray['id']); try { if (!is_object($_records[$recordIdx]->filters)) { throw new Tinebase_Exception_UnexpectedValue('no filter group found'); } $result[$idx]['filters'] = $_records[$recordIdx]->filters->toArray(TRUE); } catch (Exception $e) { if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Skipping filter: ' . $e->getMessage()); } unset($result[$idx]); continue; } // resolve grant users/groups if (isset($result[$idx]['grants'])) { $result[$idx]['grants'] = Tinebase_Frontend_Json_Container::resolveAccounts($result[$idx]['grants']); $result[$idx]['account_grants'] = Tinebase_PersistentFilter::getInstance()->getGrantsOfAccount(Tinebase_Core::getUser(), $_records[$recordIdx])->toArray(); } } return array_values($result); }
/** * repair function for persistent filters (favorites) without grants: this adds default grants for those filters. * * @return int */ public function setDefaultGrantsOfPersistentFilters() { if (!$this->_checkAdminRight()) { return -1; } $this->_addOutputLogWriter(6); // get all persistent filters without grants // TODO this could be enhanced by allowing to set default grants for other filters, too Tinebase_PersistentFilter::getInstance()->doContainerACLChecks(false); $filters = Tinebase_PersistentFilter::getInstance()->search(new Tinebase_Model_PersistentFilterFilter(array(), '', array('ignoreAcl' => true))); $filtersWithoutGrants = 0; foreach ($filters as $filter) { if (count($filter->grants) == 0) { // update to set default grants $filter = Tinebase_PersistentFilter::getInstance()->update($filter); $filtersWithoutGrants++; if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) { Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Updated filter: ' . print_r($filter->toArray(), true)); } } } if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) { Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' Set default grants for ' . $filtersWithoutGrants . ' filters' . ' (checked ' . count($filters) . ' in total).'); } return 0; }
/** * create default favorite for teacher * * @param Tinebase_Model_FullUser $account * @param Courses_Model_Course $course */ protected function _createDefaultFilterForTeacher($account, $course) { $pfe = Tinebase_PersistentFilter::getInstance(); $filter = $pfe->create(new Tinebase_Model_PersistentFilter(array('account_id' => $account->getId(), 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Courses')->getId(), 'model' => 'Courses_Model_CourseFilter', 'name' => "My course", 'description' => "My course", 'filters' => array(array('field' => 'is_deleted', 'operator' => 'equals', 'value' => '0'), array('field' => 'name', 'operator' => 'equals', 'value' => $course->name))))); if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) { Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Created default filter for teacher ' . $account->accountLoginName . ': ' . print_r($filter->toArray(), true)); } // set as default $pref = new Courses_Preference(); $pref->setValueForUser(Courses_Preference::DEFAULTPERSISTENTFILTER, $filter->getId(), $account->getId(), TRUE); }
/** * calendar has different grant handling * @see 0007450: shared calendars of other users (iOS) */ public function testGetAllFoldersWithContainerSyncFilter() { $device = $this->_getDevice(Syncroton_Model_Device::TYPE_IPHONE); $controller = Syncroton_Data_Factory::factory($this->_class, $device, new Tinebase_DateTime(null, null, 'de_DE')); $folderA = $this->testCreateFolder(); // personal of test user $sclever = Tinebase_Helper::array_value('sclever', Zend_Registry::get('personas')); $folderB = Tinebase_Core::getPreference('Calendar')->getValueForUser(Calendar_Preference::DEFAULTCALENDAR, $sclever->getId()); // have syncGerant for sclever Tinebase_Container::getInstance()->setGrants($folderB, new Tinebase_Record_RecordSet('Tinebase_Model_Grants', array(array('account_id' => $sclever->getId(), 'account_type' => 'user', Tinebase_Model_Grants::GRANT_ADMIN => true), array('account_id' => Tinebase_Core::getUser()->getId(), 'account_type' => 'user', Tinebase_Model_Grants::GRANT_READ => true, Tinebase_Model_Grants::GRANT_SYNC => true))), TRUE); $syncFilter = new Calendar_Model_EventFilter(array(array('field' => 'container_id', 'operator' => 'in', 'value' => array($folderA->serverId, $folderB)))); $syncFavorite = Tinebase_PersistentFilter::getInstance()->create(new Tinebase_Model_PersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), 'account_id' => Tinebase_Core::getUser()->getId(), 'model' => 'Calendar_Model_EventFilter', 'filters' => $syncFilter, 'name' => 'testSyncFilter', 'description' => 'test two folders'))); $device->calendarfilterId = $syncFavorite->getId(); $allSyncrotonFolders = $controller->getAllFolders(); $defaultFolderId = Tinebase_Core::getPreference('Calendar')->{Calendar_Preference::DEFAULTCALENDAR}; foreach ($allSyncrotonFolders as $syncrotonFolder) { $this->assertTrue($syncrotonFolder->serverId == $defaultFolderId ? $syncrotonFolder->type === Syncroton_Command_FolderSync::FOLDERTYPE_CALENDAR : $syncrotonFolder->type === Syncroton_Command_FolderSync::FOLDERTYPE_CALENDAR_USER_CREATED); } $this->assertEquals(2, count($allSyncrotonFolders)); $this->assertArrayHasKey($folderA->serverId, $allSyncrotonFolders); $this->assertArrayHasKey($folderB, $allSyncrotonFolders); }
/** * testCurrentAccountValue: checks if organizer is "magic word" Tinebase_Model_User::CURRENTACCOUNT * * @see 0011090: Aufgaben - Favoriten - Falscher Verantwortlicher */ public function testCurrentAccountValue() { // look at default task favorites: currentAccount should be set as value foreach (array('My open tasks', 'All tasks for me') as $filterName) { $filter = new Tinebase_Model_PersistentFilterFilter(array(array('field' => 'name', 'operator' => 'equals', 'value' => $filterName), array('field' => 'application_id', 'operator' => 'equals', 'value' => Tinebase_Application::getInstance()->getApplicationById('Tasks')->getId()))); $result = Tinebase_PersistentFilter::getInstance()->search($filter)->getFirstRecord(); $this->assertTrue($result !== null); $filters = $result->toArray(); $filters = $filters['filters']; $this->assertEquals(Tinebase_Model_User::CURRENTACCOUNT, $filters[0]['value'], print_r($filters, true)); } }
/** * test delete (and if prefs are removed */ public function testDeleteFilter() { $filter = $this->testSaveFilter(); Tinebase_Core::getPreference('Tasks')->{Tinebase_Preference_Abstract::DEFAULTPERSISTENTFILTER} = $filter['id']; $this->_uit->deletePersistentFilters(array($filter['id'])); $this->assertNotEquals(Tinebase_Core::getPreference('Tasks')->{Tinebase_Preference_Abstract::DEFAULTPERSISTENTFILTER}, $filter['id']); $this->setExpectedException('Tinebase_Exception_NotFound'); Tinebase_PersistentFilter::getInstance()->get($filter['id']); }
/** * testTeacherDefaultFavorite * * @see 0006876: create "my course" default favorite for new teachers */ public function testTeacherDefaultFavorite() { $course = $this->_getCourseData(); $courseData = $this->_json->saveCourse($course); $this->_groupsToDelete->addRecord(Tinebase_Group::getInstance()->getGroupById($courseData['group_id'])); $teacher = Tinebase_User::getInstance()->getFullUserById($courseData['members'][0]['id']); $filter = Tinebase_PersistentFilter::getInstance()->getFilterById(Tinebase_Core::getPreference('Courses')->getValueForUser(Courses_Preference::DEFAULTPERSISTENTFILTER, $teacher->getId())); $this->assertEquals(array(array('field' => 'name', 'operator' => 'equals', 'value' => $course['name'])), $filter->toArray()); }
/** * update to 3.11 * - add more default favorites */ public function update_10() { $pfe = Tinebase_PersistentFilter::getInstance(); $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->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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'); }
/** * 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); } }
/** * test search for preferences for anyone of calendar * * @see http://forge.tine20.org/mantisbt/view.php?id=5298 */ public function testSearchCalendarPreferencesForAnyone() { $tasksPersistentFilter = Tinebase_PersistentFilter::getInstance()->getPreferenceValues('Tasks', Tinebase_Core::getUser()->getId()); $json = new Tinebase_Frontend_Json(); $filter = $this->_getPreferenceFilter(NULL, Tinebase_Acl_Rights::ACCOUNT_TYPE_ANYONE); $result = $json->searchPreferencesForApplication('Tasks', $filter->toArray()); $prefData = $result['results']; $prefToSave = array(); foreach ($prefData as $pref) { if ($pref['name'] === Tasks_Preference::DEFAULTPERSISTENTFILTER) { $prefToSave[$pref['id']] = array('name' => Tasks_Preference::DEFAULTPERSISTENTFILTER, 'value' => $tasksPersistentFilter[5][0], 'type' => Tinebase_Model_Preference::TYPE_ADMIN); } } Tinebase_Core::getPreference('Tasks')->saveAdminPreferences($prefToSave); $result = $json->searchPreferencesForApplication('Calendar', $filter->toArray()); $this->assertGreaterThan(0, $result['totalcount']); $filterPref = NULL; foreach ($result['results'] as $pref) { if ($pref['name'] === Calendar_Preference::DEFAULTPERSISTENTFILTER) { $filterPref = $pref; } } $this->assertTrue($filterPref !== NULL); $this->assertEquals(Tinebase_Application::getInstance()->getApplicationByName('Calendar')->getId(), $filterPref['application_id'], print_r($filterPref, TRUE)); }
/** * create favorites */ protected function _initializeFavorites() { $pfe = Tinebase_PersistentFilter::getInstance(); $commonValues = array('account_id' => NULL, 'application_id' => Tinebase_Application::getInstance()->getApplicationByName('Addressbook')->getId(), 'model' => 'Addressbook_Model_ContactFilter'); $pfe->createDuringSetup(new Tinebase_Model_PersistentFilter(array_merge($commonValues, array('name' => Addressbook_Preference::DEFAULTPERSISTENTFILTER_NAME, 'description' => "All contacts I have read grants for", 'filters' => array())))); $pfe->createDuringSetup(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->createDuringSetup(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->createDuringSetup(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)))))); }
/** * testUpdatePersistentFilterIdsAndLabel * -> id should not be saved, label must be saved */ public function testUpdatePersistentFilterIdsAndLabel() { $favoriteId = Tinebase_PersistentFilter::getInstance()->getPreferenceValues('Projects', NULL, 'All my projects'); $favorite = Tinebase_PersistentFilter::getInstance()->get($favoriteId); $this->assertTrue($favorite->filters instanceof Tinebase_Model_Filter_FilterGroup); $favorite->name = 'testfilter'; unset($favorite->id); // add filter with id and label $favorite->filters->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'title', 'operator' => 'equals', 'value' => 'lala', 'id' => 'somenonpersistentid', 'label' => 'somepersistentlabel'))); $updatedFilter = Tinebase_PersistentFilter::getInstance()->create($favorite); $filterArray = $updatedFilter->filters->toArray(); $this->assertEquals('somepersistentlabel', $filterArray[2]['label']); $this->assertTrue(!isset($filterArray[2]['id'])); }