summaryrefslogtreecommitdiff
path: root/includes/pages
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-12-28 14:20:16 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-12-28 14:20:16 +0100
commit739eddefd512b2c7775d6f4831186317217fcfbc (patch)
treecbfee894d3cc38cad5d3cfa3bf3186234f1f9432 /includes/pages
parenta470a5f5d36fc66f1cace698e79e9d1a174d1e7d (diff)
better shift sign up restriction
Diffstat (limited to 'includes/pages')
-rw-r--r--includes/pages/user_shifts.php33
1 files changed, 5 insertions, 28 deletions
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index 56695549..46be08d3 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -236,34 +236,6 @@ function user_shifts() {
$type_id = $_REQUEST['type_id'];
else
redirect(page_link_to('user_shifts'));
-
- // Schicht läuft schon, Eintragen für Engel nicht mehr möglich
- if (! in_array('user_shifts_admin', $privileges) && time() > $shift['start']) {
- error(_("This shift is running now or ended already. Please contact a dispatcher to join the shift."));
- redirect(shift_link($shift));
- }
-
- // Another shift the user is signed up for collides with this one
- if (! in_array('user_shifts_admin', $privileges) && sql_num_query("
- SELECT `Shifts`.`SID`
- FROM `Shifts`
- INNER JOIN `ShiftEntry` ON (`Shifts`.`SID` = `ShiftEntry`.`SID` AND `ShiftEntry`.`UID` = '" . sql_escape($user['UID']) . "')
- WHERE `start` < '" . sql_escape($shift['end']) . "' AND `end` > '" . sql_escape($shift['start']) . "'") > 0) {
- error(_("You already subscribed to shift in the same timeslot. Please contact a dispatcher to join the shift."));
- redirect(shift_link($shift));
-
- $needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
- if ($needed_angeltypes === false)
- engelsystem_error('Unable to load needed angel types.');
-
- // you canot join if shift is full
- foreach ($needed_angeltypes as $needed_angeltype)
- if ($needed_angeltype['angel_type_id'] == $type_id)
- if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
- error(_("The shift is already full."));
- redirect(shift_link($shift));
- }
- }
if (in_array('user_shifts_admin', $privileges))
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($type_id) . "' LIMIT 1");
@@ -274,6 +246,11 @@ function user_shifts() {
redirect(page_link_to('user_shifts'));
$type = $type[0];
+ if (! Shift_signup_allowed($shift, $type)) {
+ error(_('You are not allowed to sign up for this shift. Maybe shift is full or already running.'));
+ redirect(shift_link($shift));
+ }
+
if (isset($_REQUEST['submit'])) {
$selected_type_id = $type_id;
if (in_array('user_shifts_admin', $privileges)) {