Using function Database::get_statistic_table instead of $_configuration['statistics_database'] to avoid problems in queries see #3265

skala
Julio Montoya 14 years ago
parent 1edcf71929
commit 490de2ffae
  1. 2
      index.php
  2. 2
      main/inc/global.inc.php
  3. 39
      main/inc/lib/database.lib.php
  4. 8
      main/inc/lib/database.mysqli.lib.php
  5. 28
      main/inc/lib/events.lib.inc.php
  6. 4
      main/inc/lib/message.lib.php
  7. 2
      main/inc/lib/online.inc.php
  8. 21
      main/inc/lib/stats.lib.inc.php
  9. 7
      main/inc/local.inc.php
  10. 12
      main/tracking/course_access_details.php
  11. 15
      main/tracking/personnalLog.php
  12. 2
      main/tracking/toolaccess_details.php
  13. 12
      main/tracking/userLog.php
  14. 12
      main/tracking/userlogCSV.php

@ -337,7 +337,7 @@ function logout() {
$s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'";
Database::query($s_sql_update_logout_date);
}
LoginDelete($uid, $_configuration['statistics_database']); // From inc/lib/online.inc.php - removes the "online" status.
LoginDelete($uid); // From inc/lib/online.inc.php - removes the "online" status.
// The following code enables the use of an external logout function.
// Example: define a $extAuthSource['ldap']['logout'] = 'file.php' in configuration.php.

@ -272,7 +272,7 @@ require $includePath.'/local.inc.php';
require_once $lib_path.'online.inc.php';
// check and modify the date of user in the track.e.online table
if (!$x = strpos($_SERVER['PHP_SELF'], 'whoisonline.php')) {
LoginCheck(isset($_user['user_id']) ? $_user['user_id'] : '', $_configuration['statistics_database']);
LoginCheck(isset($_user['user_id']) ? $_user['user_id'] : '');
}
// ===== end "who is logged in?" module section =====

@ -16,6 +16,8 @@
/* CONSTANTS */
//@todo move this variables in a database_table.lib.php file to avoid repetition with the mysqli lib
// Main database tables
define('TABLE_MAIN_COURSE', 'course');
define('TABLE_MAIN_USER', 'user');
@ -110,21 +112,30 @@ define('TABLE_MAIN_LEGAL', 'legal');
define('TABLE_MAIN_BLOCK', 'block');
// Statistic database tables
define('TABLE_STATISTIC_TRACK_E_LASTACCESS', 'track_e_lastaccess');
define('TABLE_STATISTIC_TRACK_E_ACCESS', 'track_e_access');
define('TABLE_STATISTIC_TRACK_E_LOGIN', 'track_e_login');
define('TABLE_STATISTIC_TRACK_E_DOWNLOADS', 'track_e_downloads');
define('TABLE_STATISTIC_TRACK_E_LINKS', 'track_e_links');
define('TABLE_STATISTIC_TRACK_E_ONLINE', 'track_e_online');
define('TABLE_STATISTIC_TRACK_E_HOTPOTATOES', 'track_e_hotpotatoes');
define('TABLE_STATISTIC_TRACK_E_COURSE_ACCESS', 'track_e_course_access');
define('TABLE_STATISTIC_TRACK_E_EXERCICES', 'track_e_exercices');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT', 'track_e_attempt');
define('TABLE_STATISTIC_TRACK_E_LASTACCESS', 'track_e_lastaccess');
define('TABLE_STATISTIC_TRACK_E_ACCESS', 'track_e_access');
define('TABLE_STATISTIC_TRACK_E_LOGIN', 'track_e_login');
define('TABLE_STATISTIC_TRACK_E_DOWNLOADS', 'track_e_downloads');
define('TABLE_STATISTIC_TRACK_E_LINKS', 'track_e_links');
define('TABLE_STATISTIC_TRACK_E_ONLINE', 'track_e_online');
define('TABLE_STATISTIC_TRACK_E_HOTPOTATOES', 'track_e_hotpotatoes');
define('TABLE_STATISTIC_TRACK_E_COURSE_ACCESS', 'track_e_course_access');
define('TABLE_STATISTIC_TRACK_E_EXERCICES', 'track_e_exercices');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT', 'track_e_attempt');
define('TABLE_STATISTIC_TRACK_E_ATTEMPT_RECORDING', 'track_e_attempt_recording');
define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default');
define('TABLE_STATISTIC_TRACK_E_UPLOADS', 'track_e_uploads');
define('TABLE_STATISTIC_TRACK_E_HOTSPOT', 'track_e_hotspot');
define('TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY', 'track_e_item_property');
define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default');
define('TABLE_STATISTIC_TRACK_E_UPLOADS', 'track_e_uploads');
define('TABLE_STATISTIC_TRACK_E_HOTSPOT', 'track_e_hotspot');
define('TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY', 'track_e_item_property');
define('TABLE_STATISTIC_TRACK_E_OPEN', 'track_e_open');
define('TABLE_STATISTIC_TRACK_C_BROWSERS', 'track_c_browsers');
define('TABLE_STATISTIC_TRACK_C_COUNTRIES', 'track_c_countries');
define('TABLE_STATISTIC_TRACK_C_OS', 'track_c_os');
define('TABLE_STATISTIC_TRACK_C_PROVIDERS', 'track_c_providers');
define('TABLE_STATISTIC_TRACK_C_REFERERS', 'track_c_referers');
// SCORM database tables
define('TABLE_SCORM_MAIN', 'scorm_main');

@ -127,6 +127,14 @@ define('TABLE_STATISTIC_TRACK_E_DEFAULT', 'track_e_default');
define('TABLE_STATISTIC_TRACK_E_UPLOADS', 'track_e_uploads');
define('TABLE_STATISTIC_TRACK_E_HOTSPOT', 'track_e_hotspot');
define('TABLE_STATISTIC_TRACK_E_ITEM_PROPERTY', 'track_e_item_property');
define('TABLE_STATISTIC_TRACK_E_OPEN', 'track_e_open');
define('TABLE_STATISTIC_TRACK_C_BROWSERS', 'track_c_browsers');
define('TABLE_STATISTIC_TRACK_C_COUNTRIES', 'track_c_countries');
define('TABLE_STATISTIC_TRACK_C_OS', 'track_c_os');
define('TABLE_STATISTIC_TRACK_C_PROVIDERS', 'track_c_providers');
define('TABLE_STATISTIC_TRACK_C_REFERERS', 'track_c_referers');
// SCORM database tables
define('TABLE_SCORM_MAIN', 'scorm_main');

@ -3,28 +3,28 @@
/**
* EVENTS LIBRARY
*
* This is the events library for Dokeos.
* This is the events library for Chamilo.
* Include/require it in your code to use its functionality.
* Functions of this library are used to record informations when some kind
* of event occur. Each event has his own types of informations then each event
* use its own function.
*
* @package dokeos.library
* @todo convert queries to use Database API
* @package chamilo.library
*/
/* INIT SECTION */
// REGROUP TABLE NAMES FOR MAINTENANCE PURPOSE
$TABLETRACK_LOGIN = $_configuration['statistics_database'].".track_e_login";
$TABLETRACK_OPEN = $_configuration['statistics_database'].".track_e_open";
$TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
$TABLETRACK_DOWNLOADS = $_configuration['statistics_database'].".track_e_downloads";
$TABLETRACK_UPLOADS = $_configuration['statistics_database'].".track_e_uploads";
$TABLETRACK_LINKS = $_configuration['statistics_database'].".track_e_links";
$TABLETRACK_EXERCICES = $_configuration['statistics_database'].".track_e_exercices";
$TABLETRACK_SUBSCRIPTIONS = $_configuration['statistics_database'].".track_e_subscriptions";
$TABLETRACK_LASTACCESS = $_configuration['statistics_database'].".track_e_lastaccess"; //for "what's new" notification
$TABLETRACK_DEFAULT = $_configuration['statistics_database'].".track_e_default";
$TABLETRACK_LOGIN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$TABLETRACK_OPEN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_OPEN);
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_UPLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_UPLOADS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
//$TABLETRACK_SUBSCRIPTIONS = $_configuration['statistics_database'].".track_e_subscriptions"; // this table is never use
$TABLETRACK_LASTACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS); //for "what's new" notification
$TABLETRACK_DEFAULT = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DEFAULT);
/* FUNCTIONS */
/**

@ -32,7 +32,7 @@ class MessageManager
public static function get_online_user_list($current_user_id) {
$min=30;
global $_configuration;
$userlist = who_is_online($current_user_id,$_configuration['statistics_database'],$min);
$userlist = who_is_online($min, true);
foreach($userlist as $row) {
$receiver_id = $row[0];
$online_user_list[$receiver_id] = GetFullUserName($receiver_id).($current_user_id==$receiver_id?(" (".get_lang('Myself').")"):(""));
@ -95,7 +95,7 @@ class MessageManager
public static function users_connected_by_id() {
global $_configuration, $_user;
$minute=30;
$user_connect = who_is_online($_user['user_id'],$_configuration['statistics_database'],$minute);
$user_connect = who_is_online($minute, true);
for ($i=0; $i<count($user_connect); $i++) {
$user_id_list[$i]=$user_connect[$i][0];
}

@ -73,7 +73,7 @@ function online_logout() {
$s_sql_update_logout_date="UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'";
Database::query($s_sql_update_logout_date);
}
LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
LoginDelete($uid); //from inc/lib/online.inc.php - removes the "online" status
//the following code enables the use of an external logout function.
//example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php

@ -8,7 +8,6 @@
* @author Sebastien Piraux
* @package chamilo.library
*
* @todo use the Database libraries
*/
/*
@ -43,19 +42,17 @@
*/
// regroup table names for maintenance purpose
$TABLETRACK_OPEN = $_configuration['statistics_database'].".track_e_open";
$TABLESTATS_PROVIDERS = $_configuration['statistics_database'].".track_c_providers";
$TABLESTATS_COUNTRIES = $_configuration['statistics_database'].".track_c_countries";
$TABLESTATS_BROWSERS = $_configuration['statistics_database'].".track_c_browsers";
$TABLESTATS_OS = $_configuration['statistics_database'].".track_c_os";
$TABLESTATS_REFERERS = $_configuration['statistics_database'].".track_c_referers";
//we can use the database class: this file is only called in the /index.php file before the global.inc.php
$TABLETRACK_OPEN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_OPEN);
$TABLESTATS_PROVIDERS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_PROVIDERS);
$TABLESTATS_COUNTRIES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_COUNTRIES);
$TABLESTATS_BROWSERS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_BROWSERS);
$TABLESTATS_OS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_OS);
$TABLESTATS_REFERERS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_C_REFERERS);
/*
==============================================================================
Main : decodeOpenInfos launch all processes
==============================================================================
*/

@ -583,14 +583,15 @@ if (isset($uidReset) && $uidReset) { // session data refresh requested
if (isset($_user['user_id']) && $_user['user_id']) // a uid is given (log in succeeded)
{
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$track_e_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT user.*, a.user_id is_admin, UNIX_TIMESTAMP(login.login_date) login_date
FROM $user_table
LEFT JOIN $admin_table a
ON user.user_id = a.user_id
LEFT JOIN ".$_configuration['statistics_database'].".track_e_login login
LEFT JOIN $track_e_login login
ON user.user_id = login.login_user_id
WHERE user.user_id = '".$_user['user_id']."'
ORDER BY login.login_date DESC LIMIT 1";

@ -14,12 +14,12 @@
/*
INIT SECTION
*/
$reqdate = $_REQUEST['reqdate'];
$period = $_REQUEST['period'];
$displayType = $_REQUEST['displayType'];
$reqdate = $_REQUEST['reqdate'];
$period = $_REQUEST['period'];
$displayType = $_REQUEST['displayType'];
// name of the language file that needs to be included
$language_file = "tracking";
include('../inc/global.inc.php');
require_once '../inc/global.inc.php';
$interbreadcrumb[]= array ("url"=>"courseLog.php", "name"=> get_lang('ToolName'));
@ -38,9 +38,9 @@ td {border-bottom: thin dashed gray;}
/*]]>*/
</style>";
//@todo use Database library
$TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
Display::display_header($nameTools,"Tracking");
include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
require_once api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php";
// the variables for the days and the months
// Defining the shorts for the days

@ -12,9 +12,7 @@
// TODO: Is this file deprecated?
/*
==============================================================================
INIT SECTION
==============================================================================
*/
// name of the language file that needs to be included
@ -46,21 +44,20 @@ td {border-bottom: thin dashed gray;}
$view = preg_replace('/[^01]/','',$_REQUEST['view']);
$TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
$TABLETRACK_LINKS = $_configuration['statistics_database'].".track_e_links";
$TABLETRACK_DOWNLOADS = $_configuration['statistics_database'].".track_e_downloads";
$TABLETRACK_LOGIN = $_configuration['statistics_database'].".track_e_login";
$TABLETRACK_EXERCICES = $_configuration['statistics_database'].".track_e_exercices";
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
$TABLETRACK_LINKS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LINKS);
$TABLETRACK_DOWNLOADS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_DOWNLOADS);
$TABLETRACK_LOGIN = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$TABLETRACK_EXERCICES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_EXERCICES);
$limitOfDisplayedLogins = 25; // number of logins to display
include(api_get_path(LIBRARY_PATH)."statsUtils.lib.inc.php");
////////////// OUTPUT //////////////////////
Display::display_header($nameTools,"Tracking");
api_display_tool_title($nameTools);
/* MAIN SECTION */
// MAIN SECTION
// show all : view must be equal to the sum of all view values (1024+512+...+64)
// show none : 0

@ -74,7 +74,7 @@ $reqdate=$_REQUEST['reqdate'];
<?php
$TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
$TABLETRACK_ACCESS = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_ACCESS);
if(isset($_cid)) //stats for the current course
{

@ -74,19 +74,7 @@ $TABLECOURSUSER = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
$TABLETRACK_LINKS = $_configuration['statistics_database'].".track_e_links";
$TABLETRACK_LOGIN = $_configuration['statistics_database'].".track_e_login";
$TABLETRACK_DOWNLOADS = $_configuration['statistics_database'].".track_e_downloads";
$TABLETRACK_UPLOADS = $_configuration['statistics_database'].".track_e_uploads";
$TABLETRACK_EXERCICES = $_configuration['statistics_database'].".track_e_exercices";
$TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
$TABLECOURSE_WORK = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$TABLECOURSE_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
$TBL_TRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
if(api_get_setting('use_session_mode') == "true") {
$sql = "SELECT 1

@ -64,19 +64,7 @@ $TABLEUSER = Database::get_main_table(TABLE_MAIN_USER);
$tbl_session_course_user = Database::get_main_table(TABLE_MAIN_SESSION_COURSE_USER);
$tbl_session = Database::get_main_table(TABLE_MAIN_SESSION);
$TABLETRACK_ACCESS = $_configuration['statistics_database'].".track_e_access";
$TABLETRACK_LINKS = $_configuration['statistics_database'].".track_e_links";
$TABLETRACK_LOGIN = $_configuration['statistics_database'].".track_e_login";
$TABLETRACK_DOWNLOADS = $_configuration['statistics_database'].".track_e_downloads";
$TABLETRACK_UPLOADS = $_configuration['statistics_database'].".track_e_uploads";
$TABLETRACK_EXERCICES = $_configuration['statistics_database'].".track_e_exercices";
$TABLETRACK_HOTPOTATOES = $_configuration['statistics_database'].".track_e_hotpotatoes";
$TABLECOURSE_LINKS = Database::get_course_table(TABLE_LINK);
$TABLECOURSE_WORK = Database::get_course_table(TABLE_STUDENT_PUBLICATION);
$TABLECOURSE_GROUPSUSER = Database::get_course_table(TABLE_GROUP_USER);
$TABLECOURSE_EXERCICES = Database::get_course_table(TABLE_QUIZ_TEST);
//$TBL_TRACK_HOTPOTATOES = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_HOTPOTATOES);
if(api_get_setting('use_session_mode') == "true") {

Loading…
Cancel
Save