/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * @param integer $id the ID of the model to be updated */ public function actionUpdate() { if (Yii::app()->request->IsPostRequest) { // save posted data $model = $this->postModel('UserGroup'); if ($this->post('ajax', '') == 'user-group-form') { $model->validate(); echo getJsonErrors($model); Yii::app()->end(); } $result = $this->api('XUser.UserGroup.save', array('attributes' => $model->attributes)); if (errorHandler()->getException() == null) { $this->message = Yii::t('XUser.UserGroup', 'Item has been saved successfully.'); $this->redirect($this->createUrl('update', array('id' => $result->id))); } } else { // show edit form $id = $this->get('id', 0); if ($id == 0) { $model = new UserGroup(); } else { $model = $this->api('XUser.UserGroup.get', array('id' => $id)); } /*if (! $model instanceof UserGroup) { $model = new UserGroup(); }*/ } if ($this->get('_popup', null) != '') { $this->layout = '//layouts/modal'; $this->render('_formModal', array('model' => $model)); } else { $this->render('update', array('model' => $model)); } }
/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. * * @param integer $id the ID of the model to be updated */ public function actionUpdate() { $workflow = Workflow::model()->findByPk($this->get('workflowId', 0)); if (Yii::app()->request->IsPostRequest) { $model = $this->postModel('SettingParam'); if ($this->post('ajax', '') == 'user-group-form') { $model->validate(); echo getJsonErrors($model); Yii::app()->end(); } $result = $this->api('Xpress.SettingParam.save', array('attributes' => $_POST['SettingParam'])); if (is_object($result)) { $model = $result; if (isset($_POST['sync_global'])) { $this->api('Xpress.SettingParam.syncValue', array('attrs' => $model->attributes)); //update cache file global $this->api('Xpress.Settings.db2php', array('module' => $model->module, 'path' => cachePath(true))); } if (isset($_POST['sync_other'])) { $this->api('Xpress.SettingParam.syncValueToOther', array('attrs' => $model->attributes)); } } if (errorHandler()->getException() == null) { $this->message = Yii::t('Admin.SettingParam', 'Item has been saved successfully.'); $this->redirect($this->createUrl('update', array('id' => $model->id, 'workflowId' => $workflow->id))); } } else { // show edit form $id = $this->get('id', 0); if ($id) { $model = $this->api('Xpress.SettingParam.get', array('id' => $id)); } if (!isset($model) || !$model instanceof SettingParam) { $model = new SettingParam(); $model->workflow_id = is_object($workflow) ? $workflow->id : 0; } } $modules = $model->getModules(); //remove sytem ~ '' empty module if (isset($modules['module_system'])) { unset($modules['module_system']); } $this->render('update', array('model' => $model, 'modules' => $modules, 'workflow' => $workflow)); }