diff options
author | jwacalex <aboehm@dompfaffenweg.de> | 2016-11-17 23:14:39 +0100 |
---|---|---|
committer | jwacalex <aboehm@dompfaffenweg.de> | 2016-11-30 23:20:13 +0100 |
commit | 79b9f9448e4f3ad7abb8d795c1404b3221c95bf9 (patch) | |
tree | a7e532e379ce4cf9e35d1aa516d0650e61963a9c /includes/model | |
parent | 356cc9e1d0e01bad88cb29f3b143e4ae7156695b (diff) |
initial commit and functionality for no self sign up
Diffstat (limited to 'includes/model')
-rw-r--r-- | includes/model/AngelType_model.php | 6 | ||||
-rw-r--r-- | includes/model/Shifts_model.php | 6 |
2 files changed, 8 insertions, 4 deletions
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index 86d64504..2ccba2ea 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -9,6 +9,7 @@ function AngelType_new() { 'id' => null, 'name' => "", 'restricted' => false, + 'no_self_signup' => false, 'description' => '', 'requires_driver_license' => false ]; @@ -43,12 +44,13 @@ function AngelType_update($angeltype) { `name`='" . sql_escape($angeltype['name']) . "', `restricted`=" . sql_bool($angeltype['restricted']) . ", `description`='" . sql_escape($angeltype['description']) . "', - `requires_driver_license`=" . sql_bool($angeltype['requires_driver_license']) . " + `requires_driver_license`=" . sql_bool($angeltype['requires_driver_license']) . ", + `no_self_signup`=" . sql_bool($angeltype['no_self_signup']) . " WHERE `id`='" . sql_escape($angeltype['id']) . "'"); if ($result === false) { engelsystem_error("Unable to update angeltype."); } - engelsystem_log("Updated angeltype: " . $angeltype['name'] . ($angeltype['restricted'] ? ", restricted" : "") . ($angeltype['requires_driver_license'] ? ", requires driver license" : "")); + engelsystem_log("Updated angeltype: " . $angeltype['name'] . ($angeltype['restricted'] ? ", restricted" : "") . ($angeltype['no_self_signup'] ? ", no_self_signup" : "") . ($angeltype['requires_driver_license'] ? ", requires driver license" : "")); return $result; } diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 2db0a3d3..6a29c540 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -159,14 +159,16 @@ function Shift_signup_allowed($user, $shift, $angeltype, $user_angeltype = null, // you cannot join if shift is full return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries); } - + if ($user_angeltype == null) { $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); } - if ($user_angeltype == null || ($angeltype['restricted'] == 1 && $user_angeltype != null && ! isset($user_angeltype['confirm_user_id']))) { + if ($user_angeltype == null || ($angeltype['no_self_signup'] == 1 && $user_angeltype != null) || + ($angeltype['restricted'] == 1 && $user_angeltype != null && ! isset($user_angeltype['confirm_user_id']))) { // you cannot join if user is not of this angel type // you cannot join if you are not confirmed + return new ShiftSignupState(ShiftSignupState::ANGELTYPE, $free_entries); } |