From e4163ec38f46c28b068c6e60a3b69bc1fd387261 Mon Sep 17 00:00:00 2001 From: Angel Fernando Quiroz Campos Date: Tue, 2 May 2023 16:47:08 -0500 Subject: [PATCH 1/2] Minor: Format code --- main/admin/add_users_to_usergroup.php | 317 +++++++++--------- .../CoreBundle/Component/Utils/ChamiloApi.php | 2 +- 2 files changed, 163 insertions(+), 156 deletions(-) diff --git a/main/admin/add_users_to_usergroup.php b/main/admin/add_users_to_usergroup.php index 1953e5132c..0a071c2d61 100755 --- a/main/admin/add_users_to_usergroup.php +++ b/main/admin/add_users_to_usergroup.php @@ -173,6 +173,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'export') { // Filter by Extra Fields $use_extra_fields = false; +$extra_field_result = []; if (is_array($extra_field_list)) { if (is_array($new_field_list) && count($new_field_list) > 0) { foreach ($new_field_list as $new_field) { @@ -273,7 +274,7 @@ foreach ($list_in as $listedUserId) { $elements_in[$listedUserId] = $person_name; } -$user_with_any_group = isset($_REQUEST['user_with_any_group']) && !empty($_REQUEST['user_with_any_group']); +$user_with_any_group = !empty($_REQUEST['user_with_any_group']); $user_list = []; if (!empty($conditions)) { @@ -341,70 +342,76 @@ echo ''; ?> -
-'.$tool_name.': '.$data['name'].''; - -if (is_array($extra_field_list)) { - if (is_array($new_field_list) && count($new_field_list) > 0) { - echo '

'.get_lang('FilterByUser').'

'; - foreach ($new_field_list as $new_field) { - echo $new_field['name']; - $varname = 'field_'.$new_field['variable']; - echo ' '; + echo ''; + foreach ($new_field['data'] as $option) { + $checked = ''; + if (isset($_POST[$varname])) { + if ($_POST[$varname] == $option[1]) { + $checked = 'selected="true"'; + } + } + echo ''; } + echo ''; + echo '  '; } - echo ''; + echo ''; + echo '

'; } - echo ''; - echo '  '; } - echo ''; - echo '

'; - } -} -echo Display::input('hidden', 'id', $id); -echo Display::input('hidden', 'form_sent', '1'); -echo Display::input('hidden', 'add_type', null); - -?> -
-
- - - - -
- : -
- - + echo Display::input('hidden', 'id', $id); + echo Display::input('hidden', 'form_sent', '1'); + echo Display::input('hidden', 'add_type', null); + + ?> +
+
+ + + + +
+ : +
+ + @@ -412,107 +419,107 @@ echo Display::input('hidden', 'add_type', null); +
+
+ 'form-control', + 'multiple' => 'multiple', + 'id' => 'elements_not_in', + 'size' => '15px', + ], + false + ); + ?> +
+ +
+
+
+ +

+ +
+
+
+
+ : +
+ 'form-control', + 'multiple' => 'multiple', + 'id' => 'elements_in', + 'size' => '15px', + ], + false + ); + unset($sessionUsersList); + ?>
- 'form-control', - 'multiple' => 'multiple', - 'id' => 'elements_not_in', - 'size' => '15px', - ], - false - ); - ?> -
- -
-
-
- -

- -
-
-
-
- : -
- 'form-control', - 'multiple' => 'multiple', - 'id' => 'elements_in', - 'size' => '15px', - ], - false - ); - unset($sessionUsersList); - ?> -
-
-'. - get_lang('SubscribeUsersToClass').''; -?> - - + function valide() { + var options = document.getElementById('elements_in').options; + for (i = 0; i < options.length; i++) + options[i].selected = true; + document.forms.formulaire.submit(); + } + Date: Tue, 2 May 2023 18:07:30 -0500 Subject: [PATCH 2/2] Group: add usergroup_add_user_show_all_student_by_default conf setting - refs BT#20712 Show all users in selector as initial list when subscribing users to group --- main/admin/add_users_to_usergroup.php | 18 ++++++++++++++++-- main/install/configuration.dist.php | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/main/admin/add_users_to_usergroup.php b/main/admin/add_users_to_usergroup.php index 0a071c2d61..bf1d8f880a 100755 --- a/main/admin/add_users_to_usergroup.php +++ b/main/admin/add_users_to_usergroup.php @@ -86,9 +86,12 @@ function change_select(reset) { if (reset) { document.formulaire["first_letter_user"].value = ""; - document.formulaire["form_sent"].value = "1"; + + if ('.(api_get_configuration_value('usergroup_add_user_show_all_student_by_default') ? 0 : 1).') { + document.formulaire["form_sent"].value = "1"; - return; + return; + } } $.post("'.api_get_self().'", $(document.formulaire).serialize(), function(data) { @@ -318,6 +321,17 @@ if (!empty($user_list)) { } } +if (api_get_configuration_value('usergroup_add_user_show_all_student_by_default') + && empty($elements_not_in) + && empty($first_letter_user) +) { + $initialUserList = UserManager::getUserListLike([], $order, true, 'OR'); + $elements_not_in = array_combine( + array_column($initialUserList, 'id'), + array_column($initialUserList, 'complete_name_with_username') + ); +} + if (ChamiloApi::isAjaxRequest()) { JsonResponse::create($elements_not_in)->send(); exit; diff --git a/main/install/configuration.dist.php b/main/install/configuration.dist.php index 730fa24da5..c4eba2be12 100644 --- a/main/install/configuration.dist.php +++ b/main/install/configuration.dist.php @@ -1239,6 +1239,9 @@ VALUES (2, 13, 'session_courses_read_only_mode', 'Lock Course In Session', 1, 1, // Do not unsubscribe users from session when sessions are unsubscribe to class // $_configuration['usergroup_do_not_unsubscribe_users_from_session_on_session_unsubscribe'] = false; +// Show all users in selector as initial list when subscribing users to class +//$_configuration['usergroup_add_user_show_all_student_by_default'] = false; + // Validate user login via a webservice, Chamilo will send a "login" and "password" parameters // to the "myWebServiceFunctionToLogin" function, the result should be "1" if the user have access. /*$_configuration['webservice_validation'] = [