예제 #1
0
파일: Theme.php 프로젝트: fandikurnia/CiiMS
 /**
  * AfterSave Event, is triggered when the model attributes are saved
  */
 public function afterSave()
 {
     // Bust the cache
     Yii::app()->cache->delete($this->theme . '_settings_tweets');
     Yii::app()->cache->delete($this->theme . '_settings_splashLogo');
     return parent::afterSave();
 }
예제 #2
0
 public function afterSave()
 {
     Yii::app()->cache->set('hybridauth_providers', false);
     Cii::getHybridAuthProviders();
     return parent::afterSave();
 }
예제 #3
0
 /**
  * Allow some override values
  * @return parent::beforeSave();
  */
 public function beforeSave()
 {
     if (($allow_api = Cii::get(Cii::getCiiConfig(), 'allow_api', true)) == false) {
         $this->attributes['enableAPI'] = $this->enableAPI = (int) $allow_api;
     }
     // Encrypt the Openstack API Key
     if ($this->attributes['openstack_apikey'] != NULL && $this->attributes['openstack_apikey'] != "") {
         $this->attributes['openstack_apikey'] = $this->openstack_apikey = Cii::encrypt($this->attributes['openstack_apikey']);
     }
     return parent::beforeSave();
 }
예제 #4
0
 /**
  * toggleButtonRow provides a checkbox with toggle support via purecss.io and prism.js
  * @param  CiiSettingsModel $model       The model that we are operating on
  * @param  string           $property    The name of the property we are working with
  * @param  array            $htmlOptions An array of HTML Options
  * @param  CValidator       $validators  The Validator(s) for this property
  *                                       Since we already have it, it's worth passing through
  */
 public function toggleButtonRow($model, $property, $htmlOptions = array(), $validators = NULL)
 {
     echo CHtml::tag('label', array(), $model->getAttributeLabel($property));
     echo CHtml::openTag('div', array('class' => Cii::get($htmlOptions, 'class', 'pure-input-2-3'), 'style' => 'display: inline-block'));
     echo CHtml::openTag('label', array('class' => 'switch-light switch-candy'));
     $checked = array();
     if ($model->{$property} == 1) {
         $checked = array('checked' => 'checked');
     }
     echo CHtml::openTag('input', CMap::mergeArray(array('type' => 'checkbox', 'id' => get_class($model) . '_' . $property, 'name' => get_class($model) . '[' . $property . ']', 'class' => Cii::get($htmlOptions, 'class', NULL), 'value' => '1'), $checked));
     echo CHtml::openTag('span');
     echo CHtml::tag('span', array(), 'Off');
     echo CHtml::tag('span', array(), 'On');
     echo CHtml::closeTag('span');
     echo CHtml::tag('a', array('class' => 'slide-button'), NULL);
     echo CHtml::closeTag('label');
     echo CHtml::closeTag('div');
 }
예제 #5
0
 public function afterSave()
 {
     Yii::app()->cache->set('analyticsjs_providers', false);
     Cii::getAnalyticsProviders();
     return parent::afterSave();
 }
예제 #6
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);
 }
예제 #7
0
 /**
  * Populates and saves model attributes
  * @param  $_POST $post            $_POST data
  * @param  CiiSettingsModel $model The model we want to populate
  * @return array                   The saved model attributes or an error message
  */
 private function loadData($post, &$model)
 {
     $model->populate($_POST, true);
     if ($model->save()) {
         return $this->getModelAttributes($model);
     }
     return $this->returnError(400, NULL, $model->getErrors());
 }