summaryrefslogtreecommitdiff
path: root/includes/model/Shifts_model.php
diff options
context:
space:
mode:
Diffstat (limited to 'includes/model/Shifts_model.php')
-rw-r--r--includes/model/Shifts_model.php63
1 files changed, 63 insertions, 0 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 5d0ec4a2..28f84c26 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -1,4 +1,67 @@
<?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) {
+ return sql_query("UPDATE `Shifts` SET
+ `start`=" . sql_escape($shift['start']) . ",
+ `end`=" . sql_escape($shift['end']) . ",
+ `RID`=" . sql_escape($shift['RID']) . ",
+ `name`=" . sql_null($shift['name']) . ",
+ `URL`=" . sql_null($shift['URL']) . ",
+ `PSID`=" . sql_null($shift['PSID']) . "
+ WHERE `SID`=" . sql_escape($shift['SID']));
+}
+
+/**
+ * Update a shift by its external id.
+ */
+function Shift_update_by_psid($shift) {
+ return sql_query("UPDATE `Shifts` SET
+ `start`=" . sql_escape($shift['start']) . ",
+ `end`=" . sql_escape($shift['end']) . ",
+ `RID`=" . sql_escape($shift['RID']) . ",
+ `name`=" . sql_null($shift['name']) . ",
+ `URL`=" . sql_null($shift['URL']) . "
+ WHERE `PSID`=" . sql_escape($shift['PSID']));
+}
+
+/**
+ * Create a new shift.
+ *
+ * @return new shift id or false
+ */
+function Shift_create($shift) {
+ $result = sql_query("INSERT INTO `Shifts` SET
+ `start`=" . sql_escape($shift['start']) . ",
+ `end`=" . sql_escape($shift['end']) . ",
+ `RID`=" . sql_escape($shift['RID']) . ",
+ `name`=" . sql_null($shift['name']) . ",
+ `URL`=" . sql_null($shift['URL']) . ",
+ `PSID`=" . sql_null($shift['PSID']));
+ if ($result === false)
+ return false;
+ return sql_id();
+}
+
+/**
+ * Return users shifts.
+ */
function Shifts_by_user($user) {
return sql_select("
SELECT *