/** * Creates a new model. * If creation is successful, the browser will be redirected to the 'view' page. */ public function actionCreate() { $this->addToolbar(); $model = new Mquestion(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Mquestion'])) { $model->attributes = $_POST['Mquestion']; $model->date_create = new CDbExpression('NOW()'); if ($model->save()) { $this->redirect(array('index')); } } $this->render('form', array('model' => $model)); }
public function run() { parent::run(); if (isset($_POST['submit_reply'])) { $id = $_POST['hid']; $model = new Mquestion(); $model->content = Yii::app()->request->getPost('content_reply', true); $model->parent = $_POST['hid']; $model->user_id = $this->_session['login_id']; $model->state = 0; if (Libraries::get_vip($model->user_id) != 0) { $model->state = 1; } $model->date_create = new CDbExpression('NOW()'); $model->save(); } $data['question'] = Mquestion::model()->findAll(array("condition" => "state = 1 and parent = 0 ", "order" => "date_create desc", "limit" => 1)); $data['u_log'] = $this->_session['login_id']; $this->render('member_question', $data); }
public function actionAjaxquestion() { $array['status'] = 0; if (isset($_POST['submit_reply'])) { $id = $_POST['hid']; $model = new Mquestion(); $model->content = Libraries::dataCleasing($_POST['content_reply']); $model->parent = $_POST['hid']; $model->user_id = $this->_session['login_id']; $model->state = Libraries::get_vip($model->user_id); $model->date_create = new CDbExpression('NOW()'); if ($model->save()) { $user = Member::model()->findByPk($model->user_id); $array['status'] = 1; $array['content'] = '<li><span class="name"><a href="' . Yii::app()->getBaseUrl(true) . '/thanh-vien/' . $model->user_id . '.html">' . $user->username . '</a>'; if ($user->premium == 1) { $array['content'] .= "<img src='" . Yii::app()->getBaseUrl(true) . "/themes/default/assets/img/vip_i.gif'>"; } $array['vip'] = $user->premium; $array['content'] .= '</span><p>' . $model->content . '</p></li>'; } } echo json_encode($array); }