diff --git a/main/admin/user_list.php b/main/admin/user_list.php
index 1fe5bf7308..df21424964 100755
--- a/main/admin/user_list.php
+++ b/main/admin/user_list.php
@@ -1060,7 +1060,7 @@ $data = $extraField->addElements($form, 0, [], true, false, $variablesToShow);
$htmlHeadXtra[] = '
diff --git a/main/inc/ajax/message.ajax.php b/main/inc/ajax/message.ajax.php
index cbcdaeb567..b49225d4d1 100755
--- a/main/inc/ajax/message.ajax.php
+++ b/main/inc/ajax/message.ajax.php
@@ -112,7 +112,7 @@ switch ($action) {
/** @var User $user */
foreach ($users as $user) {
- $userName = $user->getCompleteNameWithUsername();
+ $userName = UserManager::formatUserFullName($user, true);
if ($showEmail) {
$userName .= " ({$user->getEmail()})";
@@ -123,7 +123,7 @@ switch ($action) {
'id' => $user->getId(),
];
}
-
+ header('Content-type:application/json');
echo json_encode($return);
break;
default:
diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php
index ad9579073d..ddbf68d880 100644
--- a/main/inc/lib/api.lib.php
+++ b/main/inc/lib/api.lib.php
@@ -22,7 +22,7 @@ use Symfony\Component\Finder\Finder;
*/
// PHP version requirement.
-define('REQUIRED_PHP_VERSION', '5.5');
+define('REQUIRED_PHP_VERSION', '5.6');
define('REQUIRED_MIN_MEMORY_LIMIT', '128');
define('REQUIRED_MIN_UPLOAD_MAX_FILESIZE', '10');
define('REQUIRED_MIN_POST_MAX_SIZE', '10');
diff --git a/main/inc/lib/formvalidator/Element/UserAvatar.php b/main/inc/lib/formvalidator/Element/UserAvatar.php
index 247d8b1314..c3a54c3949 100644
--- a/main/inc/lib/formvalidator/Element/UserAvatar.php
+++ b/main/inc/lib/formvalidator/Element/UserAvatar.php
@@ -73,10 +73,10 @@ class UserAvatar extends HTML_QuickForm_input
$html .= '
diff --git a/main/inc/lib/sessionmanager.lib.php b/main/inc/lib/sessionmanager.lib.php
index f87cfd5b8b..531377149e 100755
--- a/main/inc/lib/sessionmanager.lib.php
+++ b/main/inc/lib/sessionmanager.lib.php
@@ -1021,7 +1021,7 @@ class SessionManager
$date_to,
$options
) {
- $sessionId = intval($sessionId);
+ $sessionId = (int) $sessionId;
$getAllSessions = false;
if (empty($sessionId)) {
diff --git a/main/inc/lib/tracking.lib.php b/main/inc/lib/tracking.lib.php
index 0c3b0e30aa..7988776c21 100755
--- a/main/inc/lib/tracking.lib.php
+++ b/main/inc/lib/tracking.lib.php
@@ -4206,9 +4206,9 @@ class Tracking
$count = $row[0];
return $count;
- } else {
- return null;
}
+
+ return 0;
}
/**
@@ -4238,7 +4238,7 @@ class Tracking
$condition_session = '';
if (isset($session_id)) {
- $session_id = intval($session_id);
+ $session_id = (int) $session_id;
$condition_session = ' AND f.session_id = '.$session_id;
}
@@ -4274,9 +4274,9 @@ class Tracking
$count = $row[0];
return $count;
- } else {
- return null;
}
+
+ return 0;
}
/**
@@ -4303,11 +4303,11 @@ class Tracking
$condition_session = '';
if (isset($session_id)) {
- $session_id = intval($session_id);
+ $session_id = (int) $session_id;
$condition_session = ' AND f.session_id = '.$session_id;
}
- $groupId = intval($groupId);
+ $groupId = (int) $groupId;
if (!empty($groupId)) {
$groupCondition = " i.to_group_id = $groupId ";
} else {
@@ -4332,9 +4332,9 @@ class Tracking
$count = $row[0];
return $count;
- } else {
- return null;
}
+
+ return 0;
}
/**
@@ -4358,8 +4358,9 @@ class Tracking
$course_id = $course_info['real_id'];
// Protect data
- $last_days = intval($last_days);
- $session_id = intval($session_id);
+ $last_days = (int) $last_days;
+ $session_id = (int) $session_id;
+
$tbl_stats_access = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$now = api_get_utc_datetime();
@@ -4368,16 +4369,16 @@ class Tracking
DATE_SUB('$now',INTERVAL $last_days DAY) <= access_date AND
c_id = '$course_id' AND
access_tool='".TOOL_CHAT."' AND
- access_session_id='$session_id' ";
+ access_session_id = '$session_id' ";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$row = Database::fetch_row($result);
$count = $row[0];
return $count;
- } else {
- return null;
}
+
+ return 0;
}
/**
@@ -4394,9 +4395,9 @@ class Tracking
$courseId,
$session_id = 0
) {
- $student_id = intval($student_id);
- $courseId = intval($courseId);
- $session_id = intval($session_id);
+ $student_id = (int) $student_id;
+ $courseId = (int) $courseId;
+ $session_id = (int) $session_id;
$date_time = '';
// table definition
@@ -4433,9 +4434,9 @@ class Tracking
*/
public static function count_student_visited_links($student_id, $courseId, $session_id = 0)
{
- $student_id = intval($student_id);
- $courseId = intval($courseId);
- $session_id = intval($session_id);
+ $student_id = (int) $student_id;
+ $courseId = (int) $courseId;
+ $session_id = (int) $session_id;
// table definition
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LINKS);
@@ -4463,9 +4464,9 @@ class Tracking
*/
public static function count_student_downloaded_documents($student_id, $courseId, $session_id = 0)
{
- $student_id = intval($student_id);
- $courseId = intval($courseId);
- $session_id = intval($session_id);
+ $student_id = (int) $student_id;
+ $courseId = (int) $courseId;
+ $session_id = (int) $session_id;
// table definition
$table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
@@ -4595,59 +4596,6 @@ class Tracking
return $users;
}
- /**
- * Get count login per student.
- *
- * @param int $student_id Student id
- * @param int $courseId
- * @param int $session_id Session id (optional)
- *
- * @return int count login
- */
- public static function count_login_per_student($student_id, $courseId, $session_id = 0)
- {
- $student_id = intval($student_id);
- $courseId = intval($courseId);
- $session_id = intval($session_id);
- $table = Database::get_main_table(TABLE_STATISTIC_TRACK_E_ACCESS);
-
- $sql = 'SELECT '.$student_id.'
- FROM '.$table.'
- WHERE
- access_user_id='.$student_id.' AND
- c_id="'.$courseId.'" AND
- access_session_id = "'.$session_id.'" ';
-
- $rs = Database::query($sql);
- $nb_login = Database::num_rows($rs);
-
- return $nb_login;
- }
-
- /**
- * Get students followed by a human resources manager.
- *
- * @param int Drh id
- *
- * @return array Student list
- */
- public static function get_student_followed_by_drh($hr_dept_id)
- {
- $hr_dept_id = intval($hr_dept_id);
- $a_students = [];
- $tbl_user = Database::get_main_table(TABLE_MAIN_USER);
-
- $sql = 'SELECT DISTINCT user_id FROM '.$tbl_user.' as user
- WHERE hr_dept_id='.$hr_dept_id;
- $rs = Database::query($sql);
-
- while ($user = Database::fetch_array($rs)) {
- $a_students[$user['user_id']] = $user['user_id'];
- }
-
- return $a_students;
- }
-
/**
* get count clicks about tools most used by course.
*
@@ -4660,12 +4608,12 @@ class Tracking
*/
public static function get_tools_most_used_by_course($courseId, $session_id = null)
{
- $courseId = intval($courseId);
+ $courseId = (int) $courseId;
$data = [];
$TABLETRACK_ACCESS = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LASTACCESS);
$condition_session = '';
if (isset($session_id)) {
- $session_id = intval($session_id);
+ $session_id = (int) $session_id;
$condition_session = ' AND access_session_id = '.$session_id;
}
$sql = "SELECT
diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php
index a9f77154da..fb1741c75e 100755
--- a/main/inc/lib/userportal.lib.php
+++ b/main/inc/lib/userportal.lib.php
@@ -1122,7 +1122,6 @@ class IndexManager
$load_history = isset($_GET['history']) && intval($_GET['history']) == 1 ? true : false;
$viewGridCourses = api_get_configuration_value('view_grid_courses') === true;
$showSimpleSessionInfo = api_get_configuration_value('show_simple_session_info');
-
$coursesWithoutCategoryTemplate = '/user_portal/classic_courses_without_category.tpl';
$coursesWithCategoryTemplate = '/user_portal/classic_courses_with_category.tpl';
$showAllSessions = api_get_configuration_value('show_all_sessions_on_my_course_page') === true;
@@ -1145,7 +1144,6 @@ class IndexManager
// Student info code check (shows student progress information on
// courses list
$studentInfo = api_get_configuration_value('course_student_info');
- $viewGrid = api_get_configuration_value('view_grid_courses');
$studentInfoProgress = !empty($studentInfo['progress']) && $studentInfo['progress'] === true;
$studentInfoScore = !empty($studentInfo['score']) && $studentInfo['score'] === true;
@@ -1157,7 +1155,7 @@ class IndexManager
$specialCourseList = '';
// If we're not in the history view...
- if ($loadHistory == false) {
+ if ($loadHistory === false) {
// Display special courses.
$specialCourses = CourseManager::returnSpecialCourses(
$user_id,
@@ -1225,10 +1223,11 @@ class IndexManager
foreach ($courses['in_category'] as $key1 => $value) {
if (isset($courses['in_category'][$key1]['courses'])) {
foreach ($courses['in_category'][$key1]['courses'] as $key2 => $courseInCatInfo) {
+ $courseCode = $courseInCatInfo['course_code'];
if ($studentInfoProgress) {
$progress = Tracking::get_avg_student_progress(
$user_id,
- $courseInCatInfo['course_code']
+ $courseCode
);
$courses['in_category'][$key1]['courses'][$key2]['student_info']['progress'] = $progress === false ? null : $progress;
}
@@ -1236,7 +1235,7 @@ class IndexManager
if ($studentInfoScore) {
$percentage_score = Tracking::get_avg_student_score(
$user_id,
- $specialCourseInfo['course_code'],
+ $courseCode,
[]
);
$courses['in_category'][$key1]['courses'][$key2]['student_info']['score'] = $percentage_score;
@@ -1246,7 +1245,7 @@ class IndexManager
$category = Category::load(
null,
null,
- $courseInCatInfo['course_code'],
+ $courseCode,
null,
null,
null
@@ -1254,7 +1253,7 @@ class IndexManager
$courses['in_category'][$key1]['student_info']['certificate'] = null;
$isCertificateAvailable = $category[0]->is_certificate_available($user_id);
if (isset($category[0])) {
- if ($viewGrid) {
+ if ($viewGridCourses) {
if ($isCertificateAvailable) {
$courses['in_category'][$key1]['student_info']['certificate'] = get_lang(
'Yes'
@@ -1286,10 +1285,11 @@ class IndexManager
if (isset($courses['not_category'])) {
foreach ($courses['not_category'] as $key => $courseNotInCatInfo) {
+ $courseCode = $courseNotInCatInfo['course_code'];
if ($studentInfoProgress) {
$progress = Tracking::get_avg_student_progress(
$user_id,
- $courseNotInCatInfo['course_code']
+ $courseCode
);
$courses['not_category'][$key]['student_info']['progress'] = $progress === false ? null : $progress;
}
@@ -1297,7 +1297,7 @@ class IndexManager
if ($studentInfoScore) {
$percentage_score = Tracking::get_avg_student_score(
$user_id,
- $courseNotInCatInfo['course_code'],
+ $courseCode,
[]
);
$courses['not_category'][$key]['student_info']['score'] = $percentage_score;
@@ -1307,7 +1307,7 @@ class IndexManager
$category = Category::load(
null,
null,
- $courseNotInCatInfo['course_code'],
+ $courseCode,
null,
null,
null
@@ -1316,7 +1316,7 @@ class IndexManager
if (isset($category[0])) {
$certificateAvailable = $category[0]->is_certificate_available($user_id);
- if ($viewGrid) {
+ if ($viewGridCourses) {
if ($certificateAvailable) {
$courses['not_category'][$key]['student_info']['certificate'] = get_lang('Yes');
} else {
@@ -1395,7 +1395,6 @@ class IndexManager
$sessions_with_category = '';
$sessions_with_no_category = '';
-
$collapsable = api_get_configuration_value('allow_user_session_collapsable');
$collapsableLink = '';
if ($collapsable) {
@@ -1609,7 +1608,7 @@ class IndexManager
$params['show_actions'] = SessionManager::cantEditSession($session_id);
if ($collapsable) {
- $collapsableData = Sessionmanager::getCollapsableData(
+ $collapsableData = SessionManager::getCollapsableData(
$user_id,
$session_id,
$extraFieldValue,