Example #1
0
 /**
  * Sends a message
  *
  * @param mixed $to
  * @param mixed $subject
  * @param string $body
  *
  * @return int
  */
 public function send($to, $subject, $body)
 {
     $result = 0;
     if ($callbackOptions = CallbackConfig::model()->find() and $callbackOptions->enabled) {
         $options = array();
         $emailFrom = null;
         if ($callbackOptions->type == 'smtp') {
             $options['host'] = $callbackOptions->host;
             $options['username'] = $callbackOptions->username;
             $options['password'] = $callbackOptions->password;
             if ($callbackOptions->port) {
                 $options['port'] = $callbackOptions->port;
             }
             if ($callbackOptions->encryption) {
                 $options['encryption'] = $callbackOptions->encryption;
             }
             $emailFrom = $callbackOptions->username;
         } else {
             $admin = CallbackConfig::model()->findByPk(1);
             $emailFrom = $admin->email;
         }
         parent::setTransportOptions($callbackOptions->type, $options);
         $from = array($emailFrom => $callbackOptions->sender);
         $result = parent::send($from, $to, $subject, $body);
     }
     return $result;
 }
Example #2
0
 /**
  * Edits callback config
  */
 public function actionIndex()
 {
     $model = CallbackConfig::model()->find();
     if (isset($_POST['CallbackConfig'])) {
         $model->attributes = $_POST['CallbackConfig'];
         if ($model->save()) {
             Yii::app()->user->setFlash('success', "Изменения успешно сохранены!");
         }
     }
     $this->render('form', array('model' => $model));
 }
Example #3
0
 /**
  * Returns form for phoneback request
  *
  * @throws CException
  */
 public function actionPhoneback()
 {
     $this->metaInfoGenerate('Просьба перезвонить', '', '');
     $this->breadcrumbs[] = 'Просьба перезвонить';
     $model = new PhonebackForm();
     if (isset($_POST['PhonebackForm'])) {
         $model->attributes = $_POST['PhonebackForm'];
         if ($model->validate()) {
             $admin = CallbackConfig::model()->findByPk(1);
             $body = $this->renderPartial('phoneback_template', array_merge(array('model' => $model)), true);
             if ($this->module->sendMessage($admin->email, 'Просьба перезвонить ' . Yii::app()->config->sitename, $body)) {
                 Yii::app()->user->setFlash('callback_message', 'Сообщение отправлено.');
             } else {
                 Yii::app()->user->setFlash('callback_message', 'В данный момент отправка сообщений невозможна.');
             }
             $this->refresh();
         }
     }
     $this->render('phoneback', array('model' => $model));
 }
Example #4
0
             <?php 
 echo $form->textField($model, 'email', array('placeholder' => $model->getAttributeLabel('email') . ' *'));
 ?>
         </div>
         <div class="row">
             <?php 
 echo $form->textField($model, 'phone', array('placeholder' => $model->getAttributeLabel('phone')));
 ?>
         </div>
         <div class="row">
             <?php 
 echo $form->textArea($model, 'text', array('class' => 'txt', 'rows' => 6, 'cols' => 30, 'placeholder' => $model->getAttributeLabel('text') . ' *'));
 ?>
         </div>
         <?php 
 if (extension_loaded('gd') and CallbackConfig::model()->checkCaptchaEnabled()) {
     ?>
             <div class="captcha-inner">
                 <?php 
     $this->widget('CCaptcha', array('captchaAction' => '/callback/default/captcha', 'buttonLabel' => ''));
     ?>
                 <div class="captcha-code-inner">
                     <?php 
     echo CHtml::activeTextField($model, 'verifyCode', array('id' => 'user-captcha', 'placeholder' => 'Введите код'));
     ?>
                     <?php 
     echo Chtml::link('Получить новый код', '/callback/default/captcha/refresh/1', array('id' => 'yw0_button'));
     ?>
                 </div>
             </div>
         <?php 
Example #5
0
 public function checkTimeout()
 {
     $config = CallbackConfig::model()->findByPk(1);
     if (isset(Yii::app()->session["timeoutCallback"]) and (int) $config->timeout > 0) {
         $date = new DateTime(Yii::app()->session["timeoutCallback"]);
         $date->add(new DateInterval('PT' . $config->timeout . 'M'));
         if ($date->format('Y-m-d H:i:s') >= date('Y-m-d H:i:s')) {
             return false;
         }
     }
     return true;
 }
Example #6
0
 /**
  * Declares the validation rules.
  */
 public function rules()
 {
     return array(array('name, text, email', 'required'), array('email', 'email', 'message' => 'Ваш e-mail не является правильным E-Mail адресом'), array('text', 'length', 'max' => 700, 'message' => 'Недопустимое количество символов'), array('phone', 'length'), array('phone', 'match', 'pattern' => '/^([+]?[0-9\\s-\\(\\)]{3,25})*$/i', 'message' => 'Поле заполнено некорректно'), array('text', 'checkTagsValidate', 'message' => 'Cообщение содержит недопустимые символы'), array('verifyCode', 'captcha', 'message' => 'Неверный проверочный код', 'allowEmpty' => !CallbackConfig::model()->checkCaptchaEnabled() || !extension_loaded('gd')));
 }