示例#1
0
 /**
  * Overload the __getter so that it checks for data in the following order
  * 1) Pull From db/cache (Cii::getConfig now does caching of elements for improved performance) for global/user config
  * 2) Check for __protected__ property, which we consider the default vlaue
  * 3) parent::__get()
  *
  * In order for this to work with __default__ values, the properties in classes that extend from this
  * MUST be protected. If they are public it will bypass this behavior.
  * 
  * @param  mixed $name The variable name we want to retrieve from the calling class
  * @return mixed
  */
 public function __get($name)
 {
     if (strpos($name, 'global_') !== false) {
         $data = Cii::getConfig(get_class($this) . '_' . $name);
     } else {
         $data = Cii::getUserConfig($this->id . '_' . $name);
     }
     if ($data !== NULL && $data !== "" && !isset($this->attributes[$name])) {
         return $data;
     }
     if (property_exists($this, $name)) {
         return $this->{$name};
     }
     return parent::__get($name);
 }
示例#2
0
 /**
  * Loads the user information
  */
 public static function loadUserInfo()
 {
     if (defined('CIIMS_INSTALL')) {
         return;
     }
     if (isset(Yii::app()->user)) {
         // Load some specific CiiMS JS here
         $json = CJSON::encode(array('email' => Cii::get(Yii::app()->user, 'email'), 'token' => Cii::getUserConfig('api_key', false), 'role' => Cii::get(Yii::app()->user, 'role'), 'isAuthenticated' => isset(Yii::app()->user->id), 'debug' => YII_DEBUG, 'time' => time(), 'version' => YII_DEBUG ? Cii::getVersion() : null, 'language' => Cii::setApplicationLanguage(), 'hosted' => defined('CII_CONFIG'), 'api' => Yii::app()->getBaseUrl(true) . '/api'));
         Yii::app()->clientScript->registerScript('ciims', "\n                localStorage.setItem('ciims', '{$json}');\n            ", CClientScript::POS_HEAD);
     }
 }