summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-12-07 17:13:14 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-12-07 17:13:14 +0100
commit156db1eadd905c7ee4c7c37dc246c8c689ae2396 (patch)
treee52d8248ff62759dacec6e30a5139b109531aa10
parent0a74ab94a8ebc93a7624e0bef90dfd7d8024deaa (diff)
add shift entry update model
-rw-r--r--includes/model/ShiftEntry_model.php11
-rw-r--r--includes/pages/admin_user.php1
-rw-r--r--includes/pages/user_myshifts.php15
3 files changed, 20 insertions, 7 deletions
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index f84b312f..903bc544 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -35,6 +35,17 @@ function ShiftEntry_create($shift_entry) {
}
/**
+ * Update a shift entry.
+ */
+function ShiftEntry_update($shift_entry) {
+ return sql_query("UPDATE `ShiftEntry` SET
+ `Comment`='" . sql_escape($shift_entry['Comment']) . "',
+ `freeload_comment`='" . sql_escape($shift_entry['freeload_comment']) . "',
+ `freeloaded`=" . sql_escape($shift_entry['freeloaded'] ? 'TRUE' : 'FALSE') . "
+ WHERE `id`=" . sql_escape($shift_entry['id']));
+}
+
+/**
* Delete a shift entry.
*/
function ShiftEntry_delete($shift_entry_id) {
diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php
index 87190857..4e10ca1e 100644
--- a/includes/pages/admin_user.php
+++ b/includes/pages/admin_user.php
@@ -215,7 +215,6 @@ function admin_user() {
$user_source = sql_select("SELECT `Nick`, `UID` FROM `User` WHERE `UID` = '" . sql_escape($id) . "' LIMIT 1");
sql_query("DELETE FROM `User` WHERE `UID`=" . sql_escape($id) . " LIMIT 1");
sql_query("DELETE FROM `UserGroups` WHERE `uid`=" . sql_escape($id));
- sql_query("UPDATE `ShiftEntry` SET `UID`=0, `Comment`=NULL WHERE `UID`=" . sql_escape($id));
engelsystem_log("Deleted user " . User_Nick_render($user_source));
$html .= success("Benutzer gelöscht!", true);
} else {
diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php
index 41ea9381..d74475d2 100644
--- a/includes/pages/user_myshifts.php
+++ b/includes/pages/user_myshifts.php
@@ -57,12 +57,15 @@ function user_myshifts() {
$comment = strip_request_item_nl('comment');
$user_source = User($shift['UID']);
- sql_query("UPDATE `ShiftEntry` SET
- `Comment`='" . sql_escape($comment) . "',
- `freeloaded`=" . sql_escape($freeloaded ? 1 : 0) . ",
- `freeload_comment`='" . sql_escape($freeload_comment) . "'
- WHERE `id`=" . sql_escape($id) . "
- LIMIT 1");
+ $result = ShiftEntry_update(array(
+ 'id' => $id,
+ 'Comment' => $comment,
+ 'freeloaded' => $freeloaded,
+ 'freeload_comment' => $freeload_comment
+ ));
+ if ($result === false)
+ engelsystem_error('Unable to update shift entr.');
+
engelsystem_log("Updated " . User_Nick_render($user_source) . "'s shift " . $shift['name'] . " from " . date("y-m-d H:i", $shift['start']) . " to " . date("y-m-d H:i", $shift['end']) . " with comment " . $comment);
success(_("Shift saved."));
redirect(page_link_to('users') . '&action=view&user_id=' . $shifts_user['UID']);