summaryrefslogtreecommitdiff
path: root/includes/model
diff options
context:
space:
mode:
authorPhilip Häusler <msquare@notrademark.de>2014-12-26 23:48:16 +0100
committerPhilip Häusler <msquare@notrademark.de>2014-12-26 23:48:16 +0100
commit8d6175a273516b60c1c0e0b33367d33fc64109b3 (patch)
tree6f6223c61270164fda6dd803e14c28b5ccc4046e /includes/model
parentaf25ca9103debdb392395e82473db318a5eeab2c (diff)
user cannot signup for full shifts
Diffstat (limited to 'includes/model')
-rw-r--r--includes/model/Shifts_model.php14
1 files changed, 13 insertions, 1 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 37c772bf..a0cdbe5d 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -43,11 +43,23 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
$signed_up = true;
break;
}
+
+ $needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
+ if ($needed_angeltypes === false)
+ engelsystem_error('Unable to load needed angel types.');
// is the shift still running or alternatively is the user shift admin?
$user_may_join_shift = true;
- // you cannot join if user alread joined a parallel or this shift
+ // you canot join if shift is full
+ foreach ($needed_angeltypes as $needed_angeltype)
+ if ($needed_angeltype['angel_type_id'] == $angeltype['id']) {
+ if ($needed_angeltype['taken'] >= $needed_angeltype['count'])
+ $user_may_join_shift = false;
+ break;
+ }
+
+ // you cannot join if user alread joined a parallel or this shift
$user_may_join_shift &= ! $collides;
// you cannot join if you already singed up for this shift