diff options
author | Igor Scheller <igor.scheller@igorshp.de> | 2018-10-17 01:30:10 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2018-10-31 13:43:23 +0100 |
commit | a2aaba9cab6b7bdf755a023ed2503cf8cf46925a (patch) | |
tree | 04275448599cc8ffaf908b3d7fcc984d822f6a17 /includes/helper | |
parent | d7aea575ff77cd37c326511e7ac5fe49067c63ad (diff) |
User: Bugfixes & code cleanup
Diffstat (limited to 'includes/helper')
-rw-r--r-- | includes/helper/email_helper.php | 30 |
1 files changed, 8 insertions, 22 deletions
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); |