Merge pull request #285 from jwacalex/gh_issue_253_disallow_selfsignup_for_shifts

Issue #253 disallow selfsignup for shifts
This commit is contained in:
msquare 2016-12-13 17:55:26 +01:00 committed by GitHub
commit e7767af4c1
5 changed files with 18 additions and 5 deletions

View File

@ -4,3 +4,6 @@ INSERT INTO `GroupPrivileges` (`id`, `group_id`, `privilege_id`) VALUES (NULL, '
ALTER TABLE `UserAngelTypes` CHANGE `coordinator` `supporter` BOOLEAN;
ALTER TABLE `User` ADD COLUMN `email_by_human_allowed` BOOLEAN NOT NULL;
-- No Self Sign Up for some Angel Types
ALTER TABLE engelsystem.AngelTypes ADD no_self_signup TINYINT(1) NOT NULL;

View File

@ -118,6 +118,8 @@ function angeltype_edit_controller() {
}
$angeltype['restricted'] = isset($_REQUEST['restricted']);
$angeltype['no_self_signup'] = isset($_REQUEST['no_self_signup']);
$angeltype['requires_driver_license'] = isset($_REQUEST['requires_driver_license']);
}
@ -192,6 +194,8 @@ function angeltypes_list_controller() {
}
$angeltype['restricted'] = $angeltype['restricted'] ? glyph('lock') : '';
$angeltype['no_self_signup'] = $angeltype['no_self_signup'] ? '' : glyph('share');
$angeltype['name'] = '<a href="' . page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'] . '">' . $angeltype['name'] . '</a>';
$angeltype['actions'] = table_buttons($actions);

View File

@ -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;
}

View File

@ -164,9 +164,11 @@ function Shift_signup_allowed($user, $shift, $angeltype, $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);
}

View File

@ -64,6 +64,7 @@ function AngelType_edit_view($angeltype, $supporter_mode) {
form([
$supporter_mode ? form_info(_("Name"), $angeltype['name']) : form_text('name', _("Name"), $angeltype['name']),
$supporter_mode ? form_info(_("Restricted"), $angeltype['restricted'] ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $angeltype['restricted']),
$supporter_mode ? form_info(_("No Self Sign Up"), $angeltype['no_self_signup'] ? _("Yes") : _("No")) : form_checkbox('no_self_signup', _("No Self Sign Up"), $angeltype['no_self_signup']),
$supporter_mode ? form_info(_("Requires driver license"), $angeltype['requires_driver_license'] ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $angeltype['requires_driver_license']),
form_info("", _("Restricted angel types can only be used by an angel if enabled by a supporter (double opt-in).")),
form_textarea('description', _("Description"), $angeltype['description']),
@ -262,6 +263,7 @@ function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
table([
'name' => _("Name"),
'restricted' => glyph('lock') . _("Restricted"),
'no_self_signup' => glyph('share') . _("Self Sign Up Allowed"),
'membership' => _("Membership"),
'actions' => ""
], $angeltypes)