/** * Updates a particular model. * If update is successful, the browser will be redirected to the 'view' page. */ public function actionUpdate() { $model = $this->loadModel(); $model->date = $model->viewDate(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (isset($_POST['Faq'])) { $model->attributes = $_POST['Faq']; if ($model->save()) { if (isset($_POST['savebutton'])) { $this->redirect($this->createUrl('index', array('msg' => '[!] Вопрос-ответ успешно обновлен', 'msgtype' => 'success', 'Faq_page' => $_GET['Faq_page']))); } else { if (isset($_POST['applybutton'])) { $this->redirect($this->createUrl('update', array('id' => $model->id, 'msg' => '[!] Вопрос-ответ успешно обновлен', 'msgtype' => 'success'))); } else { $model->is_answered = 1; $model->update(); $body = '<p><b>Вопрос:</b></p>'; $body .= '<p>' . $model->question . '</p>'; $body .= '<p><b>Ответ:</b></p>'; $body .= '<p>' . $model->answer . '</p>'; $mailer = new SwiftMailer(); $mailer->sendHtmlMail(array('noreply@' . Yii::app()->params['domain'] => Yii::app()->params['company']), $model->email, 'Ответ на Ваш вопрос на сайте ' . Yii::app()->params['domain'], $body, $attachments = array()); $this->redirect($this->createUrl('update', array('id' => $model->id, 'msg' => '[!] Вопрос-ответ успешно обновлен и ответ на вопрос отправлен на почту ' . $model->email, 'msgtype' => 'success'))); } } } else { $model->date = $model->viewDate(); } } $this->render('update', array('model' => $model)); }