From a2aaba9cab6b7bdf755a023ed2503cf8cf46925a Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Wed, 17 Oct 2018 01:30:10 +0200 Subject: User: Bugfixes & code cleanup --- includes/helper/email_helper.php | 30 ++++++++---------------------- 1 file changed, 8 insertions(+), 22 deletions(-) (limited to 'includes/helper/email_helper.php') diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php index 4fc10226..566217ef 100644 --- a/includes/helper/email_helper.php +++ b/includes/helper/email_helper.php @@ -4,29 +4,15 @@ use Engelsystem\Mail\EngelsystemMailer; use Engelsystem\Models\User\User; /** - * @param array|User $recipientUser - * @param string $title - * @param string $message - * @param bool $notIfItsMe + * @param User $recipientUser + * @param string $title + * @param string $message + * @param bool $notIfItsMe * @return bool */ function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe = false) { - $user = Auth()->user(); - - if ($recipientUser instanceof User) { - $id = $user->id; - $lang = $user->settings->language; - $email = $user->contact->email ? $user->contact->email : $user->email; - $username = $user->name; - } else { - $id = $recipientUser['UID']; - $lang = $recipientUser['Sprache']; - $email = $recipientUser['email']; - $username = $recipientUser['Nick']; - } - - if ($notIfItsMe && $user->id == $id) { + if ($notIfItsMe && Auth()->user()->id == $recipientUser->id) { return true; } @@ -36,12 +22,12 @@ function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe /** @var EngelsystemMailer $mailer */ $mailer = app('mailer'); - $translator->setLocale($lang); + $translator->setLocale($recipientUser->settings->language); $status = $mailer->sendView( - $email, + $recipientUser->contact->email ? $recipientUser->contact->email : $recipientUser->email, $title, 'emails/mail', - ['username' => $username, 'message' => $message] + ['username' => $recipientUser->name, 'message' => $message] ); $translator->setLocale($locale); -- cgit v1.2.3-54-g00ecf