From 88adc590d30fdafcbf28c3c45c1041ff74e4e085 Mon Sep 17 00:00:00 2001 From: noumo Date: Tue, 19 May 2015 18:39:08 +0300 Subject: [PATCH] Sent fixes --- helpers/Mail.php | 8 ++++---- modules/feedback/mail/en/new_feedback.php | 2 +- modules/feedback/mail/ru/new_feedback.php | 2 +- modules/feedback/models/Feedback.php | 12 +++++++++++- modules/shopcart/models/Order.php | 2 +- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/helpers/Mail.php b/helpers/Mail.php index 518741e..411e5a3 100644 --- a/helpers/Mail.php +++ b/helpers/Mail.php @@ -11,13 +11,13 @@ public static function send($toEmail, $subject, $template, $data = [], $options if(!filter_var($toEmail, FILTER_VALIDATE_EMAIL) || !$subject || !$template){ return false; } - $data['subject'] = $subject; + $data['subject'] = trim($subject); $message = Yii::$app->mailer->compose($template, $data) - ->setTo(Setting::get('admin_email')) - ->setSubject(trim($subject)); + ->setTo($toEmail) + ->setSubject($data['subject']); - if(!filter_var(Setting::get('robot_email'), FILTER_VALIDATE_EMAIL)){ + if(filter_var(Setting::get('robot_email'), FILTER_VALIDATE_EMAIL)){ $message->setFrom(Setting::get('robot_email')); } diff --git a/modules/feedback/mail/en/new_feedback.php b/modules/feedback/mail/en/new_feedback.php index f815d8e..3259735 100644 --- a/modules/feedback/mail/en/new_feedback.php +++ b/modules/feedback/mail/en/new_feedback.php @@ -3,5 +3,5 @@ $this->title = $subject; ?> -

User name ?> leaved message in your guestbook.

+

User name ?> leaved message in your guestbook.

You can view it .

\ No newline at end of file diff --git a/modules/feedback/mail/ru/new_feedback.php b/modules/feedback/mail/ru/new_feedback.php index 07e1060..7d849ed 100644 --- a/modules/feedback/mail/ru/new_feedback.php +++ b/modules/feedback/mail/ru/new_feedback.php @@ -3,7 +3,7 @@ $this->title = $subject; ?> -

Пользователь name ?> оставил сообщение в вашей гостевой книге.

+

Пользователь name ?> оставил сообщение в вашей гостевой книге.

Просмотреть его вы можете .


Это автоматическое сообщение и на него не нужно отвечатью

\ No newline at end of file diff --git a/modules/feedback/models/Feedback.php b/modules/feedback/models/Feedback.php index b7c47ce..07cfe5c 100644 --- a/modules/feedback/models/Feedback.php +++ b/modules/feedback/models/Feedback.php @@ -7,6 +7,7 @@ use yii\easyii\models\Setting; use yii\easyii\validators\ReCaptchaValidator; use yii\easyii\validators\EscapeValidator; +use yii\helpers\Url; class Feedback extends \yii\easyii\components\ActiveRecord { @@ -52,6 +53,15 @@ public function beforeSave($insert) } } + public function afterSave($insert, $changedAttributes) + { + parent::afterSave($insert, $changedAttributes); + + if($insert){ + $this->mailAdmin(); + } + } + public function attributeLabels() { return [ @@ -89,7 +99,7 @@ public function mailAdmin() Setting::get('admin_email'), $settings['subjectOnNewFeedback'], $settings['templateOnNewFeedback'], - ['feedback' => $this] + ['feedback' => $this, 'link' => Url::to(['/admin/feedback/a/view', 'id' => $this->primaryKey], true)] ); } diff --git a/modules/shopcart/models/Order.php b/modules/shopcart/models/Order.php index 439329d..ffb98d1 100644 --- a/modules/shopcart/models/Order.php +++ b/modules/shopcart/models/Order.php @@ -164,7 +164,7 @@ public function notifyUser() $settings['templateNotifyUser'], [ 'order' => $this, - 'link' => Url::to([$settings['frontendShopcartRoute'], 'token' => $this->access_token], true) + 'link' => Url::to([$settings['frontendShopcartRoute'], 'id' => $this->primaryKey, 'token' => $this->access_token], true) ] ); }