fix shift occupied method

This commit is contained in:
msquare 2016-11-12 19:05:36 +01:00
parent c61e888de4
commit 7bafe3f24c
1 changed files with 6 additions and 6 deletions

View File

@ -94,15 +94,15 @@ function Shift_collides($shift, $shifts) {
* *
* @param int $shift_id * @param int $shift_id
* ID of the shift to check * ID of the shift to check
* @param int $angeltype_id
* ID of the angeltype that should be checked
*/ */
function Shift_occupied($shift_id) { function Shift_occupied($shift_id, $angeltype_id) {
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']); $needed_angeltypes = NeededAngelTypes_by_shift($shift_id);
foreach ($needed_angeltypes as $needed_angeltype) { foreach ($needed_angeltypes as $needed_angeltype) {
if ($needed_angeltype['angel_type_id'] == $angeltype['id']) { if ($needed_angeltype['angel_type_id'] == $angeltype['id']) {
if ($needed_angeltype['taken'] < $needed_angeltype['count']) { return $needed_angeltype['taken'] < $needed_angeltype['count'];
return false;
}
} }
} }
@ -136,7 +136,7 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
} }
// you canot join if shift is full // you canot join if shift is full
$user_may_join_shift = ! Shift_occupied($shift['SID']); $user_may_join_shift = ! Shift_occupied($shift['SID'], $angeltype['id']);
// you cannot join if user alread joined a parallel or this shift // you cannot join if user alread joined a parallel or this shift
$user_may_join_shift &= ! Shift_collides($shift, $user_shifts); $user_may_join_shift &= ! Shift_collides($shift, $user_shifts);