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. 115
      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) {
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";
return;
}
}
$.post("'.api_get_self().'", $(document.formulaire).serialize(), function(data) {
document.formulaire["form_sent"].value = "1";
@ -173,6 +176,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 +277,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)) {
@ -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()) {
JsonResponse::create($elements_not_in)->send();
exit;
@ -341,13 +356,14 @@ echo '<div id="advanced_search_options" style="display:none">';
$searchForm->display();
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';
} ?>" style="margin:0px;">
<?php
echo '<legend>'.$tool_name.': '.$data['name'].'</legend>';
} ?>" style="margin:0px;">
<?php
echo '<legend>'.$tool_name.': '.$data['name'].'</legend>';
if (is_array($extra_field_list)) {
if (is_array($extra_field_list)) {
if (is_array($new_field_list) && count($new_field_list) > 0) {
echo '<h3>'.get_lang('FilterByUser').'</h3>';
foreach ($new_field_list as $new_field) {
@ -370,32 +386,37 @@ if (is_array($extra_field_list)) {
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />';
}
}
}
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);
?>
<div class="row">
?>
<div class="row">
<div class="col-md-5">
<?php if ($data['group_type'] == UserGroup::SOCIAL_CLASS) {
?>
<select name="relation" id="relation" class="form-control">
<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>
<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>
<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>
<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>
<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>
</select>
<?php
} ?>
} ?>
<div class="multiple_select_header">
<b><?php echo get_lang('UsersInPlatform'); ?> :</b>
@ -428,7 +449,7 @@ echo Display::input('hidden', 'add_type', null);
false
);
?>
<br />
<br/>
<label class="control-label">
<input type="checkbox" <?php if ($user_with_any_group) {
echo 'checked="checked"';
@ -438,11 +459,11 @@ echo Display::input('hidden', 'add_type', null);
</div>
<div class="col-md-2">
<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>
</button>
<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'))">
<br/><br/>
<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>
</button>
</div>
@ -467,52 +488,52 @@ echo Display::input('hidden', 'add_type', null);
unset($sessionUsersList);
?>
</div>
</div>
<?php
</div>
<?php
echo '<button class="btn btn-primary" type="button" value="" onclick="valide()" ><em class="fa fa-check"></em>'.
get_lang('SubscribeUsersToClass').'</button>';
?>
</form>
<script>
function moveItem(origin , destination) {
for(var i = 0 ; i<origin.options.length ; i++) {
if(origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text,origin.options[i].value);
origin.options[i]=null;
i = i-1;
?>
</form>
<script>
function moveItem(origin, destination) {
for (var i = 0; i < origin.options.length; i++) {
if (origin.options[i].selected) {
destination.options[destination.length] = new Option(origin.options[i].text, origin.options[i].value);
origin.options[i] = null;
i = i - 1;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i<options.length ; i++)
function sortOptions(options) {
newOptions = [];
for (i = 0; i < options.length; i++)
newOptions[i] = options[i];
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0 ; i < newOptions.length ; i++)
for (i = 0; i < newOptions.length; i++)
options[i] = newOptions[i];
}
}
function mysort(a, b) {
if(a.text.toLowerCase() > b.text.toLowerCase()){
function mysort(a, b) {
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
if(a.text.toLowerCase() < b.text.toLowerCase()){
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
}
}
function valide() {
function valide() {
var options = document.getElementById('elements_in').options;
for (i = 0 ; i<options.length ; i++)
for (i = 0; i < options.length; i++)
options[i].selected = true;
document.forms.formulaire.submit();
}
</script>
}
</script>
<?php
Display::display_footer();

@ -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'] = [

@ -293,7 +293,7 @@ class ChamiloApi
*/
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';
}

Loading…
Cancel
Save