Merge pull request #4698 from AngelFQC/BT20712

Group: add usergroup_add_user_show_all_student_by_default conf setting
pull/4701/head
Nicolas Ducoulombier 3 years ago committed by GitHub
commit fba1eb1875
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 41
      main/admin/add_users_to_usergroup.php
  2. 3
      main/install/configuration.dist.php
  3. 2
      src/Chamilo/CoreBundle/Component/Utils/ChamiloApi.php

@ -86,10 +86,13 @@ function change_select(reset) {
if (reset) { if (reset) {
document.formulaire["first_letter_user"].value = ""; document.formulaire["first_letter_user"].value = "";
if ('.(api_get_configuration_value('usergroup_add_user_show_all_student_by_default') ? 0 : 1).') {
document.formulaire["form_sent"].value = "1"; document.formulaire["form_sent"].value = "1";
return; return;
} }
}
$.post("'.api_get_self().'", $(document.formulaire).serialize(), function(data) { $.post("'.api_get_self().'", $(document.formulaire).serialize(), function(data) {
document.formulaire["form_sent"].value = "1"; document.formulaire["form_sent"].value = "1";
@ -173,6 +176,7 @@ if (isset($_GET['action']) && $_GET['action'] == 'export') {
// Filter by Extra Fields // Filter by Extra Fields
$use_extra_fields = false; $use_extra_fields = false;
$extra_field_result = [];
if (is_array($extra_field_list)) { if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list) > 0) { if (is_array($new_field_list) && count($new_field_list) > 0) {
foreach ($new_field_list as $new_field) { foreach ($new_field_list as $new_field) {
@ -273,7 +277,7 @@ foreach ($list_in as $listedUserId) {
$elements_in[$listedUserId] = $person_name; $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 = []; $user_list = [];
if (!empty($conditions)) { if (!empty($conditions)) {
@ -317,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()) { if (ChamiloApi::isAjaxRequest()) {
JsonResponse::create($elements_not_in)->send(); JsonResponse::create($elements_not_in)->send();
exit; exit;
@ -341,7 +356,8 @@ echo '<div id="advanced_search_options" style="display:none">';
$searchForm->display(); $searchForm->display();
echo '</div>'; echo '</div>';
?> ?>
<form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id; if (!empty($_GET['add'])) { <form name="formulaire" method="post" action="<?php echo api_get_self(); ?>?id=<?php echo $id;
if (!empty($_GET['add'])) {
echo '&add=true'; echo '&add=true';
} ?>" style="margin:0px;"> } ?>" style="margin:0px;">
<?php <?php
@ -383,15 +399,20 @@ echo Display::input('hidden', 'add_type', null);
?> ?>
<select name="relation" id="relation" class="form-control"> <select name="relation" id="relation" class="form-control">
<option value=""><?php echo get_lang('SelectARelationType'); ?></option> <option value=""><?php echo get_lang('SelectARelationType'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_ADMIN; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_ADMIN) ? 'selected=selected' : ''; ?> > <option
value="<?php echo GROUP_USER_PERMISSION_ADMIN; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_ADMIN) ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Admin'); ?></option> <?php echo get_lang('Admin'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_READER; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_READER) ? 'selected=selected' : ''; ?> > <option
value="<?php echo GROUP_USER_PERMISSION_READER; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_READER) ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Reader'); ?></option> <?php echo get_lang('Reader'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_PENDING_INVITATION; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_PENDING_INVITATION) ? 'selected=selected' : ''; ?> > <option
value="<?php echo GROUP_USER_PERMISSION_PENDING_INVITATION; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_PENDING_INVITATION) ? 'selected=selected' : ''; ?> >
<?php echo get_lang('PendingInvitation'); ?></option> <?php echo get_lang('PendingInvitation'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_MODERATOR; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_MODERATOR) ? 'selected=selected' : ''; ?> > <option
value="<?php echo GROUP_USER_PERMISSION_MODERATOR; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_MODERATOR) ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Moderator'); ?></option> <?php echo get_lang('Moderator'); ?></option>
<option value="<?php echo GROUP_USER_PERMISSION_HRM; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_HRM) ? 'selected=selected' : ''; ?> > <option
value="<?php echo GROUP_USER_PERMISSION_HRM; ?>" <?php echo (isset($relation) && $relation == GROUP_USER_PERMISSION_HRM) ? 'selected=selected' : ''; ?> >
<?php echo get_lang('Drh'); ?></option> <?php echo get_lang('Drh'); ?></option>
</select> </select>
<?php <?php
@ -438,11 +459,11 @@ echo Display::input('hidden', 'add_type', null);
</div> </div>
<div class="col-md-2"> <div class="col-md-2">
<div style="padding-top:54px;width:auto;text-align: center;"> <div style="padding-top:54px;width:auto;text-align: center;">
<button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))"> <button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('elements_not_in'), document.getElementById('elements_in'))">
<em class="fa fa-arrow-right"></em> <em class="fa fa-arrow-right"></em>
</button> </button>
<br/><br/> <br/><br/>
<button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('elements_in'), document.getElementById('elements_not_in'))" onclick="moveItem(document.getElementById('elements_in'), document.getElementById('elements_not_in'))"> <button class="btn btn-default" type="button" onclick="moveItem(document.getElementById('elements_in'), document.getElementById('elements_not_in'))">
<em class="fa fa-arrow-left"></em> <em class="fa fa-arrow-left"></em>
</button> </button>
</div> </div>
@ -487,7 +508,7 @@ function moveItem(origin , destination) {
} }
function sortOptions(options) { function sortOptions(options) {
newOptions = new Array(); newOptions = [];
for (i = 0; i < options.length; i++) for (i = 0; i < options.length; i++)
newOptions[i] = options[i]; newOptions[i] = options[i];

@ -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 // Do not unsubscribe users from session when sessions are unsubscribe to class
// $_configuration['usergroup_do_not_unsubscribe_users_from_session_on_session_unsubscribe'] = false; // $_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 // 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. // to the "myWebServiceFunctionToLogin" function, the result should be "1" if the user have access.
/*$_configuration['webservice_validation'] = [ /*$_configuration['webservice_validation'] = [

@ -293,7 +293,7 @@ class ChamiloApi
*/ */
public static function isAjaxRequest() public static function isAjaxRequest()
{ {
$requestedWith = isset($_SERVER['HTTP_X_REQUESTED_WITH']) ? $_SERVER['HTTP_X_REQUESTED_WITH'] : null; $requestedWith = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? null;
return $requestedWith === 'XMLHttpRequest'; return $requestedWith === 'XMLHttpRequest';
} }

Loading…
Cancel
Save