示例#1
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;
 }
 /**
  * save state and load it with registry data
  */
 public function testSaveAndGetState()
 {
     $testData = array('bla' => 'blubb', 'zzing' => 'zzang');
     foreach ($testData as $key => $value) {
         Tinebase_State::getInstance()->setState($key, $value);
     }
     $stateInfo = Tinebase_State::getInstance()->loadStateInfo();
     $this->assertEquals($testData, $stateInfo);
 }
 /**
  * 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;
 }
示例#4
0
 /**
  * save state and load it with registry data
  *
  * @todo save old state and recover it after the test
  */
 public function testSaveAndGetState()
 {
     $testData = array('bla' => 'blubb', 'zzing' => 'zzang');
     Tinebase_State::getInstance()->saveStateInfo($testData);
     $stateInfo = Tinebase_State::getInstance()->loadStateInfo();
     $this->assertEquals($testData, $stateInfo);
     //$registryData = $this->_instance->getAllRegistryData();
 }