Format code, rename function, remove unneeded functions.

1.10.x
Julio Montoya 11 years ago
parent ba95269ead
commit 2b17f983b9
  1. 109
      main/inc/lib/database.mysqli.lib.php
  2. 4
      main/inc/local.inc.php

@ -44,15 +44,6 @@ class MySQLIDatabase {
return $_configuration['main_database']; return $_configuration['main_database'];
} }
/**
* Returns the name of the statistics database.
*/
public static function get_statistic_database()
{
global $_configuration;
return $_configuration['statistics_database'];
}
/** /**
* Returns the name of the SCORM database. * Returns the name of the SCORM database.
* @deprecated * @deprecated
@ -183,37 +174,6 @@ class MySQLIDatabase {
return self::format_glued_course_table_name(self::fix_database_parameter($database_name), $short_table_name); return self::format_glued_course_table_name(self::fix_database_parameter($database_name), $short_table_name);
} }
/**
* This generic method returns the correct and complete name of any statistic table
* of which you pass the short name as a parameter.
* Please, define table names as constants in this library and use them
* instead of directly using magic words in your tool code.
*
* @param string $short_table_name, the name of the table
* @return string The full name of the requested stats table
*/
public static function get_statistic_table($short_table_name)
{
return self::format_table_name(self::get_statistic_database(), $short_table_name);
}
/**
* This generic method returns the correct and complete name of any scorm
* table of which you pass the short name as a parameter. Please, define
* table names as constants in this library and use them instead of directly
* using magic words in your tool code.
*
* @param string $short_table_name, the name of the table
*/
public static function get_user_personal_table($short_table_name)
{
return self::format_table_name(self::get_user_personal_database(), $short_table_name);
}
public static function get_course_chat_connected_table($database_name = '')
{
return self::format_glued_course_table_name(self::fix_database_parameter($database_name), TABLE_CHAT_CONNECTED);
}
/* /*
Query methods Query methods
@ -231,23 +191,6 @@ class MySQLIDatabase {
return self::store_result(self::query("SELECT * FROM $table")); return self::store_result(self::query("SELECT * FROM $table"));
} }
/**
* Returns an array with all database fields for the specified course.
*
* @param string $course_code The real (system) code of the course (ID from inside the main course table)
* @return array Course info from the course table
* @todo shouldn't this be in the course.lib.php script?
*/
public static function get_course_info($course_code)
{
$course_code = self::escape_string($course_code);
$table = self::get_main_table(TABLE_MAIN_COURSE);
$result = self::generate_abstract_course_field_names(
self::fetch_array(self::query("SELECT * FROM $table WHERE code = '$course_code'"))
);
return $result === false ? array('db_name' => '') : $result;
}
/** /**
* @param $user_id (integer): the id of the user * @param $user_id (integer): the id of the user
* @return $user_info (array): user_id, lastname, firstname, username, email, ... * @return $user_info (array): user_id, lastname, firstname, username, email, ...
@ -281,58 +224,6 @@ class MySQLIDatabase {
return $info ? $info['course_code'] : false; return $info ? $info['course_code'] : false;
} }
/**
* This method creates an abstraction layer between database field names
* and field names expected in code.
*
* This approach helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
*
* @todo add more array entries to abstract course info from field names
* @author Roan Embrechts
*
* @todo What's the use of this method. I think this is better removed.
* There should be consistency in the variable names and the use throughout the scripts
* for the database name we should consistently use or db_name or database (db_name probably being the better one)
*/
public static function generate_abstract_course_field_names($result_array)
{
$visual_code = isset($result_array['visual_code']) ? $result_array['visual_code'] : null;
$code = isset($result_array['code']) ? $result_array['code'] : null;
$title = isset($result_array['title']) ? $result_array['title'] : null;
$db_name = isset($result_array['db_name']) ? $result_array['db_name'] : null;
$category_code = isset($result_array['category_code']) ? $result_array['category_code'] : null;
$result_array['official_code'] = $visual_code;
$result_array['visual_code'] = $visual_code;
$result_array['real_code'] = $code;
$result_array['system_code'] = $code;
$result_array['title'] = $title;
$result_array['database'] = $db_name;
$result_array['faculty'] = $category_code;
//$result_array['directory'] = $result_array['directory'];
/*
still to do: (info taken from local.inc.php)
$_course['id' ] = $cData['cours_id' ]; //auto-assigned integer
$_course['name' ] = $cData['title' ];
$_course['official_code'] = $cData['visual_code' ]; // use in echo
$_course['sysCode' ] = $cData['code' ]; // use as key in db
$_course['path' ] = $cData['directory' ]; // use as key in path
$_course['dbName' ] = $cData['db_name' ]; // use as key in db list
$_course['dbNameGlu' ] = $_configuration['table_prefix'] . $cData['dbName'] . $_configuration['db_glue']; // use in all queries
$_course['titular' ] = $cData['tutor_name' ];
$_course['language' ] = $cData['course_language' ];
$_course['extLink' ]['url' ] = $cData['department_url' ];
$_course['extLink' ]['name'] = $cData['department_name'];
$_course['categoryCode'] = $cData['faCode' ];
$_course['categoryName'] = $cData['faName' ];
$_course['visibility' ] = (bool) ($cData['visibility'] == 2 || $cData['visibility'] == 3);
$_course['registrationAllowed'] = (bool) ($cData['visibility'] == 1 || $cData['visibility'] == 2);
*/
return $result_array;
}
/** /**
* This method creates an abstraction layer between database field names * This method creates an abstraction layer between database field names
* and field names expected in code. * and field names expected in code.

@ -746,7 +746,7 @@ if (isset($uidReset) && $uidReset) {
$user_table = Database::get_main_table(TABLE_MAIN_USER); $user_table = Database::get_main_table(TABLE_MAIN_USER);
$admin_table = Database::get_main_table(TABLE_MAIN_ADMIN); $admin_table = Database::get_main_table(TABLE_MAIN_ADMIN);
$track_e_login = Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); $track_e_login = Database::get_main_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$sql = "SELECT user.*, a.user_id is_admin, login.login_date $sql = "SELECT user.*, a.user_id is_admin, login.login_date
FROM $user_table FROM $user_table
@ -933,7 +933,7 @@ if (isset($cidReset) && $cidReset) {
} }
if ($save_course_access) { if ($save_course_access) {
$course_tracking_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS); $course_tracking_table = Database :: get_main_table(TABLE_STATISTIC_TRACK_E_COURSE_ACCESS);
/* /*
* When $_configuration['session_lifetime'] is too big 100 hours (in order to let users take exercises with no problems) * When $_configuration['session_lifetime'] is too big 100 hours (in order to let users take exercises with no problems)

Loading…
Cancel
Save