Просмотр исходного кода

Remove unsued api storage code and tables #2651

Julio 6 лет назад
Родитель
Сommit
0d3e999ae8

+ 0 - 39
main/admin/cli.php

@@ -1,39 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-/**
- * Used for external support of chamilo's users.
- *
- * @author Arnaud Ligot, CBlue SPRL
- *
- * @package chamilo.admin.cli
- */
-
-// we are in the admin area so we do not need a course id
-$cidReset = true;
-// include global script
-require_once __DIR__.'/../inc/global.inc.php';
-$this_section = SECTION_PLATFORM_ADMIN;
-// make sure only logged-in admins can execute this
-api_protect_admin_script();
-
-// setting the name of the tool
-$tool_name = get_lang('CommandLineInterpreter');
-// setting breadcrumbs
-$interbreadcrumb[] = ['url' => 'index.php', 'name' => get_lang('PlatformAdmin')];
-// including the header file (which includes the banner itself)
-Display :: display_header($tool_name);
-switch ($_GET["cmd"]) {
-    case "clear_stapi":
-        echo "Are you sure you are willing to erase all storage api data (no backup)? <a href='cli.php?cmd=clear_stapi_confirm' >Yes</a>";
-        break;
-    case "clear_stapi_confirm":
-        Database::query("delete from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES));
-        Database::query("delete from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK));
-        echo "Done";
-        break;
-    default:
-        echo "UNKNOWN COMMAND";
-        break;
-}
-
-Display :: display_footer();

+ 0 - 79
main/document/remote.php

@@ -1,79 +0,0 @@
-<?php
-/* See license terms in /license.txt */
-/**
- * Script that allows download of a specific file from external applications.
- *
- * @author Arnaud Ligot <arnaud@cblue.be>, Based on work done for old videoconference application (I have about 30 minutes to write this peace of code so if somebody has more time, feel free to rewrite it...)
- *
- * @package chamilo.document
- */
-/**
- * Script that allows remote download of a file.
- *
- * @param string Action parameter (action=...)
- * @param string Course code (cidReq=...)
- * @param string Current working directory (cwd=...)
- *
- * @return string JSON output
- */
-/* FIX for IE cache when using https */
-session_cache_limiter('none');
-require_once __DIR__.'/../inc/global.inc.php';
-api_block_anonymous_users();
-/*==== Variables initialisation ====*/
-$action = $_REQUEST['action']; //safe as only used in if()'s
-$seek = ['/', '%2F', '..'];
-$destroy = ['', '', ''];
-$cidReq = str_replace($seek, $destroy, $_REQUEST["cidReq"]);
-$cidReq = Security::remove_XSS($cidReq);
-$user_id = api_get_user_id();
-$coursePath = api_get_path(SYS_COURSE_PATH).$cidReq.'/document';
-$_course = api_get_course_info($cidReq);
-if (empty($_course)) {
-    die("problem when fetching course information");
-}
-// stupid variable initialisation for old version of DocumentManager functions.
-$_course['path'] = $_course['directory'];
-$is_manager = (CourseManager::getUserInCourseStatus($user_id, $_course['real_id']) == COURSEMANAGER);
-if ($debug > 0) {
-    error_log($coursePath, 0);
-}
-// FIXME: check security around $_REQUEST["cwd"]
-$cwd = $_REQUEST['cwd'];
-// treat /..
-$nParent = 0; // the number of /.. into the url
-while (substr($cwd, -3, 3) == '/..') {
-    // go to parent directory
-    $cwd = substr($cwd, 0, -3);
-    if (strlen($cwd) == 0) {
-        $cwd = '/';
-    }
-    $nParent++;
-}
-for (; $nParent > 0; $nParent--) {
-    $cwd = (strrpos($cwd, '/') > -1 ? substr($cwd, 0, strrpos($cwd, '/')) : $cwd);
-}
-if (strlen($cwd) == 0) {
-    $cwd = '/';
-}
-if (Security::check_abs_path($cwd, api_get_path(SYS_PATH))) {
-    die();
-}
-if ($action == 'list') {
-    /*==== List files ====*/
-    if ($debug > 0) {
-        error_log("sending file list", 0);
-    }
-
-    // get files list
-    $files = DocumentManager::getAllDocumentData($_course, $cwd, 0, null, false);
-
-    // adding download link to files
-    foreach ($files as $k => $f) {
-        if ($f['filetype'] == 'file') {
-            $files[$k]['download'] = api_get_path(WEB_COURSE_PATH).$cidReq."/document".$f['path'];
-        }
-        echo json_encode($files);
-        exit;
-    }
-}

+ 0 - 4
main/inc/lib/database.constants.inc.php

@@ -294,10 +294,6 @@ define('TABLE_USERGROUP_REL_USERGROUP', 'usergroup_rel_usergroup');
 // Mail notifications
 define('TABLE_NOTIFICATION', 'notification');
 
-//Storage api tables
-define('TABLE_TRACK_STORED_VALUES', 'track_stored_values');
-define('TABLE_TRACK_STORED_VALUES_STACK', 'track_stored_values_stack');
-
 define('TABLE_MAIN_SKILL', 'skill');
 define('TABLE_MAIN_SKILL_REL_SKILL', 'skill_rel_skill');
 define('TABLE_MAIN_SKILL_REL_GRADEBOOK', 'skill_rel_gradebook');

+ 0 - 43
main/lp/js/HOWTO-storageapi

@@ -1,43 +0,0 @@
-HOWTO use Storage API in your content.
-
-Include the following JavaScript function in your content:
---------------------javascript code--------------------
-function FindSTAPI(win) {
-	var g_nFindAPITries = 0;
-	while ((win.STAPI == null) && (win.parent != null) && (win.parent != win)) {
-		g_nFindAPITries ++;
-		if (g_nFindAPITries > 500) {
-			return null;
-		}
-		win = win.parent;
-	}
-	return win.STAPI;
-}
---------------------javascript code--------------------
-
-This function returns a facade object which has the following methods :
-
-- testCall(message) : outputs message in an alertbox, you can use it to make sure the API is reachable
-- getAllUsers : get a list of users info (user ids, usernames, firstnames, lastnames)
-
-Basic storage:
-- setValue(sv_key, sv_value): set the given value for the given key for the current user
-- getValue(sv_key): get the value stored for the key sv_key for the current user
-- getAll(): get all stored key/values pair for the current user
-
-Stack storage (you can store a stack of values instead of a single value for each key):
-- stack_push(sv_key, sv_value): push a new value in the stack for sv_key for the current user
-- stack_pop(sv_key): pop the most recently pushed value from the sv_key stack for the current user
-- stack_length(sv_key): get the number of stacked values for the key sv_key for the current user
-- stack_clear(sv_key): erase all values from the storage stack for the key sv_key for the current user
-- stack_getAll(sv_key): get all values from the storage stack for the key sv_key for the current user
-
-These storage values have superuser counterparts which allow platform administrators to alter values for any user :
-- setValue_user(sv_key, sv_value, user_id)
-- getValue(sv_key, user_id)
-- getAll(user_id)
-- stack_push(sv_key, sv_value, user_id)
-- stack_pop(sv_key, sv_value, user_id)
-- stack_length(sv_key, user_id)
-- stack_clear(sv_key, user_id)
-- stack_getAll(sv_key, user_id)

+ 0 - 28
main/lp/js/documentapi.js

@@ -1,28 +0,0 @@
-// JS interface enabling scorm content to use main/document/remote.php easily
-// CBlue SPRL, Arnaud Ligot <arnaud@cblue.be>
-
-
-lms_documents_list = function(path) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		datatype: "json",
-		url: "../document/remote.php",
-		data: {
-			action: "list",
-			cwd: path,
-			cidReq: chamilo_courseCode,
-		},
-		success: function(data) {
-			result = eval("("+data+")");
-		}
-	});
-	return result;
-}
-
-// Accessor object
-function DOCUMENTAPIobject() {
-	this.list = lms_documents_list;
-}
-var DOCUMENTAPI = new DOCUMENTAPIobject();

+ 0 - 302
main/lp/js/storageapi.js

@@ -1,302 +0,0 @@
-// Storage API
-// JavaScript API
-// CBlue SPRL, Jean-Karim Bockstael <jeankarim@cblue.be>
-
-
-lms_storage_testCall = function(content) {
-	alert(content);
-}
-
-lms_storage_setValue_user = function(sv_key, sv_value, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "set",
-			svkey: sv_key,
-			svvalue: sv_value,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = (data != '0');
-		}
-	});
-	return result;
-}
-
-lms_storage_getValue_user = function(sv_key, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "get",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = data;
-		}
-	});
-	return result;
-}
-
-lms_storage_getPosition_user = function(sv_key, sv_user, sv_asc) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "getposition",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco,
-			svasc: sv_asc
-		},
-		success: function(data) {
-			result = data;
-		}
-	});
-	return result;
-}
-
-lms_storage_getLeaders_user = function(sv_key, sv_user, sv_asc, sv_length) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "getleaders",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco,
-			svasc: sv_asc,
-			svlength: sv_length
-		},
-		success: function(data) {
-			result = eval("("+data+")");
-		}
-	});
-	return result;
-}
-
-
-
-lms_storage_getAll_user = function(sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "getall",
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = eval("("+data+")");
-		}
-	});
-	return result;
-}
-
-lms_storage_stack_push_user = function(sv_key, sv_value, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "stackpush",
-			svvalue: sv_value,
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = (data != '0');
-		}
-	});
-	return result;
-}
-
-lms_storage_stack_pop_user = function(sv_key, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "stackpop",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = data;
-		}
-	});
-	return result;
-}
-
-lms_storage_stack_length_user = function(sv_key, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "stacklength",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = data;
-		}
-	});
-	return result;
-}
-
-lms_storage_stack_clear_user = function(sv_key, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "stackclear",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = data;
-		}
-	});
-	return result;
-}
-
-lms_storage_stack_getAll_user = function(sv_key, sv_user) {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "stackgetall",
-			svkey: sv_key,
-			svuser: sv_user,
-			svcourse: sv_course,
-			svsco: sv_sco
-		},
-		success: function(data) {
-			result = eval("("+data+")");
-		}
-	});
-	return result;
-}
-
-lms_storage_getAllUsers = function() {
-	var result;
-	$.ajax({
-		async: false,
-		type: "POST",
-		url: "storageapi.php",
-		data: {
-			action: "usersgetall"
-		},
-		success: function(data) {
-			result = eval("("+data+")");
-		}
-	});
-	return result;
-}
-
-lms_storage_setValue = function(sv_key, sv_value) {
-	return lms_storage_setValue_user(sv_key, sv_value, sv_user);
-}
-
-lms_storage_getValue = function(sv_key) {
-	return lms_storage_getValue_user(sv_key, sv_user);
-}
-
-lms_storage_getPosition = function(sv_key, sv_asc) {
-	return lms_storage_getPosition_user(sv_key, sv_user, sv_asc);
-}
-
-lms_storage_getLeaders = function(sv_key, sv_asc, sv_length) {
-	return lms_storage_getLeaders_user(sv_key, sv_user, sv_asc, sv_length);
-}
-
-lms_storage_getAll = function() {
-	return lms_storage_getAll_user(sv_user);
-}
-
-lms_storage_stack_push = function(sv_key, sv_value) {
-	return lms_storage_stack_push_user(sv_key, sv_value, sv_user);
-}
-
-lms_storage_stack_pop = function(sv_key) {
-	return lms_storage_stack_pop(sv_key, sv_user);
-}
-
-lms_storage_stack_length = function(sv_key) {
-	return lms_storage_stack_length_user(sv_key, sv_user);
-}
-
-lms_storage_stack_clear = function(sv_key) {
-	return lms_storage_stack_clear_user(sv_key, sv_user);
-}
-
-lms_storage_stack_getAll = function(sv_key) {
-	return lms_storage_stack_getAll_user(sv_key, sv_user);
-}
-
-
-// Accessor object
-function STORAGEAPIobject() {
-	this.testCall = lms_storage_testCall;
-	this.setValue = lms_storage_setValue;
-	this.setValue_user = lms_storage_setValue_user;
-	this.getValue = lms_storage_getValue;
-	this.getValue_user = lms_storage_getValue_user;
-	this.getAll = lms_storage_getAll;
-	this.getAll_user = lms_storage_getAll_user;
-	this.getPosition_user = lms_storage_getPosition_user;
-	this.getPosition = lms_storage_getPosition;
-	this.getLeaders_user = lms_storage_getLeaders_user;
-	this.getLeaders = lms_storage_getLeaders;
-	this.stack_push = lms_storage_stack_push;
-	this.stack_push_user = lms_storage_stack_push_user;
-	this.stack_pop = lms_storage_stack_pop;
-	this.stack_pop_user = lms_storage_stack_pop_user;
-	this.stack_length = lms_storage_stack_length;
-	this.stack_length_user = lms_storage_stack_length_user;
-	this.stack_clear = lms_storage_stack_clear;
-	this.stack_clear_user = lms_storage_stack_clear_user;
-	this.stack_getAll = lms_storage_stack_getAll;
-	this.stack_getAll_user = lms_storage_stack_getAll_user;
-	this.getAllUsers = lms_storage_getAllUsers;
-	this.sv_user = sv_user;
-	this.sv_course = sv_course;
-	this.sv_sco = sv_sco;
-}
-var STORAGEAPI = new STORAGEAPIobject();
-var STAPI = STORAGEAPI;

+ 0 - 14
main/lp/lp_view.php

@@ -190,20 +190,6 @@ if (isset($exerciseResult) || isset($_SESSION['exerciseResult'])) {
     Session::erase('duration_time');
 }
 
-// additional APIs
-$htmlHeadXtra[] = '<script>
-chamilo_courseCode = "'.$course_code.'";
-</script>';
-// Document API
-$htmlHeadXtra[] = '<script src="js/documentapi.js" type="text/javascript" language="javascript"></script>';
-// Storage API
-$htmlHeadXtra[] = '<script>
-var sv_user = \''.api_get_user_id().'\';
-var sv_course = chamilo_courseCode;
-var sv_sco = \''.$lp_id.'\';
-</script>'; // FIXME fetch sco and userid from a more reliable source directly in sotrageapi.js
-$htmlHeadXtra[] = '<script type="text/javascript" src="js/storageapi.js"></script>';
-
 /**
  * Get a link to the corresponding document.
  */

+ 0 - 314
main/lp/storageapi.php

@@ -1,314 +0,0 @@
-<?php
-// Storage API
-// PHP Backend
-// CBlue SPRL, Jean-Karim Bockstael, <jeankarim@cblue.be>
-
-require_once '../inc/global.inc.php';
-
-// variable cleaning...
-foreach (["svkey", "svvalue"] as $key) {
-    $_REQUEST[$key] = Database::escape_string($_REQUEST[$key]);
-}
-
-foreach (["svuser", "svcourse", "svsco", "svlength", "svasc"] as $key) {
-    $_REQUEST[$key] = intval($_REQUEST[$key]);
-}
-
-switch ($_REQUEST['action']) {
-    case "get":
-        print storage_get($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
-        break;
-    case "set":
-        if (storage_can_set($_REQUEST['svuser'])) {
-            echo storage_set($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svvalue']);
-        }
-        break;
-    case "getall":
-        print storage_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco']);
-        break;
-    case "stackpush":
-        if (storage_can_set($_REQUEST['svuser'])) {
-            echo storage_stack_push($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svvalue']);
-        }
-        break;
-    case "stackpop":
-        if (storage_can_set($_REQUEST['svuser'])) {
-            echo storage_stack_pop($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
-        }
-        break;
-    case "stacklength":
-        print storage_stack_length($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
-        break;
-    case "stackclear":
-        if (storage_can_set($_REQUEST['svuser'])) {
-            echo storage_stack_clear($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
-        }
-        break;
-    case "stackgetall":
-        if (storage_can_set($_REQUEST['svuser'])) {
-            echo storage_stack_getall($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey']);
-        }
-        break;
-    case "getposition":
-        print storage_get_position($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc']);
-        break;
-    case "getleaders":
-        print storage_get_leaders($_REQUEST['svuser'], $_REQUEST['svcourse'], $_REQUEST['svsco'], $_REQUEST['svkey'], $_REQUEST['svasc'], $_REQUEST['svlength']);
-        break;
-    case "usersgetall":
-// security issue
-        print "NOT allowed, security issue, see sources";
-//		print storage_get_all_users();
-        break;
-    default:
-        // Do nothing
-}
-
-function storage_can_set($sv_user)
-{
-    // platform admin can change any user's stored values, other users can only change their own values
-    $allowed = ((api_is_platform_admin()) || ($sv_user == api_get_user_id()));
-    if (!$allowed) {
-        echo "ERROR : Not allowed";
-    }
-
-    return $allowed;
-}
-
-function storage_get($sv_user, $sv_course, $sv_sco, $sv_key)
-{
-    $sql = "select sv_value
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)."
-        where user_id= '$sv_user'
-        and sco_id = '$sv_sco'
-        and course_id = '$sv_course'
-        and sv_key = '$sv_key'";
-    $res = Database::query($sql);
-    if (Database::num_rows($res) > 0) {
-        $row = Database::fetch_assoc($res);
-        if (get_magic_quotes_gpc()) {
-            return stripslashes($row['sv_value']);
-        } else {
-            return $row['sv_value'];
-        }
-    } else {
-        return null;
-    }
-}
-
-function storage_get_leaders($sv_user, $sv_course, $sv_sco, $sv_key, $sv_asc, $sv_length)
-{
-    // get leaders
-    $sql_leaders = "select u.user_id, firstname, lastname, email, username, sv_value as value
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)." sv,
-            ".Database::get_main_table(TABLE_MAIN_USER)." u
-        where u.user_id=sv.user_id
-        and sco_id = '$sv_sco'
-        and course_id = '$sv_course'
-        and sv_key = '$sv_key'
-        order by sv_value ".($sv_asc ? "ASC" : "DESC")." limit $sv_length";
-    //	$sql_data = "select sv.user_id as user_id, sv_key as variable, sv_value as value
-    //		from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)." sv
-    //		where sv.user_id in (select u2.user_id from ($sql_leaders) u2)
-    //		and sco_id = '$sv_sco'
-    //		and course_id = '$sv_course'";
-    //	$resData = Database::query($sql_data);
-    //	$data = Array();
-    //	while($row = Database::fetch_assoc($resData))
-    //		$data[] = $row; // fetching all data
-//
-    $resLeaders = Database::query($sql_leaders);
-    $result = [];
-    while ($row = Database::fetch_assoc($resLeaders)) {
-        $row["values"] = [];
-        //		foreach($data as $dataRow) {
-        //			if ($dataRow["user_id"] = $row["user_id"])
-        //				$row["values"][$dataRow["variable"]] = $dataRow["value"];
-        //		}
-        $result[] = $row;
-    }
-
-    return json_encode($result);
-}
-
-function storage_get_position($sv_user, $sv_course, $sv_sco, $sv_key, $sv_asc, $sv_length)
-{
-    $sql = "select count(list.user_id) as position
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)." search,
-            ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)." list
-        where search.user_id= '$sv_user'
-        and search.sco_id = '$sv_sco'
-        and search.course_id = '$sv_course'
-        and search.sv_key = '$sv_key'
-        and list.sv_value ".($sv_asc ? "<=" : ">=")." search.sv_value
-        and list.sco_id = search.sco_id
-        and list.course_id = search.course_id
-        and list.sv_key = search.sv_key
-        order by list.sv_value";
-    $res = Database::query($sql);
-    if (Database::num_rows($res) > 0) {
-        $row = Database::fetch_assoc($res);
-
-        return $row['position'];
-    } else {
-        return null;
-    }
-}
-
-function storage_set($sv_user, $sv_course, $sv_sco, $sv_key, $sv_value)
-{
-    $sv_value = Database::escape_string($sv_value);
-    $sql = "replace into ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)."
-        (user_id, sco_id, course_id, sv_key, sv_value)
-        values
-        ('$sv_user','$sv_sco','$sv_course','$sv_key','$sv_value')";
-    $res = Database::query($sql);
-
-    return Database::affected_rows($res);
-}
-
-function storage_getall($sv_user, $sv_course, $sv_sco)
-{
-    $sql = "select sv_key, sv_value
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES)."
-        where user_id= '$sv_user'
-        and sco_id = '$sv_sco'
-        and course_id = '$sv_course'";
-    $res = Database::query($sql);
-    $data = [];
-    while ($row = Database::fetch_assoc($res)) {
-        if (get_magic_quotes_gpc()) {
-            $row['sv_value'] = stripslashes($row['sv_value']);
-        }
-        $data[] = $row;
-    }
-
-    return json_encode($data);
-}
-
-function storage_stack_push($sv_user, $sv_course, $sv_sco, $sv_key, $sv_value)
-{
-    $sv_value = Database::escape_string($sv_value);
-    Database::query("start transaction");
-    $sqlorder = "select ifnull((select max(stack_order)
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        where user_id= '$sv_user'
-        and sco_id='$sv_sco'
-        and course_id='$sv_course'
-        and sv_key='$sv_key'
-        ), 0) as stack_order";
-    $resorder = Database::query($sqlorder);
-    $row = Database::fetch_assoc($resorder);
-    $stack_order = (1 + $row['stack_order']);
-    $sqlinsert = "insert into ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        (user_id, sco_id, course_id, sv_key, stack_order, sv_value)
-        values
-        ('$sv_user', '$sv_sco', '$sv_course', '$sv_key', '$stack_order', '$sv_value')";
-    $resinsert = Database::query($sqlinsert);
-    if ($resorder && $resinsert) {
-        Database::query("commit");
-
-        return 1;
-    } else {
-        Database::query("rollback");
-
-        return 0;
-    }
-}
-
-function storage_stack_pop($sv_user, $sv_course, $sv_sco, $sv_key)
-{
-    Database::query("start transaction");
-    $sqlselect = "select sv_value, stack_order
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        where user_id= '$sv_user'
-        and sco_id='$sv_sco'
-        and course_id='$sv_course'
-        and sv_key='$sv_key'
-        order by stack_order desc
-        limit 1";
-    $resselect = Database::query($sqlselect);
-    $rowselect = Database::fetch_assoc($resselect);
-    $stack_order = $rowselect['stack_order'];
-    $sqldelete = "delete
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        where user_id= '$sv_user'
-        and sco_id='$sv_sco'
-        and course_id='$sv_course'
-        and sv_key='$sv_key'
-        and stack_order='$stack_order'";
-    $resdelete = Database::query($sqldelete);
-    if ($resselect && $resdelete) {
-        Database::query("commit");
-        if (get_magic_quotes_gpc()) {
-            return stripslashes($rowselect['sv_value']);
-        } else {
-            return $rowselect['sv_value'];
-        }
-    } else {
-        Database::query("rollback");
-
-        return null;
-    }
-}
-
-function storage_stack_length($sv_user, $sv_course, $sv_sco, $sv_key)
-{
-    $sql = "select count(*) as length
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        where user_id= '$sv_user'
-        and sco_id='$sv_sco'
-        and course_id='$sv_course'
-        and sv_key='$sv_key'";
-    $res = Database::query($sql);
-    $row = Database::fetch_assoc($res);
-
-    return $row['length'];
-}
-
-function storage_stack_clear($sv_user, $sv_course, $sv_sco, $sv_key)
-{
-    $sql = "delete
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        where user_id= '$sv_user'
-        and sco_id='$sv_sco'
-        and course_id='$sv_course'
-        and sv_key='$sv_key'";
-    $res = Database::query($sql);
-
-    return Database::num_rows($res);
-}
-
-function storage_stack_getall($sv_user, $sv_course, $sv_sco, $sv_key)
-{
-    $sql = "select stack_order as stack_order, sv_value as value
-        from ".Database::get_main_table(TABLE_TRACK_STORED_VALUES_STACK)."
-        where user_id= '$sv_user'
-        and sco_id='$sv_sco'
-        and course_id='$sv_course'
-        and sv_key='$sv_key'";
-    $res = Database::query($sql);
-    $results = [];
-    while ($row = Database::fetch_assoc($res)) {
-        if (get_magic_quotes_gpc()) {
-            $row['value'] = stripslashes($row['value']);
-        }
-        $results[] = $row;
-    }
-
-    return json_encode($results);
-}
-
-function storage_get_all_users()
-{
-    $sql = "select user_id, username, firstname, lastname
-        from ".Database::get_main_table(TABLE_MAIN_USER)."
-        order by user_id asc";
-    $res = Database::query($sql);
-    $results = [];
-    while ($row = Database::fetch_assoc($res)) {
-        $results[] = $row;
-    }
-
-    return json_encode($results);
-}

+ 0 - 197
src/CoreBundle/Entity/TrackStoredValues.php

@@ -1,197 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-namespace Chamilo\CoreBundle\Entity;
-
-use Doctrine\ORM\Mapping as ORM;
-
-/**
- * TrackStoredValues.
- *
- * @ORM\Table(
- *  name="track_stored_values",
- *  uniqueConstraints={
- *      @ORM\UniqueConstraint(name="user_id_2", columns={"user_id", "sco_id", "course_id", "sv_key"})
- *  },
- *  indexes={
- *      @ORM\Index(name="user_sco_course_sv", columns={"user_id", "sco_id", "course_id", "sv_key"})
- *  }
- * )
- * @ORM\Entity
- */
-class TrackStoredValues
-{
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="user_id", type="integer", nullable=false)
-     */
-    protected $userId;
-
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="sco_id", type="integer", nullable=false)
-     */
-    protected $scoId;
-
-    /**
-     * @var string
-     *
-     * @ORM\Column(name="course_id", type="string", length=40, nullable=false)
-     */
-    protected $courseId;
-
-    /**
-     * @var string
-     *
-     * @ORM\Column(name="sv_key", type="string", length=64, nullable=false)
-     */
-    protected $svKey;
-
-    /**
-     * @var string
-     *
-     * @ORM\Column(name="sv_value", type="text", nullable=false)
-     */
-    protected $svValue;
-
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="id", type="integer")
-     * @ORM\Id
-     * @ORM\GeneratedValue(strategy="IDENTITY")
-     */
-    protected $id;
-
-    /**
-     * Set userId.
-     *
-     * @param int $userId
-     *
-     * @return TrackStoredValues
-     */
-    public function setUserId($userId)
-    {
-        $this->userId = $userId;
-
-        return $this;
-    }
-
-    /**
-     * Get userId.
-     *
-     * @return int
-     */
-    public function getUserId()
-    {
-        return $this->userId;
-    }
-
-    /**
-     * Set scoId.
-     *
-     * @param int $scoId
-     *
-     * @return TrackStoredValues
-     */
-    public function setScoId($scoId)
-    {
-        $this->scoId = $scoId;
-
-        return $this;
-    }
-
-    /**
-     * Get scoId.
-     *
-     * @return int
-     */
-    public function getScoId()
-    {
-        return $this->scoId;
-    }
-
-    /**
-     * Set courseId.
-     *
-     * @param string $courseId
-     *
-     * @return TrackStoredValues
-     */
-    public function setCourseId($courseId)
-    {
-        $this->courseId = $courseId;
-
-        return $this;
-    }
-
-    /**
-     * Get courseId.
-     *
-     * @return string
-     */
-    public function getCourseId()
-    {
-        return $this->courseId;
-    }
-
-    /**
-     * Set svKey.
-     *
-     * @param string $svKey
-     *
-     * @return TrackStoredValues
-     */
-    public function setSvKey($svKey)
-    {
-        $this->svKey = $svKey;
-
-        return $this;
-    }
-
-    /**
-     * Get svKey.
-     *
-     * @return string
-     */
-    public function getSvKey()
-    {
-        return $this->svKey;
-    }
-
-    /**
-     * Set svValue.
-     *
-     * @param string $svValue
-     *
-     * @return TrackStoredValues
-     */
-    public function setSvValue($svValue)
-    {
-        $this->svValue = $svValue;
-
-        return $this;
-    }
-
-    /**
-     * Get svValue.
-     *
-     * @return string
-     */
-    public function getSvValue()
-    {
-        return $this->svValue;
-    }
-
-    /**
-     * Get id.
-     *
-     * @return int
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-}

+ 0 - 228
src/CoreBundle/Entity/TrackStoredValuesStack.php

@@ -1,228 +0,0 @@
-<?php
-/* For licensing terms, see /license.txt */
-
-namespace Chamilo\CoreBundle\Entity;
-
-use Doctrine\ORM\Mapping as ORM;
-
-/**
- * TrackStoredValuesStack.
- *
- * @ORM\Table(
- *  name="track_stored_values_stack",
- *  uniqueConstraints={
- *      @ORM\UniqueConstraint(name="user_id_2", columns={"user_id", "sco_id", "course_id", "sv_key", "stack_order"})
- *  },
- *  indexes={
- *      @ORM\Index(name="user_sco_course_sv_stack", columns={"user_id", "sco_id", "course_id", "sv_key", "stack_order"})
- *  }
- * )
- * @ORM\Entity
- */
-class TrackStoredValuesStack
-{
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="id", type="integer")
-     * @ORM\Id
-     * @ORM\GeneratedValue
-     */
-    protected $id;
-
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="user_id", type="integer", nullable=false)
-     */
-    protected $userId;
-
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="sco_id", type="integer", nullable=false)
-     */
-    protected $scoId;
-
-    /**
-     * @var int
-     *
-     * @ORM\Column(name="stack_order", type="integer", nullable=false)
-     */
-    protected $stackOrder;
-
-    /**
-     * @var string
-     *
-     * @ORM\Column(name="course_id", type="string", length=40, nullable=false)
-     */
-    protected $courseId;
-
-    /**
-     * @var string
-     *
-     * @ORM\Column(name="sv_key", type="string", length=64, nullable=false)
-     */
-    protected $svKey;
-
-    /**
-     * @var string
-     *
-     * @ORM\Column(name="sv_value", type="text", nullable=false)
-     */
-    protected $svValue;
-
-    /**
-     * Set userId.
-     *
-     * @param int $userId
-     *
-     * @return TrackStoredValuesStack
-     */
-    public function setUserId($userId)
-    {
-        $this->userId = $userId;
-
-        return $this;
-    }
-
-    /**
-     * Get userId.
-     *
-     * @return int
-     */
-    public function getUserId()
-    {
-        return $this->userId;
-    }
-
-    /**
-     * Set scoId.
-     *
-     * @param int $scoId
-     *
-     * @return TrackStoredValuesStack
-     */
-    public function setScoId($scoId)
-    {
-        $this->scoId = $scoId;
-
-        return $this;
-    }
-
-    /**
-     * Get scoId.
-     *
-     * @return int
-     */
-    public function getScoId()
-    {
-        return $this->scoId;
-    }
-
-    /**
-     * Set stackOrder.
-     *
-     * @param int $stackOrder
-     *
-     * @return TrackStoredValuesStack
-     */
-    public function setStackOrder($stackOrder)
-    {
-        $this->stackOrder = $stackOrder;
-
-        return $this;
-    }
-
-    /**
-     * Get stackOrder.
-     *
-     * @return int
-     */
-    public function getStackOrder()
-    {
-        return $this->stackOrder;
-    }
-
-    /**
-     * Set courseId.
-     *
-     * @param string $courseId
-     *
-     * @return TrackStoredValuesStack
-     */
-    public function setCourseId($courseId)
-    {
-        $this->courseId = $courseId;
-
-        return $this;
-    }
-
-    /**
-     * Get courseId.
-     *
-     * @return string
-     */
-    public function getCourseId()
-    {
-        return $this->courseId;
-    }
-
-    /**
-     * Set svKey.
-     *
-     * @param string $svKey
-     *
-     * @return TrackStoredValuesStack
-     */
-    public function setSvKey($svKey)
-    {
-        $this->svKey = $svKey;
-
-        return $this;
-    }
-
-    /**
-     * Get svKey.
-     *
-     * @return string
-     */
-    public function getSvKey()
-    {
-        return $this->svKey;
-    }
-
-    /**
-     * Set svValue.
-     *
-     * @param string $svValue
-     *
-     * @return TrackStoredValuesStack
-     */
-    public function setSvValue($svValue)
-    {
-        $this->svValue = $svValue;
-
-        return $this;
-    }
-
-    /**
-     * Get svValue.
-     *
-     * @return string
-     */
-    public function getSvValue()
-    {
-        return $this->svValue;
-    }
-
-    /**
-     * Get id.
-     *
-     * @return int
-     */
-    public function getId()
-    {
-        return $this->id;
-    }
-}

+ 11 - 7
src/CoreBundle/Migrations/Schema/V200/Version20.php

@@ -154,9 +154,6 @@ class Version20 extends AbstractMigrationChamilo
 
         $this->addSql('ALTER TABLE c_tool ADD CONSTRAINT FK_8456658091D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)');
 
-        $this->addSql('DROP INDEX user_sco_course_sv ON track_stored_values;');
-        $this->addSql('DROP INDEX user_sco_course_sv_stack ON track_stored_values_stack;');
-
         $this->addSql('UPDATE c_tool SET name = "blog" WHERE name = "blog_management" ');
         $this->addSql('UPDATE c_tool SET name = "agenda" WHERE name = "calendar_event" ');
         $this->addSql('UPDATE c_tool SET name = "maintenance" WHERE name = "course_maintenance" ');
@@ -278,13 +275,13 @@ class Version20 extends AbstractMigrationChamilo
         }
         /*
                 $this->addSql("ALTER TABLE personal_agenda DROP course");
-        
+
                 $this->addSql("
                     ALTER TABLE specific_field_values
                     ADD c_id int(11) NOT NULL,
                     ADD FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE RESTRICT;
                 ");
-        
+
                 $this->addSql("
                     ALTER TABLE track_e_hotspot
                     CHANGE c_id c_id int(11) NOT NULL AFTER hotspot_course_code,
@@ -724,8 +721,15 @@ class Version20 extends AbstractMigrationChamilo
             }
         }
 
-        // Drop unused tables
-        $dropTables = ['event_email_template', 'event_sent', 'user_rel_event_type', 'openid_association'];
+        // Drop tables
+        $dropTables = [
+            'event_email_template',
+            'event_sent',
+            'user_rel_event_type',
+            'openid_association',
+            'track_stored_values',
+            'track_stored_values_stack',
+        ];
         foreach ($dropTables as $table) {
             if ($schema->hasTable($table)) {
                 $schema->dropTable($table);