Replace $_SESSION, rename function to camelCase, format code

pull/2650/head
Julio Montoya 6 years ago
parent e3a3c5a636
commit 166199747f
  1. 2
      main/extra/print_myStudents.php
  2. 3
      main/inc/lib/agenda.lib.php
  3. 47
      main/inc/lib/api.lib.php
  4. 9
      main/inc/lib/course_home.lib.php
  5. 7
      main/inc/lib/template.lib.php
  6. 21
      user_portal.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[] = array ("url" => api_get_path(WEB_COURSE_PATH).$course_info['directory'], 'name' => $course_info['title']);
} }
$interbreadcrumb[] = [ $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"), "name" => get_lang("Tracking"),
]; ];
} else { } else {

@ -57,6 +57,7 @@ class Agenda
// Setting the course object if we are in a course // Setting the course object if we are in a course
$courseInfo = api_get_course_info_by_id($courseId); $courseInfo = api_get_course_info_by_id($courseId);
if (!empty($courseInfo)) { if (!empty($courseInfo)) {
$this->set_course($courseInfo); $this->set_course($courseInfo);
} }
@ -64,7 +65,7 @@ class Agenda
// Check if teacher/admin rights. // Check if teacher/admin rights.
$isAllowToEdit = api_is_allowed_to_edit(false, true); $isAllowToEdit = api_is_allowed_to_edit(false, true);
// Check course setting. // 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() && api_is_allowed_in_course()
) { ) {
$isAllowToEdit = true; $isAllowToEdit = true;

@ -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 * @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;
$id = (int) $id; if (empty($id)) {
$course_table = Database::get_main_table(TABLE_MAIN_COURSE); $course = Session::read('_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);
}
return $_course; return $course;
} }
global $_course; $course_table = Database::get_main_table(TABLE_MAIN_COURSE);
if ($_course == '-1') { $course_cat_table = Database::get_main_table(TABLE_MAIN_CATEGORY);
$_course = []; $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 [];
} }
/** /**

@ -1426,7 +1426,7 @@ class CourseHome
* *
* @return string * @return string
*/ */
public static function show_navigation_tool_shortcuts($orientation = SHORTCUTS_HORIZONTAL) public static function getCourseToolBar($orientation = SHORTCUTS_HORIZONTAL): string
{ {
$origin = api_get_origin(); $origin = api_get_origin();
if ($origin === 'learnpath') { if ($origin === 'learnpath') {
@ -1436,10 +1436,9 @@ class CourseHome
$navigation_items = self::get_navigation_items(false); $navigation_items = self::get_navigation_items(false);
$html = ''; $html = '';
if (!empty($navigation_items)) { if (!empty($navigation_items)) {
if ($orientation == SHORTCUTS_HORIZONTAL) { $style_id = 'toolshortcuts_vertical';
$style_id = "toolshortcuts_horizontal"; if ($orientation === SHORTCUTS_HORIZONTAL) {
} else { $style_id = 'toolshortcuts_horizontal';
$style_id = "toolshortcuts_vertical";
} }
$html .= '<div id="'.$style_id.'">'; $html .= '<div id="'.$style_id.'">';
foreach ($navigation_items as $key => $navigation_item) { foreach ($navigation_items as $key => $navigation_item) {

@ -518,7 +518,6 @@ class Template
$this->assign('show_header', $status); $this->assign('show_header', $status);
$show_toolbar = 0; $show_toolbar = 0;
if (self::isToolBarDisplayedForUser()) { if (self::isToolBarDisplayedForUser()) {
$show_toolbar = 1; $show_toolbar = 1;
} }
@ -530,11 +529,11 @@ class Template
$show_course_navigation_menu = null; $show_course_navigation_menu = null;
if (!empty($this->course_id) && $this->user_is_logged_in) { 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 //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 //Course toolbar
$show_course_navigation_menu = CourseHome::show_navigation_menu(); $show_course_navigation_menu = CourseHome::show_navigation_menu();
} }

@ -22,14 +22,12 @@ use ChamiloSession as Session;
/* Flag forcing the 'current course' reset, as we're not inside a course anymore */ /* Flag forcing the 'current course' reset, as we're not inside a course anymore */
$cidReset = true; $cidReset = true;
// For HTML editor repository.
if (isset($_SESSION['this_section'])) {
unset($_SESSION['this_section']);
}
/* Included libraries */ /* Included libraries */
require_once './main/inc/global.inc.php'; require_once './main/inc/global.inc.php';
// For HTML editor repository.
Session::erase('this_section');
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
api_block_anonymous_users(); // Only users who are logged in can proceed. 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('profile_block', $controller->return_profile_block());
$controller->tpl->assign('user_image_block', $controller->return_user_image_block()); $controller->tpl->assign('user_image_block', $controller->return_user_image_block());
$controller->tpl->assign('course_block', $controller->return_course_block()); $controller->tpl->assign('course_block', $controller->return_course_block());

Loading…
Cancel
Save