diff options
author | msquare <msquare@notrademark.de> | 2017-06-20 16:50:21 +0200 |
---|---|---|
committer | msquare <msquare@notrademark.de> | 2017-06-20 16:50:21 +0200 |
commit | 56814fa2fdf58b4013f4d57c5ea87619c7122957 (patch) | |
tree | 640945769b7e9626cdf43162c786147f5c962029 /includes/mailer/shifts_mailer.php | |
parent | a5fc5bd0979e8de1fce8a8addd351a6e7bd6aeb8 (diff) | |
parent | cd30017b97afc3c7001fbb9eb14b54dbb980b7b6 (diff) |
Merge branch 'pr/316' into feature-igel-rewrite
Diffstat (limited to 'includes/mailer/shifts_mailer.php')
-rw-r--r-- | includes/mailer/shifts_mailer.php | 211 |
1 files changed, 118 insertions, 93 deletions
diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php index e1bf422b..5c0e4310 100644 --- a/includes/mailer/shifts_mailer.php +++ b/includes/mailer/shifts_mailer.php @@ -1,104 +1,129 @@ <?php -function mail_shift_change($old_shift, $new_shift) { - $users = ShiftEntries_by_shift($old_shift["SID"]); - $old_room = Room($old_shift["RID"]); - $new_room = Room($new_shift["RID"]); - - $noticable_changes = false; - - $message = _("A Shift you are registered on has changed:"); - $message .= "\n"; - - if ($old_shift["name"] != $new_shift["name"]) { - $message .= sprintf(_("* Shift type changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n"; - $noticable_changes = true; - } - - if ($old_shift["title"] != $new_shift["title"]) { - $message .= sprintf(_("* Shift title changed from %s to %s"), $old_shift["title"], $new_shift["title"]) . "\n"; - $noticable_changes = true; - } - - if ($old_shift["start"] != $new_shift["start"]) { - $message .= sprintf(_("* Shift Start changed from %s to %s"), date("Y-m-d H:i", $old_shift["start"]), date("Y-m-d H:i", $new_shift["start"])) . "\n"; - $noticable_changes = true; - } - - if ($old_shift["end"] != $new_shift["end"]) { - $message .= sprintf(_("* Shift End changed from %s to %s"), date("Y-m-d H:i", $old_shift["end"]), date("Y-m-d H:i", $new_shift["end"])) . "\n"; - $noticable_changes = true; - } - - if ($old_shift["RID"] != $new_shift["RID"]) { - $message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n"; - $noticable_changes = true; - } - - if (! $noticable_changes) { - // There are no changes worth sending an E-Mail - return; - } - - $message .= "\n"; - $message .= _("The updated Shift:") . "\n"; - - $message .= $new_shift["name"] . "\n"; - $message .= $new_shift["title"] . "\n"; - $message .= date("Y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n"; - $message .= $new_room["Name"] . "\n"; - - foreach ($users as $user) { - if ($user["email_shiftinfo"]) { - engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message, true); +/** + * @param array $old_shift + * @param array $new_shift + */ +function mail_shift_change($old_shift, $new_shift) +{ + $users = ShiftEntries_by_shift($old_shift['SID']); + $old_room = Room($old_shift['RID']); + $new_room = Room($new_shift['RID']); + + $noticeable_changes = false; + + $message = _('A Shift you are registered on has changed:'); + $message .= "\n"; + + if ($old_shift['name'] != $new_shift['name']) { + $message .= sprintf(_('* Shift type changed from %s to %s'), $old_shift['name'], $new_shift['name']) . "\n"; + $noticeable_changes = true; + } + + if ($old_shift['title'] != $new_shift['title']) { + $message .= sprintf(_('* Shift title changed from %s to %s'), $old_shift['title'], $new_shift['title']) . "\n"; + $noticeable_changes = true; + } + + if ($old_shift['start'] != $new_shift['start']) { + $message .= sprintf( + _('* Shift Start changed from %s to %s'), + date('Y-m-d H:i', $old_shift['start']), + date('Y-m-d H:i', $new_shift['start']) + ) . "\n"; + $noticeable_changes = true; } - } -} -function mail_shift_delete($shift) { - $users = ShiftEntries_by_shift($shift["SID"]); - $room = Room($shift["RID"]); - - $message = _("A Shift you are registered on was deleted:") . "\n"; - - $message .= $shift["name"] . "\n"; - $message .= $shift["title"] . "\n"; - $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n"; - $message .= $room["Name"] . "\n"; - - foreach ($users as $user) { - if ($user["email_shiftinfo"]) { - engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message, true); + if ($old_shift['end'] != $new_shift['end']) { + $message .= sprintf( + _('* Shift End changed from %s to %s'), + date('Y-m-d H:i', $old_shift['end']), + date('Y-m-d H:i', $new_shift['end']) + ) . "\n"; + $noticeable_changes = true; + } + + if ($old_shift['RID'] != $new_shift['RID']) { + $message .= sprintf(_('* Shift Location changed from %s to %s'), $old_room['Name'], $new_room['Name']) . "\n"; + $noticeable_changes = true; + } + + if (!$noticeable_changes) { + // There are no changes worth sending an E-Mail + return; + } + + $message .= "\n"; + $message .= _('The updated Shift:') . "\n"; + + $message .= $new_shift['name'] . "\n"; + $message .= $new_shift['title'] . "\n"; + $message .= date('Y-m-d H:i', $new_shift['start']) . ' - ' . date('H:i', $new_shift['end']) . "\n"; + $message .= $new_room['Name'] . "\n"; + + foreach ($users as $user) { + if ($user['email_shiftinfo']) { + engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift has changed'), $message, true); + } } - } } -function mail_shift_assign($user, $shift) { - if ($user["email_shiftinfo"]) { - $room = Room($shift["RID"]); - - $message = _("You have been assigned to a Shift:") . "\n"; - $message .= $shift["name"] . "\n"; - $message .= $shift["title"] . "\n"; - $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n"; - $message .= $room["Name"] . "\n"; - - engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message, true); - } +/** + * @param array $shift + */ +function mail_shift_delete($shift) +{ + $users = ShiftEntries_by_shift($shift['SID']); + $room = Room($shift['RID']); + + $message = _('A Shift you are registered on was deleted:') . "\n"; + + $message .= $shift['name'] . "\n"; + $message .= $shift['title'] . "\n"; + $message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n"; + $message .= $room['Name'] . "\n"; + + foreach ($users as $user) { + if ($user['email_shiftinfo']) { + engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift was deleted'), $message, true); + } + } } -function mail_shift_removed($user, $shift) { - if ($user["email_shiftinfo"]) { - $room = Room($shift["RID"]); - - $message = _("You have been removed from a Shift:") . "\n"; - $message .= $shift["name"] . "\n"; - $message .= $shift["title"] . "\n"; - $message .= date("Y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n"; - $message .= $room["Name"] . "\n"; - - engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message, true); - } +/** + * @param array $user + * @param array $shift + */ +function mail_shift_assign($user, $shift) +{ + if (!$user['email_shiftinfo']) { + return; + } + + $room = Room($shift['RID']); + + $message = _('You have been assigned to a Shift:') . "\n"; + $message .= $shift['name'] . "\n"; + $message .= $shift['title'] . "\n"; + $message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n"; + $message .= $room['Name'] . "\n"; + + engelsystem_email_to_user($user, '[engelsystem] ' . _('Assigned to Shift'), $message, true); } -?> +function mail_shift_removed($user, $shift) +{ + if (!$user['email_shiftinfo']) { + return; + } + + $room = Room($shift['RID']); + + $message = _('You have been removed from a Shift:') . "\n"; + $message .= $shift['name'] . "\n"; + $message .= $shift['title'] . "\n"; + $message .= date('Y-m-d H:i', $shift['start']) . ' - ' . date('H:i', $shift['end']) . "\n"; + $message .= $room['Name'] . "\n"; + + engelsystem_email_to_user($user, '[engelsystem] ' . _('Removed from Shift'), $message, true); +} |