/**
  * Short Description.
  *
  * @return void
  */
 public function actionEdit()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     $model = Configuration::model()->findAllByAttributes(array('configuration_type_id' => $id), array('order' => 'sort_order'));
     if ($this->IsCloud) {
         $model = $this->sanitizeEditModule($model, 'Cloud');
     }
     if ($this->IsMT) {
         $model = $this->sanitizeEditModule($model, 'MT');
     }
     if ($this->isHosted) {
         $model = $this->sanitizeEditModule($model, 'Hosted');
     }
     if (isset($_POST['Configuration'])) {
         $valid = true;
         foreach ($model as $i => $item) {
             if (isset($_POST['Configuration'][$i])) {
                 $item->attributes = $_POST['Configuration'][$i];
             }
             if ($item->key_name == 'LANG_MENU' && $item->key_value == 1) {
                 $itemLanguages = $model[2];
                 $itemLanguages->attributes = $_POST['Configuration'][2];
                 if (empty($itemLanguages->key_value)) {
                     $valid = false;
                 }
             }
             if ($item->options == "INT") {
                 if ((int) $item->key_value) {
                     $valid = true;
                 } else {
                     $valid = false;
                 }
             }
             if ($item->options == "EMAIL") {
                 $valid = $this->validateEmail($item) && $valid;
             } else {
                 $valid = $item->validate() && $valid;
             }
             if (!$valid) {
                 if ($item->options == 'EMAIL') {
                     Yii::app()->user->setFlash('error', $item->title . ' is not a valid email address');
                 } elseif ($item->key_name == 'LANG_MENU') {
                     Yii::app()->user->setFlash('error', 'Languages field cannot be empty when language menu is enabled');
                 } elseif ($item->options == "INT") {
                     Yii::app()->user->setFlash('error', $item->title . ': ' . 'Only numbers are allowed', true);
                 } else {
                     $err = $item->getErrors();
                     Yii::app()->user->setFlash('error', $item->title . ' -- ' . print_r($err['key_value'][0], true));
                 }
                 break;
             }
         }
         if ($valid) {
             foreach ($model as $i => $item) {
                 $item->attributes = $_POST['Configuration'][$i];
                 if ($item->options == "PASSWORD") {
                     $item->key_value = _xls_encrypt($item->key_value);
                 }
                 if ($item->save() === false) {
                     Yii::app()->user->setFlash('error', print_r($item->getErrors(), true));
                 } else {
                     Yii::app()->user->setFlash('success', Yii::t('admin', 'Configuration updated on {time}.', array('{time}' => date('d F, Y  h:i:sa'))));
                     $item->postConfigurationChange();
                 }
                 if ($item->key_name == 'EMAIL_TEST' && $item->key_value == 1) {
                     $this->sendEmailTest();
                 }
             }
         }
     }
     foreach ($model as $i => $item) {
         if ($item->options == 'BOOL') {
             $this->registerOnOff($item->id, "Configuration_{$i}_key_value", $item->key_value);
         }
         if ($item->options == 'PASSWORD') {
             $model[$i]->key_value = _xls_decrypt($model[$i]->key_value);
         }
         $model[$i]->title = Yii::t('admin', $item->title, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
         $model[$i]->helper_text = Yii::t('admin', $item->helper_text, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
     }
     /*
      * http://www.yiiframework.com/doc/api/1.1/CModel#generateAttributeLabel-detail
      *
      * Unless we define the label attribute in activeLabelEx htmlOptions in the view,
      * the label will be generated when it calls CModel::generateAttributeLabel().
      * This is a problem for the labels we want to display on pages like the Google Integration
      * page that have labels which deliberately require dashes and camel-case formatting.
      */
     $defineLabel = false;
     switch (CPropertyValue::ensureInteger($id)) {
         case 20:
             // IntegrationController::GOOGLE = 20
             $defineLabel = true;
             break;
         default:
             break;
     }
     $this->render('admin.views.default.edit', array('model' => $model, 'defineLabel' => $defineLabel));
 }
Example #2
0
<div class="span9">
	<div class="hero-unit nobottom">

		<h3><?php 
echo Yii::t('admin', 'Manage My Themes');
?>
</h3>
		<div class="editinstructions">
			<?php 
if (Yii::app()->getRequest()->getQuery('n')) {
    echo "<h4>" . Yii::t('admin', 'Your current theme has an update available. Click Upgrade Theme below the icon to download the latest version.') . "</h4> ";
}
echo Yii::t('admin', '<p>Choose the theme you wish to use by selecting the graphic and clicking Make Active to switch to the theme. Change options for the currently active theme below the image. Your currently active theme is always listed first.</p>', array('{color}' => _xls_regionalize('color')));
echo Yii::t('admin', '<p>You can also Preview any theme by clicking the relevant <strong>Preview</strong> link.</p>');
?>
		</div>
		<div class="clearfix spaceafter"></div>
		<div id="thememanage">
			<?php 
echo CHtml::beginForm('manage', 'post', array('id' => 'manage'));
?>


			<?php 
echo CHtml::hiddenField('task', '', array('id' => 'task'));
foreach ($arrThemes as $key => $objTheme) {
    echo '<div class="span4 theme"><div class="themetitle">' . $objTheme['name'] . '</div><div class="themeversion">' . $objTheme['version'] . $objTheme['beta'] . '</div><div class="clearfix"></div><div class="themeselect" >';
    echo CHtml::radioButton('theme', $key == $currentTheme ? true : false, array('id' => $key, 'value' => $key));
    echo '</div>';
    echo CHtml::tag('div', array('class' => 'themeicon ' . ($key == $currentTheme ? "selected" : ""), 'id' => 'img' . $key, 'onClick' => 'js:
									$("#"+picked).attr("checked", false);
 public function actionEdit()
 {
     $id = Yii::app()->getRequest()->getQuery('id');
     $model = Configuration::model()->findAllByAttributes(array('configuration_type_id' => $id), array('order' => 'sort_order'));
     if (isset($_POST['Configuration'])) {
         $valid = true;
         foreach ($model as $i => $item) {
             if (isset($_POST['Configuration'][$i])) {
                 $item->attributes = $_POST['Configuration'][$i];
             }
             $valid = $item->validate() && $valid;
             if (!$valid) {
                 $err = $item->getErrors();
                 Yii::app()->user->setFlash('error', $item->title . " -- " . print_r($err['key_value'][0], true));
                 break;
             }
         }
         if ($valid) {
             foreach ($model as $i => $item) {
                 $item->attributes = $_POST['Configuration'][$i];
                 if ($item->options == "PASSWORD") {
                     $item->key_value = _xls_encrypt($item->key_value);
                 }
                 if (!$item->save()) {
                     Yii::app()->user->setFlash('error', print_r($item->getErrors(), true));
                 } else {
                     $item->postConfigurationChange();
                 }
                 if ($item->key_name == 'EMAIL_TEST' && $item->key_value == 1) {
                     $this->sendEmailTest();
                 }
             }
             Yii::app()->user->setFlash('success', Yii::t('admin', 'Configuration updated on {time}.', array('{time}' => date("d F, Y  h:i:sa"))));
         }
     }
     foreach ($model as $i => $item) {
         if ($item->key_name == "EMAIL_TEST") {
             $item->key_value = 0;
         }
         if ($item->options == "BOOL") {
             $this->registerOnOff($item->id, "Configuration_{$i}_key_value", $item->key_value);
         }
         if ($item->options == "PASSWORD") {
             $model[$i]->key_value = _xls_decrypt($model[$i]->key_value);
         }
         $model[$i]->title = Yii::t('admin', $item->title, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
         $model[$i]->helper_text = Yii::t('admin', $item->helper_text, array('{color}' => _xls_regionalize('color'), '{check}' => _xls_regionalize('check')));
     }
     $this->render('edit', array('model' => $model));
 }