summaryrefslogtreecommitdiff
path: root/includes/model
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-12-13 17:55:26 +0100
committerGitHub <noreply@github.com>2016-12-13 17:55:26 +0100
commite7767af4c1551dacbeb1ef22ab193e334826c81e (patch)
tree1bce73a6f803792dcef5196aefe52a45fb4a46a3 /includes/model
parent39f9c2e34cd2fb44a3ea66e363045b250a0e4b07 (diff)
parent6a591e7557e5a2b9c14dec7abb75f09249df9b6d (diff)
Merge pull request #285 from jwacalex/gh_issue_253_disallow_selfsignup_for_shifts
Issue #253 disallow selfsignup for shifts
Diffstat (limited to 'includes/model')
-rw-r--r--includes/model/AngelType_model.php6
-rw-r--r--includes/model/Shifts_model.php6
2 files changed, 8 insertions, 4 deletions
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index 34da4db7..dc26fce9 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -10,6 +10,7 @@ function AngelType_new() {
'id' => null,
'name' => "",
'restricted' => false,
+ 'no_self_signup' => false,
'description' => '',
'requires_driver_license' => false
];
@@ -44,12 +45,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 b1d4ca5e..1e1bd97d 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);
}