user cannot signup for full shifts

This commit is contained in:
Philip Häusler 2014-12-26 23:48:16 +01:00
parent af25ca9103
commit 8d6175a273
2 changed files with 25 additions and 1 deletions

View File

@ -43,11 +43,23 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
$signed_up = true; $signed_up = true;
break; 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? // is the shift still running or alternatively is the user shift admin?
$user_may_join_shift = true; $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; $user_may_join_shift &= ! $collides;
// you cannot join if you already singed up for this shift // you cannot join if you already singed up for this shift

View File

@ -253,6 +253,18 @@ function user_shifts() {
redirect(shift_link($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)) if (in_array('user_shifts_admin', $privileges))
$type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1"); $type = sql_select("SELECT * FROM `AngelTypes` WHERE `id`=" . sql_escape($type_id) . " LIMIT 1");
else else