diff --git a/main/extra/print_myStudents.php b/main/extra/print_myStudents.php index d24e6f820b..1d94586f9b 100644 --- a/main/extra/print_myStudents.php +++ b/main/extra/print_myStudents.php @@ -39,7 +39,7 @@ if (isset($_GET['details'])) { //$interbreadcrumb[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['title']); } $interbreadcrumb[] = [ - "url" => "../tracking/courseLog.php?cidReq=".$get_course_code.'&studentlist=true&id_session='.(empty($_SESSION['id_session']) ? '' : $_SESSION['id_session']), + "url" => "../tracking/courseLog.php?cidReq=".$get_course_code.'&studentlist=true&id_session='.api_get_session_id(), "name" => get_lang("Tracking"), ]; } else { diff --git a/main/inc/lib/agenda.lib.php b/main/inc/lib/agenda.lib.php index 1db03e2bbb..e19f0f303a 100644 --- a/main/inc/lib/agenda.lib.php +++ b/main/inc/lib/agenda.lib.php @@ -57,6 +57,7 @@ class Agenda // Setting the course object if we are in a course $courseInfo = api_get_course_info_by_id($courseId); + if (!empty($courseInfo)) { $this->set_course($courseInfo); } @@ -64,7 +65,7 @@ class Agenda // Check if teacher/admin rights. $isAllowToEdit = api_is_allowed_to_edit(false, true); // Check course setting. - if (api_get_course_setting('allow_user_edit_agenda') == '1' + if (api_get_course_setting('allow_user_edit_agenda') === '1' && api_is_allowed_in_course() ) { $isAllowToEdit = true; diff --git a/main/inc/lib/api.lib.php b/main/inc/lib/api.lib.php index e87e3921c4..2b32aa4c4e 100644 --- a/main/inc/lib/api.lib.php +++ b/main/inc/lib/api.lib.php @@ -2132,36 +2132,35 @@ function api_get_url_entity($id = 0) * * @return array The course info as an array formatted by api_format_course_array, including category.name */ -function api_get_course_info_by_id($id = null) +function api_get_course_info_by_id($id = 0) { - if (!empty($id)) { - $id = (int) $id; - $course_table = Database::get_main_table(TABLE_MAIN_COURSE); - $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY); - $sql = "SELECT - course.*, - course_category.code faCode, - course_category.name faName - FROM $course_table - LEFT JOIN $course_cat_table - ON course.category_code = course_category.code - WHERE course.id = $id"; - $result = Database::query($sql); - $_course = []; - if (Database::num_rows($result) > 0) { - $row = Database::fetch_array($result); - $_course = api_format_course_array($row); - } + $id = (int) $id; + if (empty($id)) { + $course = Session::read('_course', []); - return $_course; + return $course; } - global $_course; - if ($_course == '-1') { - $_course = []; + $course_table = Database::get_main_table(TABLE_MAIN_COURSE); + $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY); + $sql = "SELECT + course.*, + course_category.code faCode, + course_category.name faName + FROM $course_table + LEFT JOIN $course_cat_table + ON course.category_code = course_category.code + WHERE course.id = $id"; + $result = Database::query($sql); + + if (Database::num_rows($result) > 0) { + $row = Database::fetch_array($result); + $course = api_format_course_array($row); + + return $course; } - return $_course; + return []; } /** diff --git a/main/inc/lib/course_home.lib.php b/main/inc/lib/course_home.lib.php index 3e75a788b9..eb0631446d 100755 --- a/main/inc/lib/course_home.lib.php +++ b/main/inc/lib/course_home.lib.php @@ -1426,7 +1426,7 @@ class CourseHome * * @return string */ - public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) + public static function getCourseToolBar($orientation = SHORTCUTS_HORIZONTAL): string { $origin = api_get_origin(); if ($origin === 'learnpath') { @@ -1436,10 +1436,9 @@ class CourseHome $navigation_items = self::get_navigation_items(false); $html = ''; if (!empty($navigation_items)) { - if ($orientation == SHORTCUTS_HORIZONTAL) { - $style_id = "toolshortcuts_horizontal"; - } else { - $style_id = "toolshortcuts_vertical"; + $style_id = 'toolshortcuts_vertical'; + if ($orientation === SHORTCUTS_HORIZONTAL) { + $style_id = 'toolshortcuts_horizontal'; } $html .= '