mirror of
https://github.com/humhub/humhub.git
synced 2025-01-17 06:08:21 +01:00
Change to user language when sending notification mails
This commit is contained in:
parent
b0c61f105f
commit
0703cd6515
@ -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)
|
||||
|
||||
|
@ -23,7 +23,7 @@ class MailNotificationTarget extends NotificationTarget
|
||||
* @var type
|
||||
*/
|
||||
public $defaultSetting = true;
|
||||
|
||||
|
||||
/**
|
||||
* @var array Notification mail layout.
|
||||
*/
|
||||
@ -45,27 +45,31 @@ 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([
|
||||
'headline' => $notification->getHeadline($recipient),
|
||||
'notification' => $notification,
|
||||
'space' => $notification->getSpace(),
|
||||
'content' => $renderer->render($notification),
|
||||
'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)
|
||||
->setFrom([Yii::$app->settings->get('mailer.systemEmailAddress') => $from])
|
||||
->setTo($recipient->email)
|
||||
->setSubject($notification->getTitle($recipient))->send();
|
||||
'headline' => $notification->getHeadline($recipient),
|
||||
'notification' => $notification,
|
||||
'space' => $notification->getSpace(),
|
||||
'content' => $renderer->render($notification),
|
||||
'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');
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user