include all mailers
This commit is contained in:
parent
f199c1f08a
commit
1f572918ff
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
function mail_shift_change($old_shift, $new_shift) {
|
function mail_shift_change($old_shift, $new_shift) {
|
||||||
|
|
||||||
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
$users = ShiftEntries_by_shift($old_shift["SID"]);
|
||||||
$old_room = Room($old_shift["RID"]);
|
$old_room = Room($old_shift["RID"]);
|
||||||
$new_room = Room($new_shift["RID"]);
|
$new_room = Room($new_shift["RID"]);
|
||||||
|
@ -9,30 +8,30 @@ function mail_shift_change($old_shift, $new_shift) {
|
||||||
$noticable_changes = false;
|
$noticable_changes = false;
|
||||||
|
|
||||||
$message = _("A Shift you are registered on has changed:");
|
$message = _("A Shift you are registered on has changed:");
|
||||||
$message .="\n";
|
$message .= "\n";
|
||||||
|
|
||||||
if($old_shift["name"] != $new_shift["name"]) {
|
if ($old_shift["name"] != $new_shift["name"]) {
|
||||||
$message .= sprintf(_("* Shift Name changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
$message .= sprintf(_("* Shift Name changed from %s to %s"), $old_shift["name"], $new_shift["name"]) . "\n";
|
||||||
$noticable_changes = true;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($old_shift["start"] != $new_shift["start"]) {
|
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";
|
$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;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($old_shift["end"] != $new_shift["end"]) {
|
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";
|
$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;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($old_shift["RID"] != $new_shift["RID"]) {
|
if ($old_shift["RID"] != $new_shift["RID"]) {
|
||||||
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
$message .= sprintf(_("* Shift Location changed from %s to %s"), $old_room["Name"], $new_room["Name"]) . "\n";
|
||||||
$noticable_changes = true;
|
$noticable_changes = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$noticable_changes) {
|
if (! $noticable_changes) {
|
||||||
//There are no changes worth sending an E-Mail
|
// There are no changes worth sending an E-Mail
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,15 +42,12 @@ function mail_shift_change($old_shift, $new_shift) {
|
||||||
$message .= date("y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $new_shift["start"]) . " - " . date("H:i", $new_shift["end"]) . "\n";
|
||||||
$message .= $new_room["Name"] . "\n";
|
$message .= $new_room["Name"] . "\n";
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user)
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"])
|
||||||
engelsystem_email_to_user($user, _("[Angelsystem] Your Shift has changed"), $message);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift has changed"), $message);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mail_shift_delete($shift) {
|
function mail_shift_delete($shift) {
|
||||||
|
|
||||||
$users = ShiftEntries_by_shift($shift["SID"]);
|
$users = ShiftEntries_by_shift($shift["SID"]);
|
||||||
$room = Room($shift["RID"]);
|
$room = Room($shift["RID"]);
|
||||||
|
|
||||||
|
@ -61,11 +57,9 @@ function mail_shift_delete($shift) {
|
||||||
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
foreach ($users as $user) {
|
foreach ($users as $user)
|
||||||
if ($user["email_shiftinfo"]) {
|
if ($user["email_shiftinfo"])
|
||||||
engelsystem_email_to_user($user, _("[Angelsystem] Your Shift was deleted"), $message);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Your Shift was deleted"), $message);
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function mail_shift_assign($user, $shift) {
|
function mail_shift_assign($user, $shift) {
|
||||||
|
@ -77,7 +71,7 @@ function mail_shift_assign($user, $shift) {
|
||||||
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
engelsystem_email_to_user($user, _("[Angelsystem] Assigned to Shift"), $message);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Assigned to Shift"), $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,7 +84,7 @@ function mail_shift_removed($user, $shift) {
|
||||||
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
$message .= date("y-m-d H:i", $shift["start"]) . " - " . date("H:i", $shift["end"]) . "\n";
|
||||||
$message .= $room["Name"] . "\n";
|
$message .= $room["Name"] . "\n";
|
||||||
|
|
||||||
engelsystem_email_to_user($user, _("[Angelsystem] Assigned to Shift"), $message);
|
engelsystem_email_to_user($user, '[engelsystem] ' . _("Removed from Shift"), $message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,6 +25,7 @@ function ShiftEntries_by_shift($shift_id) {
|
||||||
* @param ShiftEntry $shift_entry
|
* @param ShiftEntry $shift_entry
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_create($shift_entry) {
|
function ShiftEntry_create($shift_entry) {
|
||||||
|
mail_shift_assign(User($shift_entry['UID']), Shift($shift_entry['SID']));
|
||||||
return sql_query("INSERT INTO `ShiftEntry` SET
|
return sql_query("INSERT INTO `ShiftEntry` SET
|
||||||
`SID`=" . sql_escape($shift_entry['SID']) . ",
|
`SID`=" . sql_escape($shift_entry['SID']) . ",
|
||||||
`TID`=" . sql_escape($shift_entry['TID']) . ",
|
`TID`=" . sql_escape($shift_entry['TID']) . ",
|
||||||
|
@ -45,10 +46,24 @@ function ShiftEntry_update($shift_entry) {
|
||||||
WHERE `id`=" . sql_escape($shift_entry['id']));
|
WHERE `id`=" . sql_escape($shift_entry['id']));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a shift entry.
|
||||||
|
*/
|
||||||
|
function ShiftEntry($shift_entry_id) {
|
||||||
|
$shift_entry = sql_select("SELECT * FROM `ShiftEntry` WHERE `id`=" . sql_escape($shift_entry_id));
|
||||||
|
if ($shift_entry === false)
|
||||||
|
return false;
|
||||||
|
if (count($shift_entry) == 0)
|
||||||
|
return null;
|
||||||
|
return $shift_entry[0];
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a shift entry.
|
* Delete a shift entry.
|
||||||
*/
|
*/
|
||||||
function ShiftEntry_delete($shift_entry_id) {
|
function ShiftEntry_delete($shift_entry_id) {
|
||||||
|
$shift_entry = ShiftEntry($shift_entry_id);
|
||||||
|
mail_shift_removed(User($shift_entry['UID']), Shift($shift_entry['SID']));
|
||||||
return sql_query("DELETE FROM `ShiftEntry` WHERE `id`=" . sql_escape($shift_entry_id));
|
return sql_query("DELETE FROM `ShiftEntry` WHERE `id`=" . sql_escape($shift_entry_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@ function Shift_delete_by_psid($shift_psid) {
|
||||||
* Delete a shift.
|
* Delete a shift.
|
||||||
*/
|
*/
|
||||||
function Shift_delete($shift_id) {
|
function Shift_delete($shift_id) {
|
||||||
|
|
||||||
mail_shift_delete(Shift($shift_id));
|
mail_shift_delete(Shift($shift_id));
|
||||||
|
|
||||||
return sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id));
|
return sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id));
|
||||||
|
@ -21,7 +20,6 @@ function Shift_delete($shift_id) {
|
||||||
* Update a shift.
|
* Update a shift.
|
||||||
*/
|
*/
|
||||||
function Shift_update($shift) {
|
function Shift_update($shift) {
|
||||||
|
|
||||||
$old_shift = Shift($shift['SID']);
|
$old_shift = Shift($shift['SID']);
|
||||||
mail_shift_change(Shift($shift['SID']), $shift);
|
mail_shift_change(Shift($shift['SID']), $shift);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue