Use ChamiloSession class

pull/2487/head
jmontoyaa 7 years ago
parent e1ad1477b1
commit 5d2a5f94c1
  1. 4
      main/exercise/hotspot_actionscript_admin.as.php
  2. 23
      main/exercise/upload_exercise.php
  3. 14
      main/inc/ajax/lp.ajax.php
  4. 12
      main/inc/email_editor.php
  5. 14
      main/inc/lib/document.lib.php
  6. 11
      main/inc/lib/myspace.lib.php
  7. 18
      main/inc/lib/notebook.lib.php
  8. 43
      main/inc/lib/tracking.lib.php
  9. 2
      main/lp/aicc_api.php
  10. 1
      main/lp/download.php

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This file generates the ActionScript variables code used by the HotSpot .swf
* @package chamilo.exercise
@ -61,7 +63,7 @@ $i = 0;
$nmbrTries = 0;
$answer_type = $objQuestion->type;
$answers = $_SESSION['tmp_answers'];
$answers = Session::read('tmp_answers');
$nbrAnswers = count($answers['answer']);
for ($i = 1; $i <= $nbrAnswers; $i++) {

@ -14,6 +14,7 @@ $help_content = 'exercise_upload';
require_once __DIR__.'/../inc/global.inc.php';
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
$debug = false;
$origin = api_get_origin();
if (!$is_allowed_to_edit) {
api_not_allowed(true);
@ -538,11 +539,10 @@ function lp_upload_quiz_action_handling()
}
}
if (isset($_SESSION['lpobject'])) {
if ($debug > 0) {
error_log('New LP - SESSION[lpobject] is defined', 0);
}
$oLP = unserialize($_SESSION['lpobject']);
$lpObject = Session::read('lpobject');
if (!empty($lpObject)) {
$oLP = unserialize($lpObject);
if (is_object($oLP)) {
if ($debug > 0) {
error_log('New LP - oLP is object', 0);
@ -555,7 +555,7 @@ function lp_upload_quiz_action_handling()
Session::erase('oLP');
Session::erase('lpobject');
} else {
$_SESSION['oLP'] = $oLP;
Session::write('oLP', $oLP);
}
}
}
@ -564,9 +564,16 @@ function lp_upload_quiz_action_handling()
$previous = $_SESSION['oLP']->select_previous_item_id();
$parent = 0;
// Add a Quiz as Lp Item
$_SESSION['oLP']->add_item($parent, $previous, TOOL_QUIZ, $quiz_id, $quizTitle, '');
$_SESSION['oLP']->add_item(
$parent,
$previous,
TOOL_QUIZ,
$quiz_id,
$quizTitle,
''
);
// Redirect to home page for add more content
header('location: ../lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.intval($_GET['lp_id']));
header('Location: ../lp/lp_controller.php?'.api_get_cidreq().'&action=add_item&type=step&lp_id='.intval($_GET['lp_id']));
exit;
} else {
// header('location: exercise.php?' . api_get_cidreq());

@ -41,9 +41,11 @@ switch ($action) {
break;
case 'add_lp_item':
if (api_is_allowed_to_edit(null, true)) {
if ($_SESSION['oLP']) {
/** @var learnpath $learningPath */
$learningPath = Session::read('oLP');
if ($learningPath) {
// Updating the lp.modified_on
$_SESSION['oLP']->set_modified_on();
$learningPath->set_modified_on();
$title = $_REQUEST['title'];
if ($_REQUEST['type'] == TOOL_QUIZ) {
$title = Exercise::format_title_variable($title);
@ -52,7 +54,7 @@ switch ($action) {
$parentId = isset($_REQUEST['parent_id']) ? $_REQUEST['parent_id'] : '';
$previousId = isset($_REQUEST['previous_id']) ? $_REQUEST['previous_id'] : '';
echo $_SESSION['oLP']->add_item(
echo $learningPath->add_item(
$parentId,
$previousId,
$_REQUEST['type'],
@ -187,7 +189,11 @@ switch ($action) {
break;
}
$learningPath = learnpath::getLpFromSession(api_get_course_id(), $lpId, api_get_user_id());
$learningPath = learnpath::getLpFromSession(
api_get_course_id(),
$lpId,
api_get_user_id()
);
$lpItem = $learningPath->getItem($lpItemId);
if (empty($lpItem)) {

@ -14,13 +14,13 @@ use ChamiloSession as Session;
require_once __DIR__.'/../inc/global.inc.php';
if (empty($_user['user_id'])) {
if (empty(api_get_user_id())) {
api_not_allowed(true);
}
if (empty($_SESSION['origin_url'])) {
$origin_url = $_SERVER['HTTP_REFERER'];
Session::write('origin_url', $origin_url);
$originUrl = Session::read('origin_url');
if (empty($originUrl)) {
Session::write('origin_url', $_SERVER['HTTP_REFERER']);
}
$action = isset($_GET['action']) ? $_GET['action'] : null;
@ -95,9 +95,9 @@ if ($form->validate()) {
get_lang('Anonymous')
);
}
$orig = $_SESSION['origin_url'];
$orig = Session::read('origin_url');
Session::erase('origin_url');
header('location:'.$orig);
header('Location:'.$orig);
exit;
}
Display::display_header(get_lang('SendEmail'));

@ -4802,8 +4802,8 @@ class DocumentManager
copy($from_sys, $to_sys);
}
//get file from tmp directory
$_SESSION['temp_audio_nanogong'] = $to_sys;
// get file from tmp directory
Session::write('temp_audio_nanogong', $to_sys);
return api_get_path(WEB_ARCHIVE_PATH).'temp/audio/'.$file_crip;
}
@ -4813,12 +4813,10 @@ class DocumentManager
*/
public static function removeGeneratedAudioTempFile()
{
if (isset($_SESSION['temp_audio_nanogong'])
&& !empty($_SESSION['temp_audio_nanogong'])
&& is_file($_SESSION['temp_audio_nanogong'])) {
unlink($_SESSION['temp_audio_nanogong']);
unset($_SESSION['temp_audio_nanogong']);
$tempAudio = Session::read('temp_audio_nanogong');
if (!empty(isset($tempAudio)) && is_file($tempAudio)) {
unlink($tempAudio);
Session::erase('temp_audio_nanogong');
}
}

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
use CpChart\Cache as pCache;
use CpChart\Data as pData;
use CpChart\Image as pImage;
@ -583,17 +584,19 @@ class MySpace
public static function sort_users($a, $b)
{
$tracking = Session::read('tracking_column');
return api_strcmp(
trim(api_strtolower($a[$_SESSION['tracking_column']])),
trim(api_strtolower($b[$_SESSION['tracking_column']]))
trim(api_strtolower($a[$tracking])),
trim(api_strtolower($b[$tracking]))
);
}
public static function rsort_users($a, $b)
{
$tracking = Session::read('tracking_column');
return api_strcmp(
trim(api_strtolower($b[$_SESSION['tracking_column']])),
trim(api_strtolower($a[$_SESSION['tracking_column']]))
trim(api_strtolower($b[$tracking])),
trim(api_strtolower($a[$tracking]))
);
}

@ -1,6 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession as Session;
/**
* This class provides methods for the notebook management.
* Include/require it in your code to use its features.
@ -258,25 +260,25 @@ class NotebookManager
Display::return_icon('notes_order_by_title.png', get_lang('OrderByTitle'), '', '32').'</a>';
echo '</div>';
if (!isset($_SESSION['notebook_view']) ||
!in_array($_SESSION['notebook_view'], array('creation_date', 'update_date', 'title'))
) {
$_SESSION['notebook_view'] = 'creation_date';
$notebookView = Session::read('notebook_view');
if (!in_array($notebookView, array('creation_date', 'update_date', 'title'))) {
Session::write('notebook_view', 'creation_date');
}
// Database table definition
$t_notebook = Database::get_course_table(TABLE_NOTEBOOK);
if ($_SESSION['notebook_view'] == 'creation_date' || $_SESSION['notebook_view'] == 'update_date') {
$order_by = " ORDER BY ".$_SESSION['notebook_view']." $sort_direction ";
if ($notebookView == 'creation_date' || $notebookView == 'update_date') {
$order_by = " ORDER BY ".$notebookView." $sort_direction ";
} else {
$order_by = " ORDER BY ".$_SESSION['notebook_view']." $sort_direction ";
$order_by = " ORDER BY ".$notebookView." $sort_direction ";
}
//condition for the session
$session_id = api_get_session_id();
$condition_session = api_get_session_condition($session_id);
$cond_extra = ($_SESSION['notebook_view'] == 'update_date') ? " AND update_date <> ''" : " ";
$cond_extra = $notebookView == 'update_date' ? " AND update_date <> ''" : " ";
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM $t_notebook

@ -1,6 +1,7 @@
<?php
/* For licensing terms, see /license.txt */
use ChamiloSession;
use Chamilo\CoreBundle\Entity\ExtraField as EntityExtraField;
use CpChart\Cache as pCache;
use CpChart\Data as pData;
@ -85,11 +86,33 @@ class Tracking
$messages = 0;
foreach ($users as $user_data) {
$time += self::get_time_spent_on_the_course($user_data['user_id'], $course_info['code'], $sessionId);
$avg_student_score += self::get_avg_student_score($user_data['user_id'], $course_info['code'], array(), $sessionId);
$avg_student_progress += self::get_avg_student_progress($user_data['user_id'], $course_info['code'], array(), $sessionId);
$work += self::count_student_assignments($user_data['user_id'], $course_info['code'], $sessionId);
$messages += self::count_student_messages($user_data['user_id'], $course_info['code'], $sessionId);
$time += self::get_time_spent_on_the_course(
$user_data['user_id'],
$course_info['code'],
$sessionId
);
$avg_student_score += self::get_avg_student_score(
$user_data['user_id'],
$course_info['code'],
array(),
$sessionId
);
$avg_student_progress += self::get_avg_student_progress(
$user_data['user_id'],
$course_info['code'],
array(),
$sessionId
);
$work += self::count_student_assignments(
$user_data['user_id'],
$course_info['code'],
$sessionId
);
$messages += self::count_student_messages(
$user_data['user_id'],
$course_info['code'],
$sessionId
);
}
$countUsers = count($users);
@ -7052,17 +7075,19 @@ class TrackingCourseLog
public function sort_users($a, $b)
{
$tracking = ChamiloSession::read('tracking_column');
return strcmp(
trim(api_strtolower($a[$_SESSION['tracking_column']])),
trim(api_strtolower($b[$_SESSION['tracking_column']]))
trim(api_strtolower($a[$tracking])),
trim(api_strtolower($b[$tracking]))
);
}
public function sort_users_desc($a, $b)
{
$tracking = ChamiloSession::read('tracking_column');
return strcmp(
trim(api_strtolower($b[$_SESSION['tracking_column']])),
trim(api_strtolower($a[$_SESSION['tracking_column']]))
trim(api_strtolower($b[$tracking])),
trim(api_strtolower($a[$tracking]))
);
}

@ -32,7 +32,7 @@ $use_anonymous = true;
require_once __DIR__.'/../inc/global.inc.php';
// Is this needed? This is probabaly done in the header file.
$file = $_SESSION['file'];
$file = Session::read('file');
$oLP = unserialize(Session::read('lpobject'));
$oItem = $oLP->items[$oLP->current];
if (!is_object($oItem)) {

@ -35,7 +35,6 @@ if ($_SESSION['oLP']) {
$lp_item_id = $_SESSION['oLP']->current;
$lp_item_info = new learnpathItem($lp_item_id);
if (!empty($lp_item_info)) {
//if (basename($lp_item_info->path) == basename($doc_url)) {
$visible = learnpath::is_lp_visible_for_student($lp_id, $user_id);
if ($visible) {

Loading…
Cancel
Save