summaryrefslogtreecommitdiff
path: root/includes/helper
diff options
context:
space:
mode:
authorIgor Scheller <igor.scheller@igorshp.de>2018-10-09 21:47:31 +0200
committermsquare <msquare@notrademark.de>2018-10-31 13:43:23 +0100
commit89e62c95a7ffd71a8e860f59378ecd13d6cbb196 (patch)
treea26965030177112a0d54a232c81ffd21d48529de /includes/helper
parentb069a938c6721ab5adddcbec4cff858ded6f0e1e (diff)
Changed more functions :tada:
Diffstat (limited to 'includes/helper')
-rw-r--r--includes/helper/email_helper.php31
1 files changed, 22 insertions, 9 deletions
diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php
index 8668cab0..4fc10226 100644
--- a/includes/helper/email_helper.php
+++ b/includes/helper/email_helper.php
@@ -1,19 +1,32 @@
<?php
use Engelsystem\Mail\EngelsystemMailer;
+use Engelsystem\Models\User\User;
/**
- * @param array $recipient_user
- * @param string $title
- * @param string $message
- * @param bool $not_if_its_me
+ * @param array|User $recipientUser
+ * @param string $title
+ * @param string $message
+ * @param bool $notIfItsMe
* @return bool
*/
-function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_its_me = false)
+function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe = false)
{
$user = Auth()->user();
- if ($not_if_its_me && $user->id == $recipient_user['UID']) {
+ 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) {
return true;
}
@@ -23,12 +36,12 @@ function engelsystem_email_to_user($recipient_user, $title, $message, $not_if_it
/** @var EngelsystemMailer $mailer */
$mailer = app('mailer');
- $translator->setLocale($recipient_user['Sprache']);
+ $translator->setLocale($lang);
$status = $mailer->sendView(
- $recipient_user['email'],
+ $email,
$title,
'emails/mail',
- ['username' => $recipient_user['Nick'], 'message' => $message]
+ ['username' => $username, 'message' => $message]
);
$translator->setLocale($locale);