diff options
author | Philip Häusler <msquare@notrademark.de> | 2014-12-07 17:48:35 +0100 |
---|---|---|
committer | Philip Häusler <msquare@notrademark.de> | 2014-12-07 17:48:35 +0100 |
commit | b75700ee1bf4bc07f1da7899aac864cb561022f4 (patch) | |
tree | 81324e1dbb63233f1895cdb5b14a998069bc5a9b | |
parent | d26f8aa12cd71cd5301e6747fbedf6bfbe2ac37f (diff) |
add shift delete model
-rw-r--r-- | includes/model/Shifts_model.php | 14 | ||||
-rw-r--r-- | includes/pages/admin_import.php | 7 | ||||
-rw-r--r-- | includes/pages/user_shifts.php | 5 |
3 files changed, 22 insertions, 4 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index a1d7967f..28f84c26 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -1,6 +1,20 @@ <?php /** + * Delete a shift by its external id. + */ +function Shift_delete_by_psid($shift_psid) { + return sql_query("DELETE FROM `Shifts` WHERE `PSID`=" . sql_escape($shift_psid)); +} + +/** + * Delete a shift. + */ +function Shift_delete($shift_id) { + return sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id)); +} + +/** * Update a shift. */ function Shift_update($shift) { diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php index f4c2b252..120ab91b 100644 --- a/includes/pages/admin_import.php +++ b/includes/pages/admin_import.php @@ -129,8 +129,11 @@ function admin_import() { engelsystem_error('Unable to update shift.'); } - foreach ($events_deleted as $event) - sql_query("DELETE FROM `Shifts` WHERE `PSID`=" . sql_escape($event['PSID']) . " LIMIT 1"); + foreach ($events_deleted as $event) { + $result = Shift_delete_by_psid($event['PSID']); + if ($result === false) + engelsystem_error('Unable to delete shift.'); + } engelsystem_log("Pentabarf import done"); diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php index 2f0bee6e..c1a5cc91 100644 --- a/includes/pages/user_shifts.php +++ b/includes/pages/user_shifts.php @@ -178,8 +178,9 @@ function user_shifts() { // Schicht löschen bestätigt if (isset($_REQUEST['delete'])) { - sql_query("DELETE FROM `NeededAngelTypes` WHERE `shift_id`=" . sql_escape($shift_id)); - sql_query("DELETE FROM `Shifts` WHERE `SID`=" . sql_escape($shift_id) . " LIMIT 1"); + $result = Shift_delete($shift_id); + if ($result === false) + engelsystem_error('Unable to delete shift.'); engelsystem_log("Deleted shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end'])); success(_("Shift deleted.")); |