Skip to content

Commit ac7f3bb

Browse files
committed
Minor: Format code
1 parent 349062d commit ac7f3bb

File tree

1 file changed

+37
-43
lines changed

1 file changed

+37
-43
lines changed

main/inc/ajax/model.ajax.php

Lines changed: 37 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
$sidx = $_REQUEST['sidx']; //index (field) to filter
2525
$sord = $_REQUEST['sord']; //asc or desc
26-
$exportFilename = isset($_REQUEST['export_filename']) ? $_REQUEST['export_filename'] : '';
26+
$exportFilename = $_REQUEST['export_filename'] ?? '';
2727

2828
if (strpos(strtolower($sidx), 'asc') !== false) {
2929
$sidx = str_replace(['asc', ','], '', $sidx);
@@ -131,13 +131,13 @@ function getWhereClause($col, $oper, $val)
131131

132132
// If there is no search request sent by jqgrid, $where should be empty
133133
$whereCondition = '';
134-
$operation = isset($_REQUEST['oper']) ? $_REQUEST['oper'] : false;
135-
$exportFormat = isset($_REQUEST['export_format']) ? $_REQUEST['export_format'] : 'csv';
136-
$searchField = isset($_REQUEST['searchField']) ? $_REQUEST['searchField'] : false;
137-
$searchOperator = isset($_REQUEST['searchOper']) ? $_REQUEST['searchOper'] : false;
138-
$searchString = isset($_REQUEST['searchString']) ? $_REQUEST['searchString'] : false;
139-
$search = isset($_REQUEST['_search']) ? $_REQUEST['_search'] : false;
140-
$forceSearch = isset($_REQUEST['_force_search']) ? $_REQUEST['_force_search'] : false;
134+
$operation = $_REQUEST['oper'] ?? false;
135+
$exportFormat = $_REQUEST['export_format'] ?? 'csv';
136+
$searchField = $_REQUEST['searchField'] ?? false;
137+
$searchOperator = $_REQUEST['searchOper'] ?? false;
138+
$searchString = $_REQUEST['searchString'] ?? false;
139+
$search = $_REQUEST['_search'] ?? false;
140+
$forceSearch = $_REQUEST['_force_search'] ?? false;
141141
$extra_fields = [];
142142
$accessStartDate = '';
143143
$accessEndDate = '';
@@ -290,18 +290,18 @@ function getWhereClause($col, $oper, $val)
290290
switch ($action) {
291291
case 'get_exercise_categories':
292292
$manager = new ExerciseCategoryManager();
293-
$courseId = isset($_REQUEST['c_id']) ? $_REQUEST['c_id'] : 0;
293+
$courseId = $_REQUEST['c_id'] ?? 0;
294294
$count = $manager->getCourseCount($courseId);
295295
break;
296296
case 'get_calendar_users':
297297
$calendarPlugin = LearningCalendarPlugin::create();
298-
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
298+
$id = $_REQUEST['id'] ?? 0;
299299
$count = $calendarPlugin->getUsersPerCalendarCount($id);
300300
break;
301301
case 'get_usergroups_users':
302302
$usergroup = new UserGroup();
303303
$usergroup->protectScript(null, true, true);
304-
$id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
304+
$id = $_REQUEST['id'] ?? 0;
305305
$count = $usergroup->getUserGroupUsers($id, true);
306306
break;
307307
case 'get_learning_path_calendars':
@@ -324,9 +324,9 @@ function getWhereClause($col, $oper, $val)
324324
$count = $object->get_count();
325325
break;
326326
case 'get_group_reporting':
327-
$course_id = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : null;
328-
$group_id = isset($_REQUEST['gidReq']) ? $_REQUEST['gidReq'] : null;
329-
$sessionId = isset($_REQUEST['session_id']) ? $_REQUEST['session_id'] : null;
327+
$course_id = $_REQUEST['course_id'] ?? null;
328+
$group_id = $_REQUEST['gidReq'] ?? null;
329+
$sessionId = $_REQUEST['session_id'] ?? null;
330330
$count = Tracking::get_group_reporting(
331331
$course_id,
332332
$sessionId,
@@ -628,7 +628,7 @@ function getWhereClause($col, $oper, $val)
628628
return 0;
629629
}
630630
require_once api_get_path(SYS_CODE_PATH).'work/work.lib.php';
631-
$workId = isset($_GET['work_id']) ? $_GET['work_id'] : null;
631+
$workId = $_GET['work_id'] ?? null;
632632
$count = getWorkUserListData(
633633
$workId,
634634
api_get_course_id(),
@@ -650,8 +650,8 @@ function getWhereClause($col, $oper, $val)
650650
$exerciseId = $_REQUEST['exercise_id'] ?? 0;
651651
$status = $_REQUEST['status'] ?? 0;
652652
$questionType = $_REQUEST['questionType'] ?? 0;
653-
$showAttemptsInSessions = $_REQUEST['showAttemptsInSessions'] ? true : false;
654-
if (isset($_GET['filter_by_user']) && !empty($_GET['filter_by_user'])) {
653+
$showAttemptsInSessions = (bool) $_REQUEST['showAttemptsInSessions'];
654+
if (!empty($_GET['filter_by_user'])) {
655655
$filter_user = (int) $_GET['filter_by_user'];
656656
if (empty($whereCondition)) {
657657
$whereCondition .= " te.exe_user_id = '$filter_user'";
@@ -660,7 +660,7 @@ function getWhereClause($col, $oper, $val)
660660
}
661661
}
662662

663-
if (isset($_GET['group_id_in_toolbar']) && !empty($_GET['group_id_in_toolbar'])) {
663+
if (!empty($_GET['group_id_in_toolbar'])) {
664664
$groupIdFromToolbar = (int) $_GET['group_id_in_toolbar'];
665665
if (!empty($groupIdFromToolbar)) {
666666
if (empty($whereCondition)) {
@@ -695,7 +695,7 @@ function getWhereClause($col, $oper, $val)
695695
case 'get_exercise_results':
696696
$exercise_id = $_REQUEST['exerciseId'];
697697

698-
if (isset($_GET['filter_by_user']) && !empty($_GET['filter_by_user'])) {
698+
if (!empty($_GET['filter_by_user'])) {
699699
$filter_user = (int) $_GET['filter_by_user'];
700700
if (empty($whereCondition)) {
701701
$whereCondition .= " te.exe_user_id = '$filter_user'";
@@ -704,7 +704,7 @@ function getWhereClause($col, $oper, $val)
704704
}
705705
}
706706

707-
if (isset($_GET['group_id_in_toolbar']) && !empty($_GET['group_id_in_toolbar'])) {
707+
if (!empty($_GET['group_id_in_toolbar'])) {
708708
$groupIdFromToolbar = (int) $_GET['group_id_in_toolbar'];
709709
if (!empty($groupIdFromToolbar)) {
710710
if (empty($whereCondition)) {
@@ -723,8 +723,8 @@ function getWhereClause($col, $oper, $val)
723723
break;
724724
case 'get_exercise_results_report':
725725
api_protect_admin_script();
726-
$exerciseId = isset($_REQUEST['exercise_id']) ? $_REQUEST['exercise_id'] : 0;
727-
$courseId = isset($_REQUEST['course_id']) ? $_REQUEST['course_id'] : 0;
726+
$exerciseId = $_REQUEST['exercise_id'] ?? 0;
727+
$courseId = $_REQUEST['course_id'] ?? 0;
728728

729729
if (empty($exerciseId)) {
730730
exit;
@@ -733,7 +733,7 @@ function getWhereClause($col, $oper, $val)
733733
if (!empty($courseId)) {
734734
$courseInfo = api_get_course_info_by_id($courseId);
735735
} else {
736-
$courseCode = isset($_REQUEST['cidReq']) ? $_REQUEST['cidReq'] : '';
736+
$courseCode = $_REQUEST['cidReq'] ?? '';
737737
if (!empty($courseCode)) {
738738
$courseInfo = api_get_course_info($courseCode);
739739
}
@@ -762,7 +762,7 @@ function getWhereClause($col, $oper, $val)
762762
$count = ExerciseLib::get_count_exam_hotpotatoes_results($hotpot_path);
763763
break;
764764
case 'get_sessions_tracking':
765-
$keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';
765+
$keyword = $_REQUEST['keyword'] ?? '';
766766

767767
$description = '';
768768
$setting = api_get_setting('show_session_description');
@@ -813,7 +813,7 @@ function getWhereClause($col, $oper, $val)
813813
}
814814
break;
815815
case 'get_sessions':
816-
$listType = isset($_REQUEST['list_type']) ? $_REQUEST['list_type'] : SessionManager::getDefaultSessionTab();
816+
$listType = $_REQUEST['list_type'] ?? SessionManager::getDefaultSessionTab();
817817

818818
if ('custom' === $listType && api_get_configuration_value('allow_session_status')) {
819819
$whereCondition .= ' AND (s.status IN ("'.SessionManager::STATUS_PLANNED.'", "'.SessionManager::STATUS_PROGRESS.'") ) ';
@@ -947,9 +947,9 @@ function getWhereClause($col, $oper, $val)
947947
case 'get_usergroups_teacher':
948948
$obj = new UserGroup();
949949
$obj->protectScript(null, false, true);
950-
$type = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'registered';
950+
$type = $_REQUEST['type'] ?? 'registered';
951951
$groupFilter = isset($_REQUEST['group_filter']) ? (int) $_REQUEST['group_filter'] : 0;
952-
$keyword = isset($_REQUEST['keyword']) ? $_REQUEST['keyword'] : '';
952+
$keyword = $_REQUEST['keyword'] ?? '';
953953

954954
$course_id = api_get_course_int_id();
955955
$sessionId = api_get_session_id();
@@ -1349,8 +1349,8 @@ function getWhereClause($col, $oper, $val)
13491349
'actions',
13501350
];
13511351

1352-
$titleToSearch = isset($_REQUEST['title_to_search']) ? $_REQUEST['title_to_search'] : '';
1353-
$userIdToSearch = isset($_REQUEST['user_id_to_search']) ? $_REQUEST['user_id_to_search'] : 0;
1352+
$titleToSearch = $_REQUEST['title_to_search'] ?? '';
1353+
$userIdToSearch = $_REQUEST['user_id_to_search'] ?? 0;
13541354
$sidx = in_array($sidx, $columns) ? $sidx : 'title';
13551355
$result = AnnouncementManager::getAnnouncements(
13561356
null,
@@ -1439,8 +1439,6 @@ function getWhereClause($col, $oper, $val)
14391439
'qualificator_id',
14401440
'correction',
14411441
];
1442-
$columns = array_merge($columns, $plagiarismColumns);
1443-
$columns[] = 'actions';
14441442
} else {
14451443
$columns = [
14461444
'fullname',
@@ -1449,9 +1447,9 @@ function getWhereClause($col, $oper, $val)
14491447
'sent_date',
14501448
'correction',
14511449
];
1452-
$columns = array_merge($columns, $plagiarismColumns);
1453-
$columns[] = 'actions';
14541450
}
1451+
$columns = array_merge($columns, $plagiarismColumns);
1452+
$columns[] = 'actions';
14551453

14561454
$whereCondition = " AND $whereCondition ";
14571455
$columnOrderValidList = array_merge(['firstname', 'lastname'], $columns);
@@ -1513,13 +1511,11 @@ function getWhereClause($col, $oper, $val)
15131511
$columns = [
15141512
'type', 'firstname', 'lastname', 'title', 'qualification', 'sent_date', 'qualificator_id',
15151513
];
1516-
$columns = array_merge($columns, $plagiarismColumns);
1517-
$columns[] = 'actions';
15181514
} else {
15191515
$columns = ['type', 'firstname', 'lastname', 'title', 'sent_date'];
1520-
$columns = array_merge($columns, $plagiarismColumns);
1521-
$columns[] = 'actions';
15221516
}
1517+
$columns = array_merge($columns, $plagiarismColumns);
1518+
$columns[] = 'actions';
15231519

15241520
if (trim($whereCondition) === '1 = 1') {
15251521
$whereCondition = '';
@@ -1547,13 +1543,11 @@ function getWhereClause($col, $oper, $val)
15471543
$columns = [
15481544
'type', 'title', 'qualification', 'sent_date', 'qualificator_id',
15491545
];
1550-
$columns = array_merge($columns, $plagiarismColumns);
1551-
$columns[] = 'actions';
15521546
} else {
15531547
$columns = ['type', 'title', 'qualification', 'sent_date'];
1554-
$columns = array_merge($columns, $plagiarismColumns);
1555-
$columns[] = 'actions';
15561548
}
1549+
$columns = array_merge($columns, $plagiarismColumns);
1550+
$columns[] = 'actions';
15571551
$documents = getAllDocumentToWork($work_id, api_get_course_int_id());
15581552

15591553
if (trim($whereCondition) === '1 = 1') {
@@ -2796,15 +2790,15 @@ function getWhereClause($col, $oper, $val)
27962790
foreach ($result as $row) {
27972791
// if results tab give not id, set id to $i otherwise id="null"
27982792
// for all <tr> of the jqgrid - ref #4235
2799-
if (!isset($row['id']) || isset($row['id']) && $row['id'] == '') {
2793+
if (!isset($row['id']) || $row['id'] == '') {
28002794
$response->rows[$i]['id'] = $i;
28012795
} else {
28022796
$response->rows[$i]['id'] = $row['id'];
28032797
}
28042798
$array = [];
28052799
foreach ($columns as $col) {
28062800
if (in_array($col, ['correction', 'actions'])) {
2807-
$array[] = isset($row[$col]) ? $row[$col] : '';
2801+
$array[] = $row[$col] ?? '';
28082802
} else {
28092803
$array[] = isset($row[$col]) ? Security::remove_XSS($row[$col]) : '';
28102804
}

0 commit comments

Comments
 (0)