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 .= $new_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); } } }
/** * Sends reminder emails to users for soon beginning shifts * */ function send_reminder_emails_for_shifts() { // load last end time $lastEndTime = time() + REMINDER_MIN_FUTURE; $fReminder = fopen(REMINDER_FILE_LOC, "c+"); $fsize = filesize(REMINDER_FILE_LOC); if ($fsize > 0) { $readLET = fread($fReminder, $fsize); } if (isset($readLET) && $readLET > $lastEndTime) { // cron was invoked before REMINDER_SEND_PERIOD time passed // -> do not send out new eMails starting from $readLET fclose($fReminder); } else { if (isset($readLET)) { // for the first time readLET is not set $lastEndTime = $readLET; } // persist new lastEnd fseek($fReminder, 0); fwrite($fReminder, $lastEndTime + REMINDER_SEND_PERIOD); fclose($fReminder); // retrieve shifts in next period $shiftsInNextP = Shifts_find_by_start_interval($lastEndTime, REMINDER_SEND_PERIOD); // iterate over every shift and find assigned users foreach ($shiftsInNextP as $shift) { $shift['RID'] = Room($shift['RID']); $assignedUsers = ShiftEntries_by_shift($shift['SID']); // iterate over each user and send eMail foreach ($assignedUsers as $user) { mail_shift_reminder($user, $shift, _("3 hours")); } // end of $assignedUsers } // end of $shiftsInNextP } // end of else (isset($readLET) ...) }