# Conflicts:
#	protected/humhub/modules/notification/components/MailNotificationTarget.php
This commit is contained in:
buddh4 2017-02-07 15:27:53 +01:00
commit 9ca6719e0c
3 changed files with 24 additions and 21 deletions

View File

@ -13,6 +13,6 @@ It's perfect for individual:
More information:
- [Homepage & Demo](http://www.humhub.org)
- [Documentation & Class Reference](http://www.humhub.org/docs)
- [Documentation & Class Reference](http://docs.humhub.org)
- [Licence](http://www.humhub.org/licences)

View File

@ -45,10 +45,12 @@ class MailNotificationTarget extends NotificationTarget
*/
public function handle(BaseNotification $notification, User $recipient)
{
Yii::$app->i18n->setUserLocale($recipient);
Yii::$app->view->params['showUnsubscribe'] = true;
Yii::$app->view->params['unsubscribeUrl'] = \yii\helpers\Url::to(['/notification/user'], true);
// Note: the renderer is configured in common.php by default its an instance of MailNotificatoinTarget
// Note: the renderer is configured in common.php by default its an instance of MailNotificationTarget
$renderer = $this->getRenderer();
$viewParams = \yii\helpers\ArrayHelper::merge([
@ -59,14 +61,15 @@ class MailNotificationTarget extends NotificationTarget
'content_plaintext' => $renderer->renderText($notification)
], $notification->getViewParams());
$from = $notification->originator
? Html::encode($notification->originator->displayName).' ('.Html::encode(Yii::$app->name).')'
: Yii::$app->settings->get('mailer.systemEmailName');
return Yii::$app->mailer->compose($this->view, $viewParams)
$from = $notification->originator ? Html::encode($notification->originator->displayName) . ' (' . Html::encode(Yii::$app->name) . ')' : Yii::$app->settings->get('mailer.systemEmailName');
Yii::$app->mailer->compose($this->view, $viewParams)
->setFrom([Yii::$app->settings->get('mailer.systemEmailAddress') => $from])
->setTo($recipient->email)
->setSubject($notification->getTitle($recipient))->send();
Yii::$app->i18n->autosetLocale();
}
/**

View File

@ -153,7 +153,7 @@ abstract class NotificationTarget extends \yii\base\Object
* Used for handling the given $notification for multiple $users.
*
* @param BaseNotification $notification
* @param type $users
* @param User[] $users
*/
public function sendBulk(BaseNotification $notification, $users)
{