Minor: Format code

pull/4698/head
Angel Fernando Quiroz Campos 2 years ago
parent 9ffdbf8844
commit e4163ec38f
  1. 317
      main/admin/add_users_to_usergroup.php
  2. 2
      src/Chamilo/CoreBundle/Component/Utils/ChamiloApi.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 '<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'])) {
echo '&add=true';
} ?>" style="margin:0px;">
<?php
echo '<legend>'.$tool_name.': '.$data['name'].'</legend>';
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) {
echo $new_field['name'];
$varname = 'field_'.$new_field['variable'];
echo '&nbsp;<select name="'.$varname.'">';
echo '<option value="0">--'.get_lang('Select').'--</option>';
foreach ($new_field['data'] as $option) {
$checked = '';
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option[1]) {
$checked = 'selected="true"';
<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>';
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) {
echo $new_field['name'];
$varname = 'field_'.$new_field['variable'];
echo '&nbsp;<select name="'.$varname.'">';
echo '<option value="0">--'.get_lang('Select').'--</option>';
foreach ($new_field['data'] as $option) {
$checked = '';
if (isset($_POST[$varname])) {
if ($_POST[$varname] == $option[1]) {
$checked = 'selected="true"';
}
}
echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
}
echo '</select>';
echo '&nbsp;&nbsp;';
}
echo '<option value="'.$option[1].'" '.$checked.'>'.$option[1].'</option>';
echo '<input type="button" value="'.get_lang('Filter').'" onclick="validate_filter()" />';
echo '<br /><br />';
}
echo '</select>';
echo '&nbsp;&nbsp;';
}
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);
?>
<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' : ''; ?> >
<?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' : ''; ?> >
<?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' : ''; ?> >
<?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' : ''; ?> >
<?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' : ''; ?> >
<?php echo get_lang('Drh'); ?></option>
</select>
<?php
} ?>
<div class="multiple_select_header">
<b><?php echo get_lang('UsersInPlatform'); ?> :</b>
<div class="input-group">
<input id="first_letter_user" name="firstLetterUser" type="text" class="form-control"
value="<?php echo Security::remove_XSS($first_letter_user); ?>"
placeholder="<?php echo get_lang('Search'); ?>"
onkeydown="return 13 !== event.keyCode;">
<span class="input-group-btn">
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="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' : ''; ?> >
<?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' : ''; ?> >
<?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' : ''; ?> >
<?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' : ''; ?> >
<?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' : ''; ?> >
<?php echo get_lang('Drh'); ?></option>
</select>
<?php
} ?>
<div class="multiple_select_header">
<b><?php echo get_lang('UsersInPlatform'); ?> :</b>
<div class="input-group">
<input id="first_letter_user" name="firstLetterUser" type="text" class="form-control"
value="<?php echo Security::remove_XSS($first_letter_user); ?>"
placeholder="<?php echo get_lang('Search'); ?>"
onkeydown="return 13 !== event.keyCode;">
<span class="input-group-btn">
<button class="btn btn-default" type="button" onclick="change_select();">
<?php echo get_lang('Filter'); ?>
</button>
@ -412,107 +419,107 @@ echo Display::input('hidden', 'add_type', null);
<?php echo get_lang('Reset'); ?>
</button>
</span>
</div>
</div>
<?php
echo Display::select(
'elements_not_in_name',
$elements_not_in,
'',
[
'class' => 'form-control',
'multiple' => 'multiple',
'id' => 'elements_not_in',
'size' => '15px',
],
false
);
?>
<br/>
<label class="control-label">
<input type="checkbox" <?php if ($user_with_any_group) {
echo 'checked="checked"';
} ?> onchange="checked_in_no_group(this.checked);" name="user_with_any_group" id="user_with_any_group_id">
<?php echo get_lang('UsersRegisteredInAnyGroup'); ?>
</label>
</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'))">
<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'))">
<em class="fa fa-arrow-left"></em>
</button>
</div>
</div>
<div class="col-md-5">
<div class="multiple_select_header">
<b><?php echo get_lang('UsersInGroup'); ?> :</b>
</div>
<?php
echo Display::select(
'elements_in_name[]',
$elements_in,
'',
[
'class' => 'form-control',
'multiple' => 'multiple',
'id' => 'elements_in',
'size' => '15px',
],
false
);
unset($sessionUsersList);
?>
</div>
</div>
<?php
echo Display::select(
'elements_not_in_name',
$elements_not_in,
'',
[
'class' => 'form-control',
'multiple' => 'multiple',
'id' => 'elements_not_in',
'size' => '15px',
],
false
);
?>
<br />
<label class="control-label">
<input type="checkbox" <?php if ($user_with_any_group) {
echo 'checked="checked"';
} ?> onchange="checked_in_no_group(this.checked);" name="user_with_any_group" id="user_with_any_group_id">
<?php echo get_lang('UsersRegisteredInAnyGroup'); ?>
</label>
</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'))">
<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'))">
<em class="fa fa-arrow-left"></em>
</button>
</div>
</div>
<div class="col-md-5">
<div class="multiple_select_header">
<b><?php echo get_lang('UsersInGroup'); ?> :</b>
</div>
<?php
echo Display::select(
'elements_in_name[]',
$elements_in,
'',
[
'class' => 'form-control',
'multiple' => 'multiple',
'id' => 'elements_in',
'size' => '15px',
],
false
);
unset($sessionUsersList);
?>
</div>
</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;
<?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;
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
}
destination.selectedIndex = -1;
sortOptions(destination.options);
}
function sortOptions(options) {
newOptions = new Array();
for (i = 0 ; i<options.length ; i++)
newOptions[i] = options[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++)
options[i] = newOptions[i];
}
newOptions = newOptions.sort(mysort);
options.length = 0;
for (i = 0; i < newOptions.length; i++)
options[i] = newOptions[i];
}
function mysort(a, b) {
if(a.text.toLowerCase() > b.text.toLowerCase()){
return 1;
}
if(a.text.toLowerCase() < b.text.toLowerCase()){
return -1;
}
return 0;
}
function mysort(a, b) {
if (a.text.toLowerCase() > b.text.toLowerCase()) {
return 1;
}
if (a.text.toLowerCase() < b.text.toLowerCase()) {
return -1;
}
return 0;
}
function valide() {
var options = document.getElementById('elements_in').options;
for (i = 0 ; i<options.length ; i++)
options[i].selected = true;
document.forms.formulaire.submit();
}
</script>
function valide() {
var options = document.getElementById('elements_in').options;
for (i = 0; i < options.length; i++)
options[i].selected = true;
document.forms.formulaire.submit();
}
</script>
<?php
Display::display_footer();

@ -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