Example #1
0
 /**
  * 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));
 }
 function index()
 {
     if (isset($_POST['submitButton'])) {
         $l_oContactMail = new SwiftMailer();
         $l_oContactMail->subject = 'Contact request';
         $l_oContactMail->name = $_POST['form_name'];
         $l_oContactMail->email = $_POST['form_email'];
         $l_oContactMail->message = $_POST['form_msg'];
         $l_sStatus = $l_oContactMail->validate();
         if ($l_sStatus) {
             $this->view->errorMail = $l_sStatus;
         } else {
             $l_sStatus = $l_oContactMail->contact();
             if ($l_sStatus) {
                 $this->view->errorMail = 'We appologise, but we were unable to connect to our mail server. Please contact us directly at info@artaddict.eu';
             } else {
                 $this->view->successMail = 'Your message has been submitted';
             }
         }
         if (!empty($_POST['form_name']) && $l_sStatus) {
             $this->view->formName = $_POST['form_name'];
         }
         if (!empty($_POST['form_email']) && $l_sStatus) {
             $this->view->formEmail = $_POST['form_email'];
         }
         if (!empty($_POST['form_msg']) && $l_sStatus) {
             $this->view->formMsg = $_POST['form_msg'];
         }
     }
     if (isset($_POST['signUpBtn'])) {
         $this->email();
     }
     $this->view->details = $this->model->getDetails();
     $this->view->title = 'Contact';
     $this->view->page = 'contact';
     $this->view->background = 'bg7.jpg';
     $this->view->artists = $this->model->aristList();
     $this->view->js = array("base", "mobNav", "google-analytics");
     $this->view->render('front/header');
     $this->view->render('front/navigation');
     $this->view->render('contact/index');
     $this->view->render('front/footer');
 }
 function sendEmail()
 {
     $l_oContactMail = new SwiftMailer();
     $l_oContactMail->subject = 'Product enquiry - ' . $_POST['form_subject'];
     $l_oContactMail->name = $_POST['form_name'];
     $l_oContactMail->email = $_POST['form_email'];
     $l_oContactMail->message = $_POST['form_msg'];
     $l_sStatus = $l_oContactMail->validate();
     if (!$l_sStatus) {
         $l_sStatus = $l_oContactMail->contact();
         if ($l_sStatus) {
             print json_encode(array('msg' => 'We appologise, but we were unable to connect to our mail server. Please contact us directly at annick@artaddict.eu'));
         } else {
             print json_encode(array('msg' => 'Your message has been submitted'));
         }
     } else {
         print json_encode(array('msg' => $l_sStatus));
     }
 }
 /**
  * Class constructor.
  * @param EmailMessage $emailMessage
  * @param EmailAccount $emailAccount
  */
 public function __construct(EmailMessage $emailMessage, $emailAccount)
 {
     parent::init();
     $this->emailAccount = $emailAccount;
     $this->emailMessage = $emailMessage;
     $this->populateSettings();
     $this->populateMessage();
 }