summaryrefslogtreecommitdiff
path: root/includes/controller
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-12-19 22:59:18 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-12-19 22:59:18 +0100
commit038bf97178ec369f693ca1ca8445ab527abc919d (patch)
tree9e4008775bdf1aae5166b9cd619108bae8ad973d /includes/controller
parentd02272afd6725d46c37b7ba781c5d40268aa09a6 (diff)
link to next shift in menu
Diffstat (limited to 'includes/controller')
-rw-r--r--includes/controller/shifts_controller.php23
1 files changed, 22 insertions, 1 deletions
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 58131d2e..041f21e2 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -16,7 +16,7 @@ function shift_controller() {
global $user, $privileges;
if (! in_array('user_shifts', $privileges))
- redirect(page_link_to('user_shifts'));
+ redirect(page_link_to('?'));
if (! isset($_REQUEST['shift_id']))
redirect(page_link_to('user_shifts'));
@@ -58,10 +58,31 @@ function shifts_controller() {
redirect(page_link_to('?'));
case 'view':
return shift_controller();
+ case 'next':
+ return shift_next_controller();
}
}
/**
+ * Redirects the user to his next shift.
+ */
+function shift_next_controller() {
+ global $user, $privileges;
+
+ if (! in_array('user_shifts', $privileges))
+ redirect(page_link_to('?'));
+
+ $upcoming_shifts = ShiftEntries_upcoming_for_user($user);
+ if ($upcoming_shifts === false)
+ return false;
+
+ if (count($upcoming_shifts) > 0)
+ redirect(shift_link($upcoming_shifts[0]));
+
+ redirect(page_link_to('user_shifts'));
+}
+
+/**
* Export all shifts using api-key.
*/
function shifts_json_export_all_controller() {