コード例 #1
0
 /**
  * returns registry data of PersistentFilter.
  *
  * @return array
  */
 public static function getAllPersistentFilters()
 {
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $obj = new Tinebase_Frontend_Json_PersistentFilter();
         // return only filters of activated apps
         $applicationIds = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->getArrayOfIds();
         return $obj->searchPersistentFilter(array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()), array('field' => 'application_id', 'operator' => 'in', 'value' => $applicationIds)), NULL);
     }
 }
 /**
  * returns registry data of PersistentFilter.
  *
  * @return array
  */
 public static function getAllPersistentFilters()
 {
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $obj = new Tinebase_Frontend_Json_PersistentFilter();
         // return only filters of activated apps
         $applicationIds = Tinebase_Application::getInstance()->getApplicationsByState(Tinebase_Application::ENABLED)->getArrayOfIds();
         $filterArray = array(array('field' => 'account_id', 'operator' => 'equals', 'value' => Tinebase_Core::getUser()->getId()), array('field' => 'application_id', 'operator' => 'in', 'value' => $applicationIds));
         if (Tinebase_Core::isLogLevel(Zend_Log::INFO)) {
             Tinebase_Core::getLogger()->info(__METHOD__ . '::' . __LINE__ . ' Fetching all filters of user ' . Tinebase_Core::getUser()->accountLoginName);
         }
         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($filterArray, true));
         }
         return $obj->searchPersistentFilter($filterArray, NULL);
     }
     return array();
 }
コード例 #3
0
 /**
  * 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']);
 }
 /**
  * testFilterResolving
  * 
  * -> relations should not be resolved here!
  */
 public function testFilterResolving()
 {
     $contact1 = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact(array('n_family' => 'test heini')));
     $contactWithRelations = array('n_family' => 'test typ', 'relations' => array(array('own_model' => 'Addressbook_Model_Contact', 'own_backend' => 'Sql', 'own_id' => 0, 'own_degree' => Tinebase_Model_Relation::DEGREE_SIBLING, 'type' => '', 'related_backend' => 'Sql', 'related_id' => $contact1->getId(), 'related_model' => 'Addressbook_Model_Contact', 'remark' => NULL)));
     $contact2 = Addressbook_Controller_Contact::getInstance()->create(new Addressbook_Model_Contact($contactWithRelations));
     $exampleFilterData = self::getPersistentFilterData();
     $exampleFilterData['filters'] = array(array('field' => 'foreignRecord', 'operator' => 'AND', 'value' => array('appName' => 'Addressbook', 'modelName' => 'Contact', 'linkType' => 'relation', 'filters' => array(array('field' => ':id', 'operator' => 'equals', 'value' => $contact2->getId())))));
     $savedFilterData = $this->_uit->savePersistentFilter($exampleFilterData);
     $filterData = array(array('field' => 'model', 'operator' => 'equals', 'value' => 'Tasks_Model_TaskFilter'), array('field' => 'id', 'operator' => 'equals', 'value' => $savedFilterData['id']));
     $searchResult = $this->_uit->searchPersistentFilter($filterData, NULL);
     $this->assertEquals(1, $searchResult['totalcount']);
     $this->assertTrue(isset($searchResult['results'][0]['filters'][0]['value']['filters'][0]['value']));
     $filterContact = $searchResult['results'][0]['filters'][0]['value']['filters'][0]['value'];
     $this->assertTrue(!isset($filterContact['relations']), 'relations should not be resolved:' . print_r($filterContact, true));
 }
コード例 #5
0
 /**
  * Returns registry data of tinebase.
  * @see Tinebase_Application_Json_Abstract
  *
  * @return mixed array 'variable name' => 'data'
  */
 public function getRegistryData()
 {
     $locale = Tinebase_Core::get('locale');
     $tbFrontendHttp = new Tinebase_Frontend_Http();
     // default credentials
     if (isset(Tinebase_Core::getConfig()->login)) {
         $loginConfig = Tinebase_Core::getConfig()->login;
         $defaultUsername = isset($loginConfig->username) ? $loginConfig->username : '';
         $defaultPassword = isset($loginConfig->password) ? $loginConfig->password : '';
     } else {
         $defaultUsername = '';
         $defaultPassword = '';
     }
     $registryData = array('serviceMap' => $tbFrontendHttp->getServiceMap(), 'timeZone' => Tinebase_Core::get(Tinebase_Core::USERTIMEZONE), 'locale' => array('locale' => $locale->toString(), 'language' => Zend_Locale::getTranslation($locale->getLanguage(), 'language', $locale), 'region' => Zend_Locale::getTranslation($locale->getRegion(), 'country', $locale)), 'version' => array('buildType' => TINE20_BUILDTYPE, 'codeName' => TINE20_CODENAME, 'packageString' => TINE20_PACKAGESTRING, 'releaseTime' => TINE20_RELEASETIME, 'filesHash' => TINE20_BUILDTYPE != 'DEVELOPMENT' ? $tbFrontendHttp->getJsCssHash() : null), 'defaultUsername' => $defaultUsername, 'defaultPassword' => $defaultPassword, 'denySurveys' => Tinebase_Core::getConfig()->denySurveys, 'titlePostfix' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::PAGETITLEPOSTFIX, NULL, '')->value, 'redirectUrl' => Tinebase_Config::getInstance()->getConfig(Tinebase_Model_Config::REDIRECTURL, NULL, '')->value, 'maxFileUploadSize' => convertToBytes(ini_get('upload_max_filesize')), 'maxPostSize' => convertToBytes(ini_get('post_max_size')));
     if (Tinebase_Core::isRegistered(Tinebase_Core::USER)) {
         $user = Tinebase_Core::getUser();
         $userContactArray = array();
         if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
             try {
                 $userContactArray = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), TRUE)->toArray();
             } catch (Addressbook_Exception_NotFound $aenf) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                     Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User not found in Addressbook: ' . $user->accountDisplayName);
                 }
             }
         }
         $registryData += array('currentAccount' => $user->toArray(), 'userContact' => $userContactArray, 'accountBackend' => Tinebase_User::getConfiguredBackend(), 'jsonKey' => Tinebase_Core::get('jsonKey'), 'userApplications' => $user->getApplications()->toArray(), 'NoteTypes' => $this->getNoteTypes(), 'stateInfo' => Tinebase_State::getInstance()->loadStateInfo(), 'changepw' => Tinebase_User::getBackendConfiguration('changepw', true), 'mustchangepw' => $user->mustChangePassword(), 'mapPanel' => Tinebase_Config::getInstance()->getConfig(Tinebase_Config::MAPPANEL, NULL, TRUE)->value, 'confirmLogout' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::CONFIRM_LOGOUT, 1), 'persistentFilters' => Tinebase_Frontend_Json_PersistentFilter::getAllPersistentFilters(), 'messenger' => $this->getMessengerConfig());
     }
     return $registryData;
 }
コード例 #6
0
 /**
  * get user registry
  * 
  * @return array
  */
 protected function _getUserRegistryData()
 {
     $user = Tinebase_Core::getUser();
     $userContactArray = array();
     if (Tinebase_Application::getInstance()->isInstalled('Addressbook') === true) {
         try {
             $userContactArray = Addressbook_Controller_Contact::getInstance()->getContactByUserId($user->getId(), TRUE)->toArray();
         } catch (Addressbook_Exception_NotFound $aenf) {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
                 /** @noinspection PhpUndefinedMethodInspection */
                 Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . ' User not found in Addressbook: ' . $user->accountDisplayName);
             }
         }
     }
     try {
         $persistentFilters = Tinebase_Frontend_Json_PersistentFilter::getAllPersistentFilters();
     } catch (Tinebase_Exception_NotFound $tenf) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Failed to fetch persistent filters. Exception: \n" . $tenf);
         }
         $persistentFilters = array();
     } catch (Exception $e) {
         if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) {
             Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__ . " Failed to fetch persistent filters. Exception: \n" . $e);
         }
         $persistentFilters = array();
     }
     $userRegistryData = array('timeZone' => Tinebase_Core::getUserTimezone(), 'currentAccount' => $user->toArray(), 'userContact' => $userContactArray, 'accountBackend' => Tinebase_User::getConfiguredBackend(), 'jsonKey' => Tinebase_Core::get('jsonKey'), 'userApplications' => $user->getApplications()->toArray(), 'NoteTypes' => $this->getNoteTypes(), 'stateInfo' => Tinebase_State::getInstance()->loadStateInfo(), 'mustchangepw' => $user->mustChangePassword(), 'confirmLogout' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::CONFIRM_LOGOUT, 1), 'advancedSearch' => Tinebase_Core::getPreference()->getValue(Tinebase_Preference::ADVANCED_SEARCH, 0), 'persistentFilters' => $persistentFilters, 'userAccountChanged' => Tinebase_Controller::getInstance()->userAccountChanged());
     if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
         Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' User registry: ' . print_r($userRegistryData, TRUE));
     }
     return $userRegistryData;
 }
コード例 #7
0
 /**
  * try to search timesheets with saved persistent filter id
  *
  * @todo move this test to tinebase json tests?
  */
 public function testSearchTimesheetsWithPersistentFilter()
 {
     $persistentFiltersJson = new Tinebase_Frontend_Json_PersistentFilter();
     $tsFilter = $this->_getTimesheetFilter();
     // create
     $filterName = Tinebase_Record_Abstract::generateUID();
     $persistentFiltersJson->savePersistentFilter(array('application_id' => Tinebase_Application::getInstance()->getApplicationById('Timetracker')->getId(), 'filters' => $tsFilter, 'name' => $filterName, 'model' => 'Timetracker_Model_TimesheetFilter'));
     $timesheet = $this->_getTimesheet();
     $timesheetData = $this->_json->saveTimesheet($timesheet->toArray());
     // search persistent filter
     $persistentFilters = $persistentFiltersJson->searchPersistentFilter($this->_getPersistentFilterFilter($filterName), NULL);
     //check
     $search = $this->_json->searchTimesheets($persistentFilters['results'][0]['id'], $this->_getPaging());
     $this->assertEquals($timesheet->description, $search['results'][0]['description']);
     $this->assertEquals('array', gettype($search['results'][0]['timeaccount_id']), 'timeaccount_id is not resolved');
     $this->assertEquals('array', gettype($search['results'][0]['account_id']), 'account_id is not resolved');
     $this->assertEquals(1, $search['totalcount']);
     $this->assertEquals(30, $search['totalsum']);
     $this->assertEquals($tsFilter, $search['filter'], 'filters do not match');
     // cleanup / delete file
     $persistentFiltersJson->deletePersistentFilters($persistentFilters['results'][0]['id']);
 }