Skip to content

Commit

Permalink
Sent fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
noumo committed May 19, 2015
1 parent 0edf78a commit 88adc59
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
8 changes: 4 additions & 4 deletions helpers/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
}

Expand Down
2 changes: 1 addition & 1 deletion modules/feedback/mail/en/new_feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@

$this->title = $subject;
?>
<p>User <b><?= $post->name ?></b> leaved message in your guestbook.</p>
<p>User <b><?= $feedback->name ?></b> leaved message in your guestbook.</p>
<p>You can view it <?= Html::a('here', $link) ?>.</p>
2 changes: 1 addition & 1 deletion modules/feedback/mail/ru/new_feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

$this->title = $subject;
?>
<p>Пользователь <b><?= $post->name ?></b> оставил сообщение в вашей гостевой книге.</p>
<p>Пользователь <b><?= $feedback->name ?></b> оставил сообщение в вашей гостевой книге.</p>
<p>Просмотреть его вы можете <?= Html::a('здесь', $link) ?>.</p>
<hr>
<p>Это автоматическое сообщение и на него не нужно отвечатью</p>
12 changes: 11 additions & 1 deletion modules/feedback/models/Feedback.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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 [
Expand Down Expand Up @@ -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)]
);
}

Expand Down
2 changes: 1 addition & 1 deletion modules/shopcart/models/Order.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
]
);
}
Expand Down

0 comments on commit 88adc59

Please sign in to comment.