Merge remote-tracking branch 'origin/1.11.x' into 1.11.x

pull/4629/merge
Angel Fernando Quiroz Campos 11 months ago
commit f2f726259c
No known key found for this signature in database
GPG Key ID: B284841AE3E562CD
  1. 86
      main/admin/add_users_to_usergroup.php
  2. 14
      main/auth/sort_my_courses.php
  3. 10
      main/document/document.php
  4. 7
      main/install/configuration.dist.php
  5. 41
      main/lp/lp_list.php
  6. 119
      main/session/add_users_to_session.php

@ -112,6 +112,44 @@ function change_select(reset) {
});
}
</script>';
$htmlHeadXtra[] = '
<script>
$(document).ready(function() {
function showLastTenUsers() {
var selectedUsers = [];
$("#elements_in option").each(function() {
selectedUsers.push($(this).val());
});
var groupId = "'.$id.'";
$.ajax({
type: "POST",
url: "'.api_get_self().'",
data: {
action: "get_last_ten_users",
excludedUsers: selectedUsers,
id: groupId
},
dataType: "json",
success: function(data) {
var select = document.getElementById("elements_not_in");
select.innerHTML = "";
$.each(data, function(index, user) {
select.append(new Option(user.username + " - " + user.firstname + " " + user.lastname, user.id));
});
},
error: function(xhr, status, error) {
console.error("Error en la solicitud AJAX: " + status + " - " + error);
}
});
}
$("#show_last_ten_users_button").click(function() {
showLastTenUsers();
});
});
</script>';
$form_sent = 0;
@ -133,6 +171,35 @@ if (empty($id)) {
api_not_allowed(true);
}
if (ChamiloApi::isAjaxRequest() && $_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'get_last_ten_users') {
$excludedUsers = isset($_POST['excludedUsers']) ? $_POST['excludedUsers'] : [];
$id = isset($_POST['id']) ? intval($_POST['id']) : 0;
$excludedIds = !empty($excludedUsers) ? implode(",", array_map('intval', $excludedUsers)) : '0';
$sql = 'SELECT id, username, firstname, lastname
FROM user
WHERE status != '.ANONYMOUS.'
AND id NOT IN ('.$excludedIds.')
ORDER BY id DESC
LIMIT 10';
$result = Database::query($sql);
$users = [];
while ($user = Database::fetch_array($result)) {
$users[] = [
'id' => $user['id'],
'username' => $user['username'],
'firstname' => $user['firstname'],
'lastname' => $user['lastname']
];
}
header('Content-Type: application/json');
echo json_encode($users);
die();
}
$first_letter_user = '';
if ((isset($_POST['form_sent']) && $_POST['form_sent']) || isset($_REQUEST['firstLetterUser'])) {
@ -453,13 +520,18 @@ echo '</div>';
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>
<button class="btn btn-default" type="button" onclick="change_select(true);">
<?php echo get_lang('Reset'); ?>
</button>
</span>
<button class="btn btn-default" type="button" onclick="change_select();">
<?php echo get_lang('Filter'); ?>
</button>
<button class="btn btn-default" type="button" onclick="change_select(true);">
<?php echo get_lang('Reset'); ?>
</button>
</span>
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="show_last_ten_users_button" title="<?php echo get_lang('ShowLastTenUsers') ?>">
<i class="fa fa-clock-o"></i>
</button>
</span>
</div>
</div>
<?php

@ -12,7 +12,19 @@ $auth = new Auth();
$user_course_categories = CourseManager::get_user_course_categories(api_get_user_id());
$courses_in_category = $auth->getCoursesInCategory(false);
$action = isset($_REQUEST['action']) ? Security::remove_XSS($_REQUEST['action']) : '';
// Only authorized actions
$authorizedActions = [
'edit_category',
'edit_course_category',
'deletecoursecategory',
'createcoursecategory',
'set_collapsable',
'unsubscribe'
];
if (in_array(trim($_REQUEST['action']), $authorizedActions)) {
$action = trim($_REQUEST['action']);
}
$currentUrl = api_get_self();
$interbreadcrumb[] = [

@ -1785,10 +1785,12 @@ if ($isAllowedToEdit ||
.'&id='.$current_folder_id.'&certificate=true'
);
} else {
$actionsLeft .= Display::url(
Display::return_icon('upload_file.png', get_lang('UplUploadDocument'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/upload.php?'.api_get_cidreq().'&id='.$current_folder_id
);
if (!(api_get_configuration_value('session_hide_document_upload') === true && (isset($sessionId) && $sessionId != 0))) {
$actionsLeft .= Display::url(
Display::return_icon('upload_file.png', get_lang('UplUploadDocument'), '', ICON_SIZE_MEDIUM),
api_get_path(WEB_CODE_PATH).'document/upload.php?'.api_get_cidreq().'&id='.$current_folder_id
);
}
}
// Create directory

@ -2565,6 +2565,13 @@ INSERT INTO extra_field_options (field_id, option_value, display_text, priority,
// Define the default time in seconds to be registered if the user does logout from a course and there is no recent entry in track_e_course_access.
//$_configuration['tracking_default_course_extra_time_on_logout'] = 600;
// Set to true to hide lp creation icon on lp list if in a session
//$_configuration['session_hide_lp_creation'] = false;
// Set to true to hide lp copy icon on lp list if in a session
//$_configuration['session_hide_lp_copy'] = false;
// Set to true to hide document upload icon on document list if in a session
//$_configuration['session_hide_document_upload'] = false;
// Define a special path token for the Common Cartridge export content.
// Due to changes in naming by the responsible organization, the Chamilo default
// is '$1EdTech-CC-FILEBASE$' (the latest), but previous versions of the standard

@ -80,24 +80,26 @@ if (!empty($sessionId)) {
if ($is_allowed_to_edit) {
$actionLeft = '';
$actionLeft .= Display::url(
Display::return_icon(
'new_learnpath.png',
get_lang('LearnpathAddLearnpath'),
'',
ICON_SIZE_MEDIUM
),
api_get_self().'?'.api_get_cidreq().'&action=add_lp'
);
$actionLeft .= Display::url(
Display::return_icon(
'import_scorm.png',
get_lang('UploadScorm'),
'',
ICON_SIZE_MEDIUM
),
'../upload/index.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
);
if (!(api_get_configuration_value('session_hide_lp_creation') === true && (isset($sessionId) && $sessionId != 0))) {
$actionLeft .= Display::url(
Display::return_icon(
'new_learnpath.png',
get_lang('LearnpathAddLearnpath'),
'',
ICON_SIZE_MEDIUM
),
api_get_self().'?'.api_get_cidreq().'&action=add_lp'
);
$actionLeft .= Display::url(
Display::return_icon(
'import_scorm.png',
get_lang('UploadScorm'),
'',
ICON_SIZE_MEDIUM
),
'../upload/index.php?'.api_get_cidreq().'&curdirpath=/&tool='.TOOL_LEARNPATH
);
}
if (api_get_setting('service_ppt2lp', 'active') === 'true') {
$actionLeft .= Display::url(
@ -200,6 +202,7 @@ $isInvitee = api_is_invitee();
$hideScormExportLink = api_get_setting('hide_scorm_export_link');
$hideScormCopyLink = api_get_setting('hide_scorm_copy_link');
$hideScormPdfLink = api_get_setting('hide_scorm_pdf_link');
$hideLpCopyInSession = (api_get_configuration_value('session_hide_lp_copy') === true && (isset($sessionId) && $sessionId != 0));
$options = learnpath::getIconSelect();
$cidReq = api_get_cidreq();
@ -925,7 +928,7 @@ foreach ($categories as $item) {
$dsp_disk = null;
}
if ($hideScormCopyLink === 'true') {
if ($hideScormCopyLink === 'true' || $hideLpCopyInSession) {
$copy = null;
}

@ -5,6 +5,8 @@
* @package chamilo.admin
*/
// resetting the course id
use Chamilo\CoreBundle\Component\Utils\ChamiloApi;
$cidReset = true;
require_once __DIR__.'/../inc/global.inc.php';
@ -14,8 +16,8 @@ $xajax->registerFunction('search_users');
// setting the section (for the tabs)
$this_section = SECTION_PLATFORM_ADMIN;
$id_session = isset($_GET['id_session']) ? (int) $_GET['id_session'] : 0;
$addProcess = isset($_GET['add']) && 'true' === $_GET['add'] ? 'true' : null;
$id_session = isset($_REQUEST['id_session']) ? (int) $_REQUEST['id_session'] : 0;
$addProcess = isset($_REQUEST['add']) && 'true' === $_REQUEST['add'] ? 'true' : null;
SessionManager::protectSession($id_session);
@ -65,6 +67,40 @@ if (is_array($extra_field_list)) {
}
}
if (ChamiloApi::isAjaxRequest() && isset($_POST['action'])) {
$id_session = isset($_POST['id_session']) ? (int) $_POST['id_session'] : 0;
$excludedUsers = isset($_POST['excludedUsers']) ? $_POST['excludedUsers'] : [];
$excludedUsersList = count($excludedUsers) > 0 ? implode(",", array_map('intval', $excludedUsers)) : '0';
if ($_POST['action'] == 'get_last_ten_users') {
$sql = "SELECT u.id, u.username, u.firstname, u.lastname
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user sru ON (u.id = sru.user_id AND sru.session_id = $id_session)
WHERE sru.user_id IS NULL
AND u.id NOT IN ($excludedUsersList)
ORDER BY u.id DESC
LIMIT 10";
} elseif ($_POST['action'] == 'get_all_users') {
$sql = "SELECT u.id, u.username, u.firstname, u.lastname
FROM $tbl_user u
LEFT JOIN $tbl_session_rel_user sru ON (u.id = sru.user_id AND sru.session_id = $id_session)
WHERE sru.user_id IS NULL
AND u.id NOT IN ($excludedUsersList)
ORDER BY u.lastname ASC, u.firstname ASC";
}
$result = Database::query($sql);
$users = [];
while ($row = Database::fetch_assoc($result)) {
$users[] = $row;
}
header('Content-Type: application/json');
echo json_encode($users);
die();
}
function search_users($needle, $type)
{
global $id_session;
@ -304,6 +340,77 @@ function change_select(val) {
xajax_search_users(val,"multiple");
}
</script>';
$htmlHeadXtra[] = '
<script>
function showLastTenUsers() {
var selectedUsers = [];
$("#destination_users option").each(function() {
selectedUsers.push($(this).val());
});
if (selectedUsers.length === 0) {
selectedUsers.push(0);
}
var idSession = "'.(int) $id_session.'";
$.post("'.api_get_self().'",
{
action: "get_last_ten_users",
excludedUsers: selectedUsers,
id_session: idSession,
add: "",
add_type: "multiple"
}, function(data) {
console.log(data);
var select = document.getElementById("origin_users");
select.innerHTML = "";
$.each(data, function(index, user) {
select.append(new Option(user.username + " - " + user.firstname + " " + user.lastname, user.id));
});
}, "json").fail(function(xhr, status, error) {
console.error("Error en la solicitud AJAX: " + error);
console.log(xhr.responseText);
});
}
function loadAllUsers() {
var selectedUsers = [];
$("#destination_users option").each(function() {
selectedUsers.push($(this).val());
});
if (selectedUsers.length === 0) {
selectedUsers.push(0);
}
var idSession = "'.(int) $id_session.'";
$.post("'.api_get_self().'",
{
action: "get_all_users",
excludedUsers: selectedUsers,
id_session: idSession,
add: "",
add_type: "multiple"
}, function(data) {
var select = document.getElementById("origin_users");
select.innerHTML = "";
$.each(data, function(index, user) {
select.append(new Option(user.username + " - " + user.firstname + " " + user.lastname, user.id));
});
}, "json").fail(function(xhr, status, error) {
console.error("Error en la solicitud AJAX: " + error);
});
}
$(document).ready(function() {
loadAllUsers();
$("#show_last_ten_users_button").on("click", showLastTenUsers);
$("#reset_users_button").on("click", loadAllUsers);
});
</script>
';
$form_sent = 0;
$errorMsg = $firstLetterUser = $firstLetterSession = '';
@ -691,6 +798,14 @@ $newLinks .= Display::url(
<?php
echo Display::get_alphabet_options(); ?>
</select>
<span class="input-group-btn">
<button class="btn btn-default" type="button" id="show_last_ten_users_button" title="<?php echo get_lang('ShowLastTenUsers') ?>">
<i class="fa fa-clock-o"></i>
</button>
<button class="btn btn-default" type="button" id="reset_users_button" title="<?php echo get_lang('Reset') ?>">
<i class="fa fa-refresh"></i>
</button>
</span>
<br/>
<br/>
<?php

Loading…
Cancel
Save