From 76c37a5f1863213e65bce5ee090187eff85ba6dd Mon Sep 17 00:00:00 2001 From: Xu Date: Fri, 19 Jan 2024 19:50:06 +0100 Subject: [PATCH] config options supporters can promote --- config/config.default.php | 3 +++ includes/controller/user_angeltypes_controller.php | 2 +- includes/view/AngelTypes_view.php | 4 ++-- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/config/config.default.php b/config/config.default.php index 19d56cc5..68b2cf34 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -262,6 +262,9 @@ return [ // Whether newly-registered user should automatically be marked as arrived 'autoarrive' => (bool) env('ANGEL_AUTOARRIVE', false), + // Supporters of an angeltype can promote other angels of the angeltype to supporter + 'supporters_can_promote' => (bool) env('SUPPORTERS_CAN_PROMOTE', false), + // Only allow shift signup this number of hours in advance // Setting this to 0 disables the feature 'signup_advance_hours' => env('SIGNUP_ADVANCE_HOURS', 0), diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php index d3739868..46bba97d 100644 --- a/includes/controller/user_angeltypes_controller.php +++ b/includes/controller/user_angeltypes_controller.php @@ -265,7 +265,7 @@ function user_angeltype_update_controller(): array $supporter = false; $request = request(); - if (!auth()->can('admin_angel_types')) { + if (!auth()->can('admin_angel_types') && !config('supporters_can_promote')) { error(__('You are not allowed to set supporter rights.')); throw_redirect(url('/angeltypes')); } diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index f01c2a6b..78ae5fa1 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -321,7 +321,7 @@ function AngelType_view_members(AngelType $angeltype, $members, $admin_user_ange ]); $members_unconfirmed[] = $member; } elseif ($member->pivot->supporter) { - if ($admin_angeltypes) { + if ($admin_angeltypes || ($admin_user_angeltypes && config('supporters_can_promote'))) { $member['actions'] = table_buttons([ button( url('/user-angeltypes', [ @@ -342,7 +342,7 @@ function AngelType_view_members(AngelType $angeltype, $members, $admin_user_ange } else { if ($admin_user_angeltypes) { $member['actions'] = table_buttons([ - $admin_angeltypes ? + ($admin_angeltypes || config('supporters_can_promote')) ? button( url('/user-angeltypes', [ 'action' => 'update',