Skip to content

Commit 798af0f

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents dc4d7c8 + 307441c commit 798af0f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1214
-529
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,4 +204,4 @@ In short, we ask you to send us Pull Requests based on a branch that you create
204204
with this purpose into your repository forked from the original Chamilo repository.
205205

206206
# Documentation
207-
For more information on Chamilo, visit https://1.11.chamilo.org/documentation/index.html
207+
For more information on Chamilo, visit https://11.chamilo.org/documentation/index.html

main/admin/index.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -541,14 +541,20 @@
541541
}
542542

543543
$blockPlatform['items'] = $items;
544-
} elseif (api_is_session_admin() && api_get_configuration_value('session_admin_access_system_announcement')) {
544+
} elseif (api_is_session_admin()) {
545545
$items = [];
546546
$items[] = [
547-
'class' => 'item-global-announcement',
548-
'url' => 'system_announcements.php',
549-
'label' => get_lang('SystemAnnouncements'),
547+
'class' => 'item-stats',
548+
'url' => 'statistics/index.php',
549+
'label' => get_lang('Statistics'),
550550
];
551-
551+
if (api_get_configuration_value('session_admin_access_system_announcement')) {
552+
$items[] = [
553+
'class' => 'item-global-announcement',
554+
'url' => 'system_announcements.php',
555+
'label' => get_lang('SystemAnnouncements'),
556+
];
557+
}
552558
$blockPlatform['items'] = $items;
553559
}
554560

main/admin/statistics/index.php

Lines changed: 67 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$cidReset = true;
99

1010
require_once __DIR__.'/../../inc/global.inc.php';
11-
api_protect_admin_script();
11+
api_protect_admin_script(true);
1212

1313
$interbreadcrumb[] = ['url' => '../index.php', 'name' => get_lang('PlatformAdmin')];
1414

@@ -18,6 +18,72 @@
1818
$sessionStatusAllowed = api_get_configuration_value('allow_session_status');
1919
$invoicingMonth = isset($_GET['invoicing_month']) ? (int) $_GET['invoicing_month'] : '';
2020
$invoicingYear = isset($_GET['invoicing_year']) ? (int) $_GET['invoicing_year'] : '';
21+
$tool_name = get_lang('Statistics');
22+
if (api_is_platform_admin()) {
23+
$tools = [
24+
get_lang('Courses') => [
25+
'report=courses' => get_lang('CountCours'),
26+
'report=tools' => get_lang('PlatformToolAccess'),
27+
'report=courselastvisit' => get_lang('LastAccess'),
28+
'report=coursebylanguage' => get_lang('CountCourseByLanguage'),
29+
],
30+
get_lang('Users') => [
31+
'report=users' => get_lang('CountUsers'),
32+
'report=recentlogins' => get_lang('Logins'),
33+
'report=logins&type=month' => get_lang('Logins') . ' (' . get_lang('PeriodMonth') . ')',
34+
'report=logins&type=day' => get_lang('Logins') . ' (' . get_lang('PeriodDay') . ')',
35+
'report=logins&type=hour' => get_lang('Logins') . ' (' . get_lang('PeriodHour') . ')',
36+
'report=pictures' => get_lang('CountUsers') . ' (' . get_lang('UserPicture') . ')',
37+
'report=logins_by_date' => get_lang('LoginsByDate'),
38+
'report=no_login_users' => get_lang('StatsUsersDidNotLoginInLastPeriods'),
39+
'report=zombies' => get_lang('Zombies'),
40+
'report=users_active' => get_lang('UserStats'),
41+
'report=users_online' => get_lang('UsersOnline'),
42+
'report=invoicing' => get_lang('InvoicingByAccessUrl'),
43+
'report=duplicated_users' => get_lang('DuplicatedUsers'),
44+
'report=duplicated_users_by_mail' => get_lang('DuplicatedUsersByMail'),
45+
],
46+
get_lang('System') => [
47+
'report=activities' => get_lang('ImportantActivities'),
48+
'report=user_session' => get_lang('PortalUserSessionStats'),
49+
'report=courses_usage' => get_lang('CoursesUsage'),
50+
'report=quarterly_report' => get_lang('QuarterlyReport'),
51+
],
52+
get_lang('Social') => [
53+
'report=messagereceived' => get_lang('MessagesReceived'),
54+
'report=messagesent' => get_lang('MessagesSent'),
55+
'report=friends' => get_lang('CountFriends'),
56+
],
57+
get_lang('Session') => [
58+
'report=session_by_date' => get_lang('SessionsByDate'),
59+
],
60+
];
61+
62+
if ('true' === api_get_plugin_setting('lti_provider', 'enabled')) {
63+
$tools[get_lang('Users')]['report=lti_tool_lp'] = get_lang('LearningPathLTI');
64+
}
65+
} elseif (api_is_session_admin()) {
66+
$tools = [
67+
get_lang('Session') => [
68+
'report=session_by_date' => get_lang('SessionsByDate'),
69+
],
70+
];
71+
}
72+
73+
// Get list of allowed reports based on role
74+
$allowedReports = [];
75+
foreach ($tools as $section => $items) {
76+
foreach ($items as $key => $label) {
77+
if (preg_match('/report=([a-zA-Z0-9_]+)/', $key, $matches)) {
78+
$allowedReports[] = $matches[1];
79+
}
80+
}
81+
}
82+
83+
// Ensure current report is valid for this user, or default to first available
84+
if (!in_array($report, $allowedReports)) {
85+
$report = reset($allowedReports);
86+
}
2187

2288
if (
2389
in_array(
@@ -334,50 +400,6 @@
334400
ob_start();
335401
}
336402

337-
$tool_name = get_lang('Statistics');
338-
$tools = [
339-
get_lang('Courses') => [
340-
'report=courses' => get_lang('CountCours'),
341-
'report=tools' => get_lang('PlatformToolAccess'),
342-
'report=courselastvisit' => get_lang('LastAccess'),
343-
'report=coursebylanguage' => get_lang('CountCourseByLanguage'),
344-
],
345-
get_lang('Users') => [
346-
'report=users' => get_lang('CountUsers'),
347-
'report=recentlogins' => get_lang('Logins'),
348-
'report=logins&type=month' => get_lang('Logins').' ('.get_lang('PeriodMonth').')',
349-
'report=logins&type=day' => get_lang('Logins').' ('.get_lang('PeriodDay').')',
350-
'report=logins&type=hour' => get_lang('Logins').' ('.get_lang('PeriodHour').')',
351-
'report=pictures' => get_lang('CountUsers').' ('.get_lang('UserPicture').')',
352-
'report=logins_by_date' => get_lang('LoginsByDate'),
353-
'report=no_login_users' => get_lang('StatsUsersDidNotLoginInLastPeriods'),
354-
'report=zombies' => get_lang('Zombies'),
355-
'report=users_active' => get_lang('UserStats'),
356-
'report=users_online' => get_lang('UsersOnline'),
357-
'report=invoicing' => get_lang('InvoicingByAccessUrl'),
358-
'report=duplicated_users' => get_lang('DuplicatedUsers'),
359-
'report=duplicated_users_by_mail' => get_lang('DuplicatedUsersByMail'),
360-
],
361-
get_lang('System') => [
362-
'report=activities' => get_lang('ImportantActivities'),
363-
'report=user_session' => get_lang('PortalUserSessionStats'),
364-
'report=courses_usage' => get_lang('CoursesUsage'),
365-
'report=quarterly_report' => get_lang('QuarterlyReport'),
366-
],
367-
get_lang('Social') => [
368-
'report=messagereceived' => get_lang('MessagesReceived'),
369-
'report=messagesent' => get_lang('MessagesSent'),
370-
'report=friends' => get_lang('CountFriends'),
371-
],
372-
get_lang('Session') => [
373-
'report=session_by_date' => get_lang('SessionsByDate'),
374-
],
375-
];
376-
377-
if ('true' === api_get_plugin_setting('lti_provider', 'enabled')) {
378-
$tools[get_lang('Users')]['report=lti_tool_lp'] = get_lang('LearningPathLTI');
379-
}
380-
381403
$course_categories = Statistics::getCourseCategories();
382404
$content = '';
383405

main/admin/sub_language_add.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,9 +209,8 @@ function allow_get_all_information_of_sub_language($parent_id, $sub_language_id)
209209

210210
if (isset($_POST['SubmitAddNewLanguage'])) {
211211
$original_name = $_POST['original_name'];
212-
$english_name = $_POST['english_name'];
213212
$isocode = $_POST['isocode'];
214-
$english_name = str_replace(' ', '_', $english_name);
213+
$english_name = api_replace_dangerous_char($_POST['english_name']);
215214
$isocode = str_replace(' ', '_', $isocode);
216215

217216
$sublanguage_available = $_POST['sub_language_is_visible'];
@@ -298,14 +297,11 @@ function allow_get_all_information_of_sub_language($parent_id, $sub_language_id)
298297
);
299298
$class = 'add';
300299
$form->addElement('header', '', $text);
301-
$form->addElement('text', 'original_name', get_lang('OriginalName'), 'class="input_titles"');
302-
$form->addRule('original_name', get_lang('ThisFieldIsRequired'), 'required');
303-
$form->addElement('text', 'english_name', get_lang('EnglishName'), 'class="input_titles"');
304-
$form->addRule('english_name', get_lang('ThisFieldIsRequired'), 'required');
305-
$form->addElement('text', 'isocode', get_lang('ISOCode'), 'class="input_titles"');
306-
$form->addRule('isocode', get_lang('ThisFieldIsRequired'), 'required');
300+
$form->addText('original_name', get_lang('OriginalName'));
301+
$form->addText('english_name', get_lang('EnglishName'));
302+
$form->addText('isocode', get_lang('ISOCode'));
307303
$form->addElement('static', null, '&nbsp;', '<i>en, es, fr</i>');
308-
$form->addElement('checkbox', 'sub_language_is_visible', '', get_lang('Visibility'));
304+
$form->addCheckBox('sub_language_is_visible', '', get_lang('Visibility'));
309305
$form->addButtonCreate(get_lang('CreateSubLanguage'), 'SubmitAddNewLanguage');
310306
//$values['original_name'] = $language_details['original_name'].'...'; -> cannot be used because of quickform filtering (freeze)
311307
$values['english_name'] = $language_details['english_name'].'2';

main/admin/sub_language_ajax.inc.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,15 @@
1414
api_protect_admin_script();
1515

1616
$new_language = Security::remove_XSS($_REQUEST['new_language']);
17-
$language_variable = Security::remove_XSS($_REQUEST['variable_language']);
17+
$language_variable = ltrim(
18+
Security::remove_XSS($_REQUEST['variable_language']),
19+
'$'
20+
);
1821
$file_id = intval($_REQUEST['file_id']);
1922

20-
if (isset($new_language) && isset($language_variable) && isset($file_id)) {
23+
$variableIsValid = isset($language_variable) && preg_match('/^[a-zA-Z_][a-zA-Z0-9_]*$/', $language_variable);
24+
25+
if (isset($new_language) && $variableIsValid && isset($file_id)) {
2126
$file_language = $language_files_to_load[$file_id].'.inc.php';
2227
$id_language = intval($_REQUEST['id']);
2328
$sub_language_id = intval($_REQUEST['sub']);
@@ -27,12 +32,7 @@
2732
$all_file_of_directory = SubLanguageManager::get_all_language_variable_in_file($path_folder);
2833
$return_value = SubLanguageManager::add_file_in_language_directory($path_folder);
2934

30-
//update variable language
31-
// Replace double quotes to avoid parse errors
32-
$new_language = str_replace('"', '\"', $new_language);
33-
// Replace new line signs to avoid parse errors - see #6773
34-
$new_language = str_replace("\n", "\\n", $new_language);
35-
$all_file_of_directory[$language_variable] = "\"".$new_language."\";";
35+
$all_file_of_directory[$language_variable] = $new_language;
3636
$result_array = [];
3737

3838
foreach ($all_file_of_directory as $key_value => $value_info) {

main/auth/openid/login.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,10 +298,17 @@ function openid_verify_assertion($op_endpoint, $response) {
298298

299299
//TODO
300300
$openid_association = Database::get_main_table(TABLE_MAIN_OPENID_ASSOCIATION);
301-
$sql = sprintf("SELECT * FROM $openid_association WHERE assoc_handle = '%s'", $response['openid.assoc_handle']);
302-
$res = Database::query($sql);
303-
$association = Database::fetch_object($res);
304-
if ($association && isset($association->session_type)) {
301+
$association = Database::select(
302+
'*',
303+
$openid_association,
304+
[
305+
'where' => [
306+
'assoc_handle = ?' => [$response['openid.assoc_handle']],
307+
]
308+
],
309+
'first'
310+
);
311+
if ($association && isset($association['session_type'])) {
305312
$keys_to_sign = explode(',', $response['openid.signed']);
306313
$self_sig = _openid_signature($association, $response, $keys_to_sign);
307314
if ($self_sig == $response['openid.sig']) {

main/auth/openid/openid.lib.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,14 +201,14 @@ function _openid_meta_httpequiv($equiv, $html) {
201201

202202
/**
203203
* Sign certain keys in a message
204-
* @param $association - object loaded from openid_association or openid_server_association table
204+
* @param $association - array loaded from openid_association or openid_server_association table
205205
* - important fields are ->assoc_type and ->mac_key
206206
* @param $message_array - array of entire message about to be sent
207207
* @param $keys_to_sign - keys in the message to include in signature (without
208208
* 'openid.' appended)
209209
*/
210-
function _openid_signature($association, $message_array, $keys_to_sign) {
211-
$signature = '';
210+
function _openid_signature(array $association, $message_array, $keys_to_sign): string
211+
{
212212
$sign_data = array();
213213

214214
foreach ($keys_to_sign as $key) {
@@ -218,7 +218,7 @@ function _openid_signature($association, $message_array, $keys_to_sign) {
218218
}
219219

220220
$message = _openid_create_message($sign_data);
221-
$secret = base64_decode($association->mac_key);
221+
$secret = base64_decode($association['mac_key']);
222222
$signature = _openid_hmac($secret, $message);
223223

224224
return base64_encode($signature);

main/coursecopy/copy_course_session_selected.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
api_not_allowed(true);
3434
}
3535

36-
$action = isset($_POST['action']) ? $_POST['action'] : '';
36+
$action = $_POST['action'] ?? '';
3737

3838
$courseId = api_get_course_int_id();
3939
$courseInfo = api_get_course_info_by_id($courseId);
@@ -52,10 +52,7 @@
5252
'name' => get_lang('Maintenance'),
5353
];
5454

55-
/**
56-
* @param string $name
57-
*/
58-
function make_select_session_list($name, $sessions, $attr = [])
55+
function make_select_session_list($name, $sessions, $attr = []): string
5956
{
6057
$attrs = '';
6158
if (count($attr) > 0) {
@@ -184,7 +181,7 @@ function displayForm()
184181
echo $html;
185182
}
186183

187-
function searchCourses($idSession, $type)
184+
function searchCourses($idSession, $type): xajaxResponse
188185
{
189186
$xajaxResponse = new xajaxResponse();
190187
$return = null;
@@ -193,6 +190,7 @@ function searchCourses($idSession, $type)
193190
if (!empty($type)) {
194191
$idSession = (int) $idSession;
195192
$courseList = SessionManager::get_course_list_by_session_id($idSession);
193+
$course_list_destination = [];
196194

197195
$return .= '<select id="destination" name="SessionCoursesListDestination[]" style="width:380px;" >';
198196

@@ -292,8 +290,6 @@ function checkSelected(id_select,id_radio,id_title,id_destination) {
292290
$cr = new CourseRestorer($course);
293291
$cr->restore($destinationCourse, $destinationSession);
294292
echo Display::return_message(get_lang('CopyFinished'), 'confirmation');
295-
296-
displayForm();
297293
} else {
298294
$arrCourseOrigin = [];
299295
$arrCourseDestination = [];
@@ -334,15 +330,16 @@ function checkSelected(id_select,id_radio,id_title,id_destination) {
334330
echo Display::return_message(get_lang('CopyFinished'), 'confirmation');
335331
}
336332

337-
displayForm();
338333
} else {
339334
echo Display::return_message(
340335
get_lang('YouMustSelectACourseFromOriginalSession'),
341336
'error'
342337
);
343-
displayForm();
344338
}
339+
345340
}
341+
342+
displayForm();
346343
} elseif (isset($_POST['copy_option']) && $_POST['copy_option'] == 'select_items') {
347344
// Else, if a CourseSelectForm is requested, show it
348345
if (api_get_setting('show_glossary_in_documents') != 'none') {

main/cron/lang/langstats.class.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,10 +190,7 @@ public function get_variables_origin()
190190
$vars = [];
191191
$priority = ['trad4all'];
192192
foreach ($priority as $file) {
193-
$list = SubLanguageManager::get_all_language_variable_in_file(
194-
$path.$file.'.inc.php',
195-
true
196-
);
193+
$list = SubLanguageManager::get_all_language_variable_in_file($path.$file.'.inc.php');
197194
foreach ($list as $var => $trad) {
198195
$vars[$var] = $file.'.inc.php';
199196
}
@@ -203,10 +200,7 @@ public function get_variables_origin()
203200
if (substr($file, 0, 1) == '.' or in_array($file, $priority)) {
204201
continue;
205202
}
206-
$list = SubLanguageManager::get_all_language_variable_in_file(
207-
$path.$file,
208-
true
209-
);
203+
$list = SubLanguageManager::get_all_language_variable_in_file($path.$file);
210204
foreach ($list as $var => $trad) {
211205
$vars[$var] = $file;
212206
}

main/cron/lang/list_undefined_langvars.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
foreach ($list as $entry) {
2121
$file = $path.'/'.$entry;
2222
if (is_file($file)) {
23-
$terms = array_merge($terms, SubLanguageManager::get_all_language_variable_in_file($file, true));
23+
$terms = array_merge($terms, SubLanguageManager::get_all_language_variable_in_file($file));
2424
}
2525
}
2626
// get only the array keys (the language variables defined in language files)

0 commit comments

Comments
 (0)