/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $model = new SectionModel(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['SectionModel'])) { $model->attributes = $_POST['SectionModel']; if ($model->save()) { $this->redirect(array('view', 'id' => $model->id)); } } $this->render('create', array('model' => $model)); }
/** * Update any disable rules associated with this response. */ private function updateDisableRules() { if (!isset($this->parent)) { $this->parent = new QuestionModel(array('questionID' => $this->responseRow->questionID, 'depth' => 'question')); } $question = $this->parent; foreach ($question->prompts as $prompt) { foreach ($prompt['rules'] as $rule) { if ($prompt['promptID'] == $this->responseText) { if ($rule->enabled != 'Y') { $rule->enabled = 'Y'; $rule->save(); if (preg_match('/.+Page$/', $rule->type)) { $page = new PageModel(array('pageID' => $rule->targetID, 'depth' => 'question')); $page->save(); } elseif (preg_match('/.+Section$/', $rule->type)) { $section = new SectionModel(array('sectionID' => $rule->targetID, 'depth' => 'question')); $section->save(); } elseif (preg_match('/.+Question$/', $rule->type)) { $question = new QuestionModel(array('questionID' => $rule->targetID, 'depth' => 'question')); $question->save(); } } } else { if ($rule->enabled != 'N') { $rule->enabled = 'N'; $rule->save(); if (preg_match('/.+Page$/', $rule->type)) { $page = new PageModel(array('pageID' => $rule->targetID, 'depth' => 'question')); $page->save(); } elseif (preg_match('/.+Section$/', $rule->type)) { $section = new SectionModel(array('sectionID' => $rule->targetID, 'depth' => 'question')); $section->save(); } elseif (preg_match('/.+Question$/', $rule->type)) { $question = new QuestionModel(array('questionID' => $rule->targetID, 'depth' => 'question')); $question->save(); } } } } } }
/** * 单元 编辑后更新数据库 */ function update() { $section = new SectionModel(); if (!!($data = $section->create())) { if (!empty($data['id'])) { if (false !== $section->save()) { //同时更新menu_item里面的标题 $menu_item = M('MenuItem'); $title = $data['title']; $new_data = array('title' => $title); $new_where = array('type_id' => array('eq', $data['id']), 'type' => 'Section'); $bools = $menu_item->where($new_where)->save($new_data); if ($bools) { $this->assign('jumpUrl', __URL__ . '/index'); $this->success('更新成功'); } } else { $this->error('更新失败:' . $section->getDbError()); } } else { $this->error('请选择编辑用户'); } } else { $this->error('更新失败:( ' . $section->getError() . ' )'); } }