From 7412d55cea5db5a0076ecc47790024700a932d4f Mon Sep 17 00:00:00 2001 From: jmontoyaa Date: Thu, 31 Aug 2017 14:25:22 +0200 Subject: [PATCH] Remove use of $_SESSION --- main/social/home.php | 4 ++- main/social/myfiles.php | 6 ++-- main/survey/fillsurvey.php | 58 +++++++++++++----------------- main/survey/surveyUtil.class.php | 8 +++-- main/ticket/categories.php | 2 +- main/ticket/priorities.php | 4 ++- main/ticket/projects.php | 4 ++- main/ticket/report.php | 4 ++- main/ticket/status.php | 4 ++- main/ticket/tickets.php | 4 ++- main/tracking/courseLog.php | 2 +- main/tracking/course_log_tools.php | 4 ++- 12 files changed, 57 insertions(+), 47 deletions(-) diff --git a/main/social/home.php b/main/social/home.php index ab6eef3f5e..e7288263e8 100755 --- a/main/social/home.php +++ b/main/social/home.php @@ -1,6 +1,8 @@ @@ -15,7 +17,7 @@ $user_id = api_get_user_id(); $show_full_profile = true; // social tab $this_section = SECTION_SOCIAL; -unset($_SESSION['this_section']); +Session::erase('this_section'); api_block_anonymous_users(); diff --git a/main/social/myfiles.php b/main/social/myfiles.php index 504e4c9774..10b9b0918e 100755 --- a/main/social/myfiles.php +++ b/main/social/myfiles.php @@ -1,6 +1,8 @@ 'profile.php', 'name' => get_lang('SocialNetwork') ); } else { - $_SESSION['this_section'] = SECTION_COURSES; + Session::write('this_section', SECTION_COURSES); $interbreadcrumb[] = array( 'url' => api_get_path(WEB_PATH).'user_portal.php', 'name' => get_lang('MyCourses') diff --git a/main/survey/fillsurvey.php b/main/survey/fillsurvey.php index f4e09b74f8..00e2802d54 100755 --- a/main/survey/fillsurvey.php +++ b/main/survey/fillsurvey.php @@ -1,6 +1,8 @@ '.get_lang('UpdateInformation').''; // We unset the sessions - unset($_SESSION['paged_questions']); - unset($_SESSION['page_questions_sec']); + Session::erase('paged_questions'); + Session::erase('page_questions_sec'); $paged_questions_sec = array(); $form->display(); } @@ -610,8 +612,8 @@ if (isset($_POST['finish_survey'])) { ); } - unset($_SESSION['paged_questions']); - unset($_SESSION['page_questions_sec']); + Session::erase('paged_questions'); + Session::erase('page_questions_sec'); Display::display_footer(); exit(); } @@ -628,11 +630,10 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { // As long as there is no pagebreak fount we keep adding questions to the page $questions_displayed = array(); $counter = 0; - $paged_questions = array(); - + $paged_questions = Session::read('paged_questions'); // If non-conditional survey if ($survey_data['survey_type'] === '0') { - if (empty($_SESSION['paged_questions'])) { + if (empty($paged_questions)) { $sql = "SELECT * FROM $table_survey_question WHERE c_id = $course_id AND @@ -647,21 +648,19 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { $paged_questions[$counter][] = $row['question_id']; } } - $_SESSION['paged_questions'] = $paged_questions; - } else { - $paged_questions = $_SESSION['paged_questions']; + Session::write('paged_questions', $paged_questions); } // Redefinition of variables and session ids to fix issue of survey not // showing questions - see support.chamilo.org #5529 $course_id = $survey_invitation['c_id']; - $_SESSION['_cid'] = $course_id; - $_SESSION['_real_cid'] = $course_id; + Session::write('_cid', $course_id); + Session::write('_real_cid', $course_id); if (array_key_exists($_GET['show'], $paged_questions)) { if (isset($_GET['user_id'])) { // Get the user into survey answer table (user or anonymus) - $my_user_id = ($survey_data['anonymous'] == 1) ? $_SESSION['surveyuser'] : api_get_user_id(); + $my_user_id = ($survey_data['anonymous'] == 1) ? $surveyUserFromSession : api_get_user_id(); $sql = "SELECT survey_question.survey_group_sec1, @@ -924,7 +923,6 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { // We only get highest 3 $secondary = ''; $combi = ''; - for ($i = 0; $i <= $group_cant; $i++) { $group1 = $groups[$i]; $group2 = $groups[$i + 1]; @@ -946,12 +944,6 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { } } } - /* - echo '
';
-                      echo 'Pair of Groups 

'; - echo $combi; - echo '
'; - */ // Create the new select with the questions from the secondary phase if (empty($_SESSION['page_questions_sec']) && !is_array($_SESSION['page_questions_sec']) && @@ -976,11 +968,11 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { $paged_questions_sec[$counter][] = $row['question_id']; } } - $_SESSION['paged_questions_sec'] = $paged_questions_sec; + Session::write('page_questions_sec', $paged_questions_sec); } else { - $paged_questions_sec = $_SESSION['paged_questions_sec']; + $paged_questions_sec = Session::read('page_questions_sec'); } - $paged_questions = $_SESSION['paged_questions']; // For the sake of pages counting + $paged_questions = Session::read('paged_questions'); // For the sake of pages counting //$paged_questions = $paged_questions_sec; // For the sake of pages counting coming up at display time... if ($shuffle == '') { $shuffle = ' BY survey_question.sort, survey_question_option.sort ASC '; @@ -1053,7 +1045,7 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { } } else { // We need this variable only in the 2nd set of questions when personality is set. - unset($_SESSION['page_questions_sec']); + Session::erase('page_questions_sec'); $paged_questions_sec = array(); // Only the questions from the basic group @@ -1086,9 +1078,9 @@ if (isset($_GET['show']) || isset($_POST['personality'])) { } } } - $_SESSION['paged_questions'] = $paged_questions; + Session::write('paged_questions', $paged_questions); } else { - $paged_questions = $_SESSION['paged_questions']; + $paged_questions = Session::read('paged_questions'); } $order_sql = $shuffle; if ($shuffle == '') { @@ -1320,7 +1312,7 @@ if ($survey_data['survey_type'] === '0') { $numberofpages += count($paged_questions_sec); } else { // We need this variable only if personality == 1 - unset($_SESSION['page_questions_sec']); + Session::erase('page_questions_sec'); $paged_questions_sec = array(); } diff --git a/main/survey/surveyUtil.class.php b/main/survey/surveyUtil.class.php index 7be7b1ab93..f9e2410484 100755 --- a/main/survey/surveyUtil.class.php +++ b/main/survey/surveyUtil.class.php @@ -2,6 +2,7 @@ /* For licensing terms, see /license.txt */ use Chamilo\CourseBundle\Entity\CSurvey; +use ChamiloSession as Session; /** * This class offers a series of general utility functions for survey querying and display @@ -106,11 +107,12 @@ class SurveyUtil // Make the survey anonymous if ($survey_data['anonymous'] == 1) { - if (!isset($_SESSION['surveyuser'])) { + $surveyUser = Session::read('surveyuser'); + if (empty($surveyUser)) { $user = md5($user.time()); - $_SESSION['surveyuser'] = $user; + Session::write('surveyuser', $user); } else { - $user = $_SESSION['surveyuser']; + $user = Session::read('surveyuser'); } } diff --git a/main/ticket/categories.php b/main/ticket/categories.php index e0fa34cf2f..1997845150 100644 --- a/main/ticket/categories.php +++ b/main/ticket/categories.php @@ -24,7 +24,7 @@ $user_id = api_get_user_id(); $isAdmin = api_is_platform_admin(); $this_section = 'tickets'; -unset($_SESSION['this_section']); +Session::erase('this_section'); $table = new SortableTable( 'TicketCategories', diff --git a/main/ticket/priorities.php b/main/ticket/priorities.php index 72dca990d3..a87bab098e 100644 --- a/main/ticket/priorities.php +++ b/main/ticket/priorities.php @@ -1,6 +1,8 @@ $(document).ready(function(){ diff --git a/main/ticket/status.php b/main/ticket/status.php index c3fea29d04..d1a15cc146 100644 --- a/main/ticket/status.php +++ b/main/ticket/status.php @@ -1,6 +1,8 @@ '; $this_section = 'tickets'; -unset($_SESSION['this_section']); +Session::erase('this_section'); $action = isset($_GET['action']) ? $_GET['action'] : ''; $projectId = isset($_GET['project_id']) ? (int) $_GET['project_id'] : 0; diff --git a/main/tracking/courseLog.php b/main/tracking/courseLog.php index 30db743f5d..dcfcb7ccf5 100755 --- a/main/tracking/courseLog.php +++ b/main/tracking/courseLog.php @@ -86,7 +86,7 @@ if (api_is_drh()) { if ($export_csv) { if (!empty($session_id)) { - $_SESSION['id_session'] = $session_id; + Session::write('id_session', $session_id); } ob_start(); } diff --git a/main/tracking/course_log_tools.php b/main/tracking/course_log_tools.php index 9feae62f97..8a983a57b8 100755 --- a/main/tracking/course_log_tools.php +++ b/main/tracking/course_log_tools.php @@ -1,6 +1,8 @@