/** * 初期処理 * @access public * @param Object $contextt context * @return boolean 処理結果 */ public function initialize($context) { parent::initialize($context); /* 初期値をセットする */ $this->controller = $context->getController(); $this->request = $context->getRequest(); $this->user = $context->getUser(); $this->moduleName = $context->getModuleName(); $this->actionName = $context->getActionName(); $this->messages =& CommonMessages::getInstance(); /* フォーム登録リストのフォームをsmartyにすべてセットする */ $o_smarty =& $this->getEngine(); $o_smarty->register_object("style", $this, array("request", "checkErrorElement")); $this->quickformSmarty = new HTML_QuickForm_Renderer_ArraySmarty($this->getEngine()); $formList = $this->request->getAttribute('formList'); foreach ($formList as $formName) { $this->setForm($formName); } /* メッセージをsmartyにセットする */ if ($this->request->hasAttribute('messages')) { $messages =& $this->request->getAttribute('messages'); $messages = array_unique($messages); $this->setAttributeByRef('messages', $messages); } /* エラーメッセージをsmartyにセットする */ if ($this->request->hasErrors()) { $errors =& $this->request->getErrors(); $errors = array_unique($errors); $this->setAttributeByRef('errors', $errors); } // 共通の CSS をセット array_push($this->css_file_array, ACS_SELECTION_CSS_DIR . 'default.css'); $this->setAttribute('include_css_array', $this->css_file_array); // 共通の JS をセット array_push($this->js_file_array, ACS_JS_DIR . 'swap.js'); $this->setAttribute('include_script_array', $this->js_file_array); return true; }
public function save() { if (!$this->validate()) { return false; } if (!($info = Monc::app()->user->getState('info'))) { throw new RuntimeException('第二步的个人信息还没填写'); } $model = new Request(); $model->setAttributes($info); $model->setAttributes($this->getAttributes()); if (!$model->save()) { $this->addErrors($model->getErrors()); return false; } return true; }
/** * 新建消息 */ public function actionRequest() { $model = new Request(); if (isset($_POST['Request'])) { if (Question::model()->findByPk($_POST['Request']['question_id']) != NULL) { $model->question_id = $_POST['Request']['question_id']; } if (Question::model()->findByPk($_POST['Request']['to_user']) != NULL) { $model->to_user = $_POST['Request']['to_user']; } $model->user_name = $_POST['Request']['user_name']; $model->create_time = time(); $model->create_user = Yii::app()->user->id; $model->save(); echo CJSON::encode($model->getErrors()); } }