Skip to content

Commit 2542b38

Browse files
committed
Merge branch '1.11.x' of github.com:chamilo/chamilo-lms into 1.11.x
2 parents be94e40 + 0712adb commit 2542b38

File tree

8 files changed

+74
-30
lines changed

8 files changed

+74
-30
lines changed

main/exercise/fill_blanks.class.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ function (&$value, $key, $tabBlankChar) {
893893
// should always be
894894
$i++;
895895
}
896-
$listAnswerResults['student_answer'][] = $listAnswerResults['words'][$i];
896+
$listAnswerResults['student_answer'][] = Security::remove_XSS($listAnswerResults['words'][$i]);
897897
if ($i + 1 < count($listAnswerResults['words'])) {
898898
// should always be
899899
$i++;
@@ -1238,13 +1238,13 @@ public static function getHtmlDisplayForAnswer(
12381238
continue;
12391239
}
12401240
}
1241-
$result .= isset($listStudentAnswerInfo['common_words'][$i]) ? $listStudentAnswerInfo['common_words'][$i] : '';
1242-
$studentLabel = isset($listStudentAnswerInfo['student_answer'][$i]) ? $listStudentAnswerInfo['student_answer'][$i] : '';
1241+
$result .= $listStudentAnswerInfo['common_words'][$i] ?? '';
1242+
$studentLabel = $listStudentAnswerInfo['student_answer'][$i] ?? '';
12431243
$result .= $studentLabel;
12441244
}
12451245

12461246
// the last common word (should be </p>)
1247-
$result .= isset($listStudentAnswerInfo['common_words'][$i]) ? $listStudentAnswerInfo['common_words'][$i] : '';
1247+
$result .= $listStudentAnswerInfo['common_words'][$i] ?? '';
12481248

12491249
return $result;
12501250
}

main/exercise/question.class.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,7 @@ public function return_header(Exercise $exercise, $counter = null, $score = [])
22552255
case ORAL_EXPRESSION:
22562256
case ANSWER_IN_OFFICE_DOC:
22572257
case ANNOTATION:
2258-
$score['revised'] = isset($score['revised']) ? $score['revised'] : false;
2258+
$score['revised'] = $score['revised'] ?? false;
22592259
if ($score['revised'] == true) {
22602260
$scoreLabel = get_lang('Revised');
22612261
$class = '';
@@ -2304,8 +2304,8 @@ public function return_header(Exercise $exercise, $counter = null, $score = [])
23042304
}
23052305

23062306
$scoreCurrent = [
2307-
'used' => isset($score['score']) ? $score['score'] : '',
2308-
'missing' => isset($score['weight']) ? $score['weight'] : '',
2307+
'used' => $score['score'] ?? '',
2308+
'missing' => $score['weight'] ?? '',
23092309
];
23102310

23112311
// Check whether we need to hide the question ID

main/inc/ajax/exercise.ajax.php

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -489,23 +489,22 @@
489489
}
490490

491491
// "all" or "simple" strings means that there's one or all questions exercise type
492-
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : null;
492+
$type = $_REQUEST['type'] ?? null;
493493

494494
// Questions choices.
495-
$choice = isset($_REQUEST['choice']) ? $_REQUEST['choice'] : [];
495+
$choice = $_REQUEST['choice'] ?? [];
496496

497497
// certainty degree choice
498-
$choiceDegreeCertainty = isset($_REQUEST['choiceDegreeCertainty']) ? $_REQUEST['choiceDegreeCertainty'] : [];
498+
$choiceDegreeCertainty = $_REQUEST['choiceDegreeCertainty'] ?? [];
499499

500500
// Hot spot coordinates from all questions.
501-
$hot_spot_coordinates = isset($_REQUEST['hotspot']) ? $_REQUEST['hotspot'] : [];
501+
$hot_spot_coordinates = $_REQUEST['hotspot'] ?? [];
502502

503503
// the filenames in upload answer type
504-
$uploadAnswerFileNames = isset($_REQUEST['uploadChoice']) ? $_REQUEST['uploadChoice'] : [];
504+
$uploadAnswerFileNames = $_REQUEST['uploadChoice'] ?? [];
505505

506506
// There is a reminder?
507-
$remind_list = isset($_REQUEST['remind_list']) && !empty($_REQUEST['remind_list'])
508-
? array_keys($_REQUEST['remind_list']) : [];
507+
$remind_list = !empty($_REQUEST['remind_list']) ? array_keys($_REQUEST['remind_list']) : [];
509508

510509
// Needed in manage_answer.
511510
$learnpath_id = isset($_REQUEST['learnpath_id']) ? (int) $_REQUEST['learnpath_id'] : 0;
@@ -662,7 +661,7 @@
662661
if ($type === 'simple' && $question_id != $my_question_id) {
663662
continue;
664663
}
665-
$my_choice = isset($choice[$my_question_id]) ? $choice[$my_question_id] : null;
664+
$my_choice = $choice[$my_question_id] ?? null;
666665
$objQuestionTmp = Question::read($my_question_id, $objExercise->course);
667666
$myChoiceDegreeCertainty = null;
668667
if ($objQuestionTmp->type === MULTIPLE_ANSWER_TRUE_FALSE_DEGREE_CERTAINTY) {
@@ -700,8 +699,7 @@
700699

701700
// This variable came from exercise_submit_modal.php.
702701
$hotspot_delineation_result = null;
703-
if (isset($_SESSION['hotspot_delineation_result']) &&
704-
isset($_SESSION['hotspot_delineation_result'][$objExercise->selectId()])
702+
if (isset($_SESSION['hotspot_delineation_result'][$objExercise->selectId()])
705703
) {
706704
$hotspot_delineation_result = $_SESSION['hotspot_delineation_result'][$objExercise->selectId()][$my_question_id];
707705
}

main/inc/lib/TicketManager.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ public static function getTicketsByCurrentUser(
801801
if (empty($userInfo)) {
802802
return [];
803803
}
804-
$isAdmin = UserManager::is_admin($userId);
804+
$isAdmin = UserManager::is_admin($userId) || (api_get_configuration_value('allow_session_admin_manage_tickets_and_export_ticket_report') && api_is_session_admin($userId));
805805

806806
if (!isset($_GET['project_id'])) {
807807
return [];
@@ -893,6 +893,7 @@ public static function getTicketsByCurrentUser(
893893
'keyword_source' => 'ticket.source ',
894894
'keyword_status' => 'ticket.status_id',
895895
'keyword_priority' => 'ticket.priority_id',
896+
'keyword_created_by' => 'ticket.sys_insert_user_id',
896897
];
897898

898899
foreach ($keywords as $keyword => $label) {
@@ -1079,6 +1080,7 @@ public static function getTotalTicketsCurrentUser()
10791080
'keyword_source' => 'ticket.source',
10801081
'keyword_status' => 'ticket.status_id',
10811082
'keyword_priority' => 'ticket.priority_id',
1083+
'keyword_created_by' => 'ticket.sys_insert_user_id',
10821084
];
10831085

10841086
foreach ($keywords as $keyword => $sqlLabel) {

main/install/configuration.dist.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -729,6 +729,11 @@
729729
// ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EB5B2A0D6285C231 FOREIGN KEY (lp_id) REFERENCES c_lp (iid);
730730
// $_configuration['ticket_lp_quiz_info_add'] = false;
731731

732+
// Allow session admins to manage tickets settings and report like global admins
733+
//$_configuration['allow_session_admin_manage_tickets_and_export_ticket_report'] = false;
734+
// Show ticket created by the user insted of ticket assigned to the user on MyTicket page.
735+
//$_configuration['ticket_show_ticket_created_by_user_on_my_ticket_page'] = false;
736+
732737
// Exercises configuration settings
733738
// Send only quiz answer notifications to course coaches and not general coach
734739
//$_configuration['block_quiz_mail_notification_general_coach'] = false;

main/ticket/new_ticket.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ function save_ticket()
373373
]
374374
);
375375

376-
if (api_is_platform_admin()) {
376+
if (api_is_platform_admin() || (api_get_configuration_value('allow_session_admin_manage_tickets_and_export_ticket_report') && api_is_session_admin())) {
377377
$form->addSelectAjax(
378378
'user_id',
379379
get_lang('Assign'),

main/ticket/tickets.php

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ function display_advanced_search_form () {
8181
$data = [
8282
[
8383
'#',
84+
get_lang('Status'),
8485
get_lang('Date'),
8586
get_lang('LastUpdate'),
8687
get_lang('Category'),
87-
get_lang('User'),
88-
get_lang('Program'),
88+
get_lang('CreatedBy'),
8989
get_lang('AssignedTo'),
90-
get_lang('Status'),
90+
get_lang('Message'),
9191
get_lang('Description'),
9292
],
9393
];
@@ -128,7 +128,8 @@ function display_advanced_search_form () {
128128
$currentUrl = api_get_self().'?project_id='.$projectId;
129129
$user_id = api_get_user_id();
130130
$isAllow = TicketManager::userIsAllowInProject(api_get_user_info(), $projectId);
131-
$isAdmin = api_is_platform_admin();
131+
$allowSessionAdmin = api_get_configuration_value('allow_session_admin_manage_tickets_and_export_ticket_report') && api_is_session_admin();
132+
$isAdmin = api_is_platform_admin() || $allowSessionAdmin;
132133
$actionRight = '';
133134

134135
Display::display_header(get_lang('MyTickets'));
@@ -145,6 +146,7 @@ function display_advanced_search_form () {
145146
'keyword_unread',
146147
'Tickets_per_page',
147148
'Tickets_column',
149+
'keyword_created_by',
148150
];
149151
}
150152
$get_parameter = '';
@@ -190,6 +192,18 @@ function display_advanced_search_form () {
190192
foreach ($admins as $admin) {
191193
$selectAdmins[$admin['user_id']] = $admin['complete_name_with_username'];
192194
}
195+
196+
$Createdby = UserManager::getUserListLike(
197+
[],
198+
['username'],
199+
true
200+
);
201+
$selectcreated = [
202+
0 => get_lang('Unassigned'),
203+
];
204+
foreach ($Createdby as $creator) {
205+
$selectcreated[$creator['user_id']] = $creator['complete_name_with_username'];
206+
}
193207
$status = TicketManager::get_all_tickets_status();
194208
$selectStatus = [];
195209
foreach ($status as $stat) {
@@ -227,7 +241,7 @@ function display_advanced_search_form () {
227241
);
228242

229243
// Add link
230-
if (api_get_setting('ticket_allow_student_add') == 'true' || api_is_platform_admin()) {
244+
if (api_get_setting('ticket_allow_student_add') == 'true' || api_is_platform_admin() || $allowSessionAdmin) {
231245
$extraParams = '';
232246

233247
if (isset($_GET['exerciseId']) && !empty($_GET['exerciseId'])) {
@@ -250,7 +264,7 @@ function display_advanced_search_form () {
250264
);
251265
}
252266

253-
if (api_is_platform_admin()) {
267+
if (api_is_platform_admin() || $allowSessionAdmin) {
254268
$actionRight .= Display::url(
255269
Display::return_icon(
256270
'export_excel.png',
@@ -261,7 +275,9 @@ function display_advanced_search_form () {
261275
api_get_self().'?action=export'.$get_parameter.$get_parameter2.'&project_id='.$projectId,
262276
['title' => get_lang('Export')]
263277
);
278+
}
264279

280+
if (api_is_platform_admin()) {
265281
$actionRight .= Display::url(
266282
Display::return_icon(
267283
'settings.png',
@@ -286,11 +302,16 @@ function display_advanced_search_form () {
286302
$ticketLabel = get_lang('AllTickets');
287303
$url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$projectId;
288304

289-
if (!isset($_GET['keyword_assigned_to'])) {
305+
if (!isset($_GET['keyword_assigned_to']) && !api_get_configuration_value('ticket_show_ticket_created_by_user_on_my_ticket_page')) {
290306
$ticketLabel = get_lang('MyTickets');
291307
$url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$projectId.'&keyword_assigned_to='.api_get_user_id();
292308
}
293309

310+
if (api_get_configuration_value('ticket_show_ticket_created_by_user_on_my_ticket_page') && !isset($_GET['keyword_created_by'])) {
311+
$ticketLabel = get_lang('MyTickets');
312+
$url = api_get_path(WEB_CODE_PATH).'ticket/tickets.php?project_id='.$projectId.'&keyword_created_by='.api_get_user_id();
313+
}
314+
294315
$options = '';
295316
$iconProject = Display::return_icon(
296317
'project.png',
@@ -342,6 +363,12 @@ function display_advanced_search_form () {
342363
);
343364
$advancedSearchForm->addDateTimePicker('keyword_start_date_start', get_lang('Created'));
344365
$advancedSearchForm->addDateTimePicker('keyword_start_date_end', get_lang('Until'));
366+
$advancedSearchForm->addSelect(
367+
'keyword_created_by',
368+
get_lang('CreatedBy'),
369+
$selectcreated,
370+
['placeholder' => get_lang('All')]
371+
);
345372
$advancedSearchForm->addSelect(
346373
'keyword_assigned_to',
347374
get_lang('AssignedTo'),
@@ -391,7 +418,8 @@ function display_advanced_search_form () {
391418
$table->set_header(1, get_lang('Status'), false);
392419
$table->set_header(2, get_lang('Date'), true);
393420
$table->set_header(3, get_lang('LastUpdate'), true);
394-
$table->set_header(4, get_lang('Category'));
421+
$table->set_header(4, get_lang('Category'), true);
422+
$table->set_header(5, get_lang('CreatedBy'), true);
395423
}
396424

397425
$table->display();

main/user/user.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
if (isset($_GET['action'])) {
8383
switch ($_GET['action']) {
8484
case 'set_tutor':
85-
if (!$canEdit) {
86-
api_not_allowed();
85+
if (!$canEdit || !Security::check_token('get', null, 'tutor')) {
86+
api_not_allowed(true);
8787
}
8888
$userId = isset($_GET['user_id']) ? (int) $_GET['user_id'] : null;
8989
$isTutor = isset($_GET['is_tutor']) ? (int) $_GET['is_tutor'] : 0;
@@ -100,6 +100,7 @@
100100
Display::addFlash(
101101
Display::return_message(get_lang('Updated'))
102102
);
103+
Security::clear_token('tutor');
103104
} else {
104105
Display::addFlash(
105106
Display::return_message(
@@ -108,6 +109,10 @@
108109
)
109110
);
110111
}
112+
header(
113+
'Location: '.api_get_path(WEB_CODE_PATH).'user/user.php?'.api_get_cidreq().'&type='.$type
114+
);
115+
exit;
111116
}
112117
}
113118
break;
@@ -1052,7 +1057,13 @@ function modify_filter($user_id, $row, $data)
10521057
if ($data['user_status_in_course'] == STUDENT) {
10531058
$result .= Display::url(
10541059
$text,
1055-
'user.php?'.api_get_cidreq().'&action=set_tutor&is_tutor='.$isTutor.'&user_id='.$user_id.'&type='.$type,
1060+
'user.php?'.api_get_cidreq().'&'.http_build_query([
1061+
'action' => 'set_tutor',
1062+
'is_tutor' => $isTutor,
1063+
'user_id' => $user_id,
1064+
'type' => $type,
1065+
'tutor_sec_token' => Security::get_existing_token('tutor'),
1066+
]),
10561067
['class' => 'btn btn-default '.$disabled]
10571068
).'&nbsp;';
10581069
}

0 commit comments

Comments
 (0)