Esempio n. 1
0
 /**
  * sync Global Settings and current workflow Settings
  *
  * @param int $id
  */
 public function actionSync($workflowId)
 {
     $current = SettingParam::model()->findAll('workflow_id=:workflow_id', array(':workflow_id' => $workflowId));
     $criteria = new CDbCriteria();
     $criteria->addCondition('workflow_id = 0 OR workflow_id IS NULL');
     if (count($current)) {
         $current = CHtml::listData($current, 'name', 'name');
         $criteria->addNotInCondition('name', $current);
     }
     $new = SettingParam::model()->findAll($criteria);
     $this->result = count($new);
     if ($this->result) {
         /** @var SettingParam $model */
         foreach ($new as $model) {
             $setting = new SettingParam();
             $setting->attributes = $model->attributes;
             $setting->workflow_id = $workflowId;
             if (!$setting->save(false)) {
                 Yii::log(CVarDumper::dumpAsString($setting->getErrors()), CLogger::LEVEL_ERROR, 'Xpress.Api.Settings');
             }
         }
     }
 }
Esempio n. 2
0
 /**
  * copy param value of workflow to default param or to other workflow
  *
  * @param array $attrs
  * @param int $workflowId
  */
 public function actionSyncValue(array $attrs, $workflowId = 0)
 {
     Yii::import('Cms.models.*');
     $criteria = new CDbCriteria();
     $criteria->compare('workflow_id', $workflowId);
     $criteria->compare('name', $attrs['name']);
     $criteria->compare('module', $attrs['module']);
     $model = SettingParam::model()->find($criteria);
     if (is_object($model)) {
         //            echo 'Update';
         $model->value = $attrs['value'];
         $model->visible = $attrs['visible'];
         $model->module = $attrs['module'];
         $model->customizable = $attrs['customizable'];
         $model->description = $attrs['description'];
         $model->label = $attrs['label'];
         $model->setting_group = $attrs['setting_group'];
         $model->ordering = $attrs['ordering'];
     } else {
         //            echo 'New';
         $model = new SettingParam();
         $model->attributes = $attrs;
         $model->workflow_id = $workflowId;
     }
     if (!$model->save(false)) {
         return errorHandler()->logException($model, 0, 'XPRESS_SETTING_PARAMS_ERR_SYNC_FAILED', array('message' => 'Copy param failed'));
     }
     return $this->result = $model;
 }