Make confirmation optional when adding a user to an angeltype

This commit is contained in:
Igor Scheller 2021-12-25 17:48:23 +01:00 committed by msquare
parent 05a206d367
commit a129f18c2c
3 changed files with 18 additions and 9 deletions

View File

@ -392,7 +392,8 @@ function user_angeltype_add_controller(): array
// Load possible users, that are not in the angeltype already // Load possible users, that are not in the angeltype already
$users_source = Users_by_angeltype_inverted($angeltype); $users_source = Users_by_angeltype_inverted($angeltype);
if (request()->hasPostData('submit')) { $request = request();
if ($request->hasPostData('submit')) {
$user_source = load_user(); $user_source = load_user();
if (!UserAngelType_exists($user_source->id, $angeltype)) { if (!UserAngelType_exists($user_source->id, $angeltype)) {
@ -409,12 +410,14 @@ function user_angeltype_add_controller(): array
AngelType_name_render($angeltype) AngelType_name_render($angeltype)
)); ));
UserAngelType_confirm($user_angeltype_id, $user_source->id); if ($request->hasPostData('auto_confirm_user')) {
engelsystem_log(sprintf( UserAngelType_confirm($user_angeltype_id, $user_source->id);
'User %s confirmed as %s.', engelsystem_log(sprintf(
User_Nick_render($user_source, true), 'User %s confirmed as %s.',
AngelType_name_render($angeltype, true) User_Nick_render($user_source, true),
)); AngelType_name_render($angeltype, true)
));
}
user_angeltype_add_email($user_source, $angeltype); user_angeltype_add_email($user_source, $angeltype);
@ -444,7 +447,8 @@ function user_angeltype_join_controller($angeltype)
throw_redirect(page_link_to('angeltypes')); throw_redirect(page_link_to('angeltypes'));
} }
if (request()->hasPostData('submit')) { $request = request();
if ($request->hasPostData('submit')) {
$user_angeltype_id = UserAngelType_create($user->id, $angeltype); $user_angeltype_id = UserAngelType_create($user->id, $angeltype);
$success_message = sprintf(__('You joined %s.'), $angeltype['name']); $success_message = sprintf(__('You joined %s.'), $angeltype['name']);
@ -455,7 +459,7 @@ function user_angeltype_join_controller($angeltype)
)); ));
success($success_message); success($success_message);
if (auth()->can('admin_user_angeltypes')) { if (auth()->can('admin_user_angeltypes') && $request->hasPostData('auto_confirm_user')) {
UserAngelType_confirm($user_angeltype_id, $user->id); UserAngelType_confirm($user_angeltype_id, $user->id);
engelsystem_log(sprintf( engelsystem_log(sprintf(
'User %s confirmed as %s.', 'User %s confirmed as %s.',

View File

@ -150,6 +150,7 @@ function UserAngelType_add_view($angeltype, $users_source, $user_id)
]), ]),
form([ form([
form_info(__('Angeltype'), $angeltype['name']), form_info(__('Angeltype'), $angeltype['name']),
form_checkbox('auto_confirm_user', __('Confirm user'), true),
form_select('user_id', __('User'), $users, $user_id), form_select('user_id', __('User'), $users, $user_id),
form_submit('submit', __('Add')) form_submit('submit', __('Add'))
]) ])
@ -171,6 +172,7 @@ function UserAngelType_join_view($user, $angeltype)
$angeltype['name'] $angeltype['name']
), true), ), true),
form([ form([
auth()->can('admin_user_angeltypes') ? form_checkbox('auto_confirm_user', __('Confirm user'), true) : '',
buttons([ buttons([
button(angeltype_link($angeltype['id']), icon('x-lg') . __('cancel')), button(angeltype_link($angeltype['id']), icon('x-lg') . __('cancel')),
form_submit('submit', icon('check-lg') . __('save'), 'btn-primary', false) form_submit('submit', icon('check-lg') . __('save'), 'btn-primary', false)

View File

@ -2420,6 +2420,9 @@ msgstr "Möchtest Du wirklich %s von %s entfernen?"
msgid "Do you really want to add %s to %s?" msgid "Do you really want to add %s to %s?"
msgstr "Möchtest Du wirklich %s zu %s hinzufügen?" msgstr "Möchtest Du wirklich %s zu %s hinzufügen?"
msgid "Confirm user"
msgstr "Benutzer bestätigen"
#: includes/view/UserAngelTypes_view.php:176 #: includes/view/UserAngelTypes_view.php:176
msgid "save" msgid "save"
msgstr "Speichern" msgstr "Speichern"