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 .= '
'; foreach ($navigation_items as $key => $navigation_item) { diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index 7a9fe8fccf..7e5ce18c73 100755 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -518,7 +518,6 @@ class Template $this->assign('show_header', $status); $show_toolbar = 0; - if (self::isToolBarDisplayedForUser()) { $show_toolbar = 1; } @@ -530,11 +529,11 @@ class Template $show_course_navigation_menu = null; if (!empty($this->course_id) && $this->user_is_logged_in) { - if (api_get_setting('show_toolshortcuts') != 'false') { + if (api_get_setting('show_toolshortcuts') !== 'false') { //Course toolbar - $show_course_shortcut = CourseHome::show_navigation_tool_shortcuts(); + $show_course_shortcut = CourseHome::getCourseToolBar(); } - if (api_get_setting('show_navigation_menu') != 'false') { + if (api_get_setting('show_navigation_menu') !== 'false') { //Course toolbar $show_course_navigation_menu = CourseHome::show_navigation_menu(); } diff --git a/user_portal.php b/user_portal.php index 30c98005a8..0303ab7435 100755 --- a/user_portal.php +++ b/user_portal.php @@ -22,14 +22,12 @@ use ChamiloSession as Session; /* Flag forcing the 'current course' reset, as we're not inside a course anymore */ $cidReset = true; -// For HTML editor repository. -if (isset($_SESSION['this_section'])) { - unset($_SESSION['this_section']); -} - /* Included libraries */ require_once './main/inc/global.inc.php'; +// For HTML editor repository. +Session::erase('this_section'); + $this_section = SECTION_COURSES; api_block_anonymous_users(); // Only users who are logged in can proceed. @@ -264,19 +262,6 @@ if ($useCookieValidation === 'true') { } } -//check for flash and message -$sniff_notification = ''; -$some_activex = isset($_SESSION['sniff_check_some_activex']) ? $_SESSION['sniff_check_some_activex'] : null; -$some_plugins = isset($_SESSION['sniff_check_some_plugins']) ? $_SESSION['sniff_check_some_plugins'] : null; - -if (!empty($some_activex) || !empty($some_plugins)) { - if (!preg_match("/flash_yes/", $some_activex) && !preg_match("/flash_yes/", $some_plugins)) { - $sniff_notification = Display::return_message(get_lang('NoFlash'), 'warning', true); - //js verification - To annoying of redirecting every time the page - $controller->tpl->assign('sniff_notification', $sniff_notification); - } -} - $controller->tpl->assign('profile_block', $controller->return_profile_block()); $controller->tpl->assign('user_image_block', $controller->return_user_image_block()); $controller->tpl->assign('course_block', $controller->return_course_block());