Skip to content

Commit 2ac4d47

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents 59cc88e + efe308b commit 2ac4d47

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

+659
-158
lines changed

app/config/mail.conf.dist.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
$platform_email['DKIM_DOMAIN'] = 'mydomain.com'; //the domain for e-mail sending, not necessarily api_get_path(WEB_PATH)
4141
$platform_email['DKIM_PRIVATE_KEY_STRING'] = ''; //the private key in a string format
4242
$platform_email['DKIM_PRIVATE_KEY'] = ''; //the private key as the path to a file. The file needs to be accessible to PHP!
43+
$platform_email['DKIM_PASSPHRASE'] = ''; //the passohrase for the private key defined in the last 2 lines
4344
// Some e-mail clients do not understand the descriptive LD+JSON format,
4445
// showing it as a loose JSON string to the final user. If this is your case,
4546
// you might want to set the variable below to 'false' to disable this header.

main/admin/add_users_to_usergroup.php

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
// setting the name of the tool
2727
$tool_name = get_lang('SubscribeUsersToClass');
28+
$showAllStudentByDefault = api_get_configuration_value('usergroup_add_user_show_all_student_by_default');
2829

2930
$htmlHeadXtra[] = '
3031
<script>
@@ -35,6 +36,11 @@
3536
});
3637
});
3738
39+
function activeUsers(originalUrl) {
40+
var searchValue = document.getElementById("first_letter_user").value;
41+
window.location.href = originalUrl + "&firstLetterUser=" + encodeURIComponent(searchValue);
42+
}
43+
3844
function add_user_to_session (code, content) {
3945
document.getElementById("user_to_add").value = "";
4046
document.getElementById("ajax_list_users_single").innerHTML = "";
@@ -87,7 +93,7 @@ function change_select(reset) {
8793
if (reset) {
8894
document.formulaire["first_letter_user"].value = "";
8995
90-
if ('.(api_get_configuration_value('usergroup_add_user_show_all_student_by_default') ? 0 : 1).') {
96+
if ('.($showAllStudentByDefault ? 0 : 1).') {
9197
document.formulaire["form_sent"].value = "1";
9298
9399
return;
@@ -129,10 +135,10 @@ function change_select(reset) {
129135

130136
$first_letter_user = '';
131137

132-
if (isset($_POST['form_sent']) && $_POST['form_sent']) {
138+
if ((isset($_POST['form_sent']) && $_POST['form_sent']) || isset($_REQUEST['firstLetterUser'])) {
133139
$form_sent = $_POST['form_sent'];
134140
$elements_posted = $_POST['elements_in_name'] ?? null;
135-
$first_letter_user = $_POST['firstLetterUser'];
141+
$first_letter_user = Security::remove_XSS($_REQUEST['firstLetterUser']);
136142

137143
if (!is_array($elements_posted)) {
138144
$elements_posted = [];
@@ -247,7 +253,9 @@ function change_select(reset) {
247253
}
248254

249255
$activeUser = isset($_REQUEST['active_users']) ? (int) $_REQUEST['active_users'] : null;
250-
$conditions['active'] = $activeUser;
256+
if (1 === $activeUser) {
257+
$conditions['active'] = $activeUser;
258+
}
251259

252260
$filterData = [];
253261
if ($searchForm->validate()) {
@@ -268,7 +276,7 @@ function change_select(reset) {
268276
foreach ($list_in as $listedUserId) {
269277
$userInfo = api_get_user_info($listedUserId);
270278

271-
if (isset($activeUser) && ((int) $activeUser != $userInfo['active'])) {
279+
if (1 === $activeUser && empty($userInfo['active'])) {
272280
$hideElementsIn[] = $listedUserId;
273281
continue;
274282
}
@@ -279,7 +287,7 @@ function change_select(reset) {
279287
$user_with_any_group = !empty($_REQUEST['user_with_any_group']);
280288
$user_list = [];
281289

282-
if (!empty($conditions)) {
290+
if (!(!$showAllStudentByDefault && !isset($_POST['firstLetterUser']) && !isset($_REQUEST['active_users'])) && !$user_with_any_group) {
283291
$user_list = UserManager::getUserListLike($conditions, $order, true, 'OR');
284292
}
285293

@@ -306,17 +314,16 @@ function change_select(reset) {
306314
continue;
307315
}
308316

309-
if (isset($activeUser) && ((int) $activeUser != $item['active'])) {
310-
continue;
311-
}
312-
313317
if (!in_array($item['user_id'], $list_in)) {
314318
$elements_not_in[$item['user_id']] = formatCompleteName($item, $orderListByOfficialCode);
315319
}
316320
}
317321
}
318322

319-
if (api_get_configuration_value('usergroup_add_user_show_all_student_by_default')
323+
if (!$showAllStudentByDefault && !isset($_POST['firstLetterUser']) && !isset($_REQUEST['active_users'])) {
324+
$elements_not_in = [];
325+
}
326+
if ($showAllStudentByDefault
320327
&& empty($elements_not_in)
321328
&& empty($first_letter_user)
322329
) {
@@ -362,13 +369,13 @@ function formatCompleteName(array $userInfo, bool $orderListByOfficialCode): str
362369
echo '<a href="'.api_get_self().'?id='.$id.'&action=export">'.
363370
Display::return_icon('export_csv.png', get_lang('Export'), [], ICON_SIZE_MEDIUM).'</a>';
364371

365-
$newUrl = api_get_self().'?id='.$id.'&active_users=1';
366-
$buttonLabel = get_lang('OnlyShowActiveUsers');
367-
if ($activeUser) {
368-
$buttonLabel = get_lang('ShowAllUsers') ;
369-
$newUrl = api_get_self().'?id='.$id;
370-
}
371-
echo '<a href="' . htmlspecialchars($newUrl) . '" class="btn btn-default">' . $buttonLabel . '</a>';
372+
$isActiveUser = !empty($activeUser);
373+
$activeUsersParam = $isActiveUser ? '0' : '1';
374+
$newUrl = api_get_self() . '?id=' . $id . '&active_users=' . $activeUsersParam;
375+
$buttonLabelKey = $isActiveUser ? 'ShowAllUsers' : 'OnlyShowActiveUsers';
376+
$buttonLabel = get_lang($buttonLabelKey);
377+
378+
echo '<a href="#" onclick="activeUsers(\'' . htmlspecialchars($newUrl) . '\'); return false;" class="btn btn-default">' . $buttonLabel . '</a>';
372379

373380
echo '</div>';
374381

main/admin/index.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,15 @@
194194
return !in_array($item['url'], $urls);
195195
});
196196
}
197+
198+
$allowJustification = ((api_get_plugin_setting('justification', 'tool_enable') === 'true') && (api_get_plugin_setting('justification', 'access_for_session_admin') === 'true'));
199+
if ($allowJustification) {
200+
$items[] = [
201+
'class' => 'item-justification-list',
202+
'url' => api_get_path(WEB_PLUGIN_PATH).'justification/list.php',
203+
'label' => get_lang('Justification'),
204+
];
205+
}
197206
}
198207

199208
if (api_get_configuration_value('allow_session_admin_extra_access')) {

main/admin/statistics/index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1501,7 +1501,7 @@
15011501
foreach ($intervals as $minutes) {
15021502
$sql = "SELECT count(distinct(user_id))
15031503
FROM $table WHERE
1504-
DATE_ADD(tms, INTERVAL '$minutes' MINUTE) > UTC_TIMESTAMP()";
1504+
tms > DATE_SUB(UTC_TIMESTAMP(), INTERVAL '$minutes' MINUTE)";
15051505
$query = Database::query($sql);
15061506
$counts[$minutes] = 0;
15071507
if (Database::num_rows($query) > 0) {

main/admin/user_import.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,8 @@ function validate_data($users, $checkUniqueEmail = false)
153153
} else {
154154
$userFromEmail = api_get_user_info_from_email($user['Email']);
155155
if (!empty($userFromEmail)) {
156+
$user['id'] = $userFromEmail['id'];
157+
$user['UserName'] = $userFromEmail['username'];
156158
$user['message'] .= Display::return_message(get_lang('EmailUsedTwice'), 'warning');
157159
$user['has_error'] = true;
158160
} else {

main/admin/user_list.php

Lines changed: 47 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -476,22 +476,44 @@ function get_user_data($from, $number_of_items, $column, $direction)
476476
$user[7] = '-1';
477477
}
478478
}
479-
480-
// forget about the expiration date field
481-
$users[] = [
482-
$user[0], // id
483-
$photo,
484-
$user[1],
485-
$user[2],
486-
$user[3],
487-
$user[4], // username
488-
$user[5], // email
489-
$user[6],
490-
$user[7], // active
491-
api_get_local_time($user[8]),
492-
api_get_local_time($user[9], null, null, true),
493-
$user[0],
494-
];
479+
if (api_get_configuration_value('admin_user_list_add_first_connexion_column')) {
480+
$firstConnectionDate = Tracking::get_first_connection_date($user[0]);
481+
if ($firstConnectionDate == '') {
482+
$firstConnectionDate = get_lang('NoConnexion');
483+
}
484+
// forget about the expiration date field
485+
$users[] = [
486+
$user[0], // id
487+
$photo,
488+
$user[1],
489+
$user[2],
490+
$user[3],
491+
$user[4], // username
492+
$user[5], // email
493+
$user[6],
494+
$user[7], // active
495+
api_get_local_time($user[8]),
496+
api_get_local_time($user[9], null, null, true),
497+
$firstConnectionDate,
498+
$user[0],
499+
];
500+
} else {
501+
// forget about the expiration date field
502+
$users[] = [
503+
$user[0], // id
504+
$photo,
505+
$user[1],
506+
$user[2],
507+
$user[3],
508+
$user[4], // username
509+
$user[5], // email
510+
$user[6],
511+
$user[7], // active
512+
api_get_local_time($user[8]),
513+
api_get_local_time($user[9], null, null, true),
514+
$user[0],
515+
];
516+
}
495517
}
496518

497519
return $users;
@@ -542,7 +564,7 @@ function modify_filter($user_id, $url_params, $row)
542564
$is_admin = in_array($user_id, $_admins_list);
543565
$statusname = api_get_status_langvars();
544566
$user_is_anonymous = false;
545-
$current_user_status_label = $row['7'];
567+
$current_user_status_label = $statusname[$row['7']];
546568

547569
if ($current_user_status_label == $statusname[ANONYMOUS]) {
548570
$user_is_anonymous = true;
@@ -1077,14 +1099,20 @@ class="btn btn-default advanced_options" onclick="display_advanced_search_form()
10771099
$table->set_header(8, get_lang('Active'));
10781100
$table->set_header(9, get_lang('RegistrationDate'));
10791101
$table->set_header(10, get_lang('LatestLogin'));
1080-
$table->set_header(11, get_lang('Action'), false);
1102+
if (api_get_configuration_value('admin_user_list_add_first_connexion_column')) {
1103+
$table->set_header(11, get_lang('FirstLoginInPlatform'), false);
1104+
$table->set_header(12, get_lang('Action'), false);
1105+
$table->set_column_filter(12, 'modify_filter');
1106+
} else {
1107+
$table->set_header(11, get_lang('Action'), false);
1108+
$table->set_column_filter(11, 'modify_filter');
1109+
}
10811110

10821111
$table->set_column_filter(3, 'user_filter');
10831112
$table->set_column_filter(4, 'user_filter');
10841113
$table->set_column_filter(6, 'email_filter');
10851114
$table->set_column_filter(7, 'status_filter');
10861115
$table->set_column_filter(8, [UserManager::class, 'getActiveFilterForTable']);
1087-
$table->set_column_filter(11, 'modify_filter');
10881116

10891117
// Hide email column if login is email, to avoid column with same data
10901118
if (api_get_setting('login_is_email') === 'true') {

main/admin/user_move_stats.php

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -60,12 +60,14 @@
6060
echo 'User added to the session';
6161
}
6262
// Registering user to the new session
63-
SessionManager::subscribeUsersToSession(
64-
$new_session_id,
65-
[$user_id],
66-
false,
67-
false
68-
);
63+
if ($update_database) {
64+
SessionManager::subscribeUsersToSession(
65+
$new_session_id,
66+
[$user_id],
67+
false,
68+
false
69+
);
70+
}
6971
}
7072

7173
$course_info = api_get_course_info($origin_course_code);
@@ -247,8 +249,8 @@ function get_courses_list_by_user_id_based_in_exercises($user_id)
247249
echo '<tr>';
248250
foreach ($course_list as $course) {
249251
echo '<td>';
250-
if (isset($course['id_session']) && !empty($course['id_session'])) {
251-
echo '<b>'.get_lang('SessionName').'</b> '.$my_session_list[$course['id_session']].'<br />';
252+
if (isset($course['session_id']) && !empty($course['session_id'])) {
253+
echo '<b>'.get_lang('SessionName').'</b> '.$my_session_list[$course['session_id']].'<br />';
252254
}
253255
echo $course['name'];
254256
echo ' ('.$course['code'].') ';
@@ -262,10 +264,10 @@ function get_courses_list_by_user_id_based_in_exercises($user_id)
262264

263265
foreach ($course_list as $course) {
264266
$course_code = $course['code'];
265-
if (empty($course['id_session'])) {
267+
if (empty($course['session_id'])) {
266268
$session_id = 0;
267269
} else {
268-
$session_id = $course['id_session'];
270+
$session_id = $course['session_id'];
269271
}
270272
echo '<td>';
271273
echo get_lang('MoveTo');

main/auth/justification.php

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,32 @@
8383
$justificationContent = '';
8484
switch ($action) {
8585
case 'notify_justification':
86-
// notification to all admins action
87-
$userInfo = api_get_user_info();
88-
// get_all_administrators
89-
$adminList = UserManager::get_all_administrators();
90-
$link = api_get_path(WEB_PATH).'plugin/justification/justification_by_user.php?user_id='.api_get_user_id();
91-
$emailToAdminSubject = $plugin->get_lang('JustificationsCompleted').': '.$userInfo['complete_name'];
92-
$emailToAdminContent = $emailToAdminSubject.' <br /><br />'.'<a href="'.$link.'">'.$link.'</a>';
93-
foreach ($adminList as $adminId => $data) {
94-
MessageManager::send_message_simple(
95-
$adminId,
96-
$emailToAdminSubject,
97-
$emailToAdminContent,
98-
api_get_user_id());
86+
$link = api_get_path(WEB_PATH).'plugin/justification/justification_by_user.php?user_id='.api_get_user_id();
87+
$notificationEmailSubject = $plugin->get_lang('JustificationsCompleted').': '.$userInfo['complete_name'];
88+
$notificationEmailContent = $notificationEmailSubject.' <br /><br />'.'<a href="'.$link.'">'.$link.'</a>';
89+
if (api_get_plugin_setting('justification', 'notification_to_creator_only') === 'true') {
90+
$sql = "select creator_id from user where user_id = " . api_get_user_id();
91+
$result = Database::query($sql);
92+
if (Database::num_rows($result) > 0) {
93+
$row = Database::fetch_array($result);
94+
$sendToAllAdmins = false;
95+
MessageManager::send_message_simple(
96+
$row['creator_id'],
97+
$notificationEmailSubject,
98+
$notificationEmailContent,
99+
api_get_user_id());
100+
}
101+
}
102+
if ($sendToAllAdmins) {
103+
// get_all_administrators
104+
$adminList = UserManager::get_all_administrators();
105+
foreach ($adminList as $adminId => $data) {
106+
MessageManager::send_message_simple(
107+
$adminId,
108+
$notificationEmailSubject,
109+
$notificationEmailContent,
110+
api_get_user_id());
111+
}
99112
}
100113
Display::addFlash(Display::return_message(get_lang('MessageSent')));
101114
header('Location: '.api_get_self().'?a=notification_sent');

main/course_info/about.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
require_once __DIR__.'/../inc/global.inc.php';
2020

21-
if (api_get_setting('course_catalog_published') != 'true' && api_is_anonymous()) {
21+
if ((api_get_setting('course_catalog_published') != 'true' && api_is_anonymous()) || api_get_configuration_value('course_about_block_all_access') == 'true') {
2222
api_not_allowed(true);
2323
}
2424

main/inc/ajax/announcement.ajax.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
$courseId = api_get_course_int_id();
1515
$groupId = api_get_group_id();
1616
$sessionId = api_get_session_id();
17+
$currentUserId = api_get_user_id();
1718

1819
$isTutor = false;
1920
if (!empty($groupId)) {
@@ -26,9 +27,13 @@
2627

2728
switch ($action) {
2829
case 'preview':
30+
$userInCourse = false;
31+
if (CourseManager::is_user_subscribed_in_course($currentUserId, CourseManager::get_course_code_from_course_id($courseId), $sessionId)) {
32+
$userInCourse = true;
33+
}
2934
$allowToEdit = (
3035
api_is_allowed_to_edit(false, true) ||
31-
(api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous()) ||
36+
(api_get_course_setting('allow_user_edit_announcement') && !api_is_anonymous() && $userInCourse) ||
3237
($sessionId && api_is_coach() && api_get_configuration_value('allow_coach_to_edit_announcements'))
3338
);
3439

@@ -47,7 +52,11 @@
4752

4853
// Last chance ... students can send announcements.
4954
if ($groupProperties['announcements_state'] == GroupManager::TOOL_PRIVATE_BETWEEN_USERS) {
50-
$allowToEdit = true;
55+
// check if user is a group member to give access
56+
$groupInfo = GroupManager::get_group_properties($groupId);
57+
if (array_key_exists($currentUserId,GroupManager::get_subscribed_users($groupInfo))) {
58+
$allowToEdit = true;
59+
}
5160
}
5261
}
5362

0 commit comments

Comments
 (0)