* @author Patrick Cool <patrick.cool@UGent.be>, expanded to get info for any user
* @author Roan Embrechts, first version + converted to Database API
* @version 30 September 2004
* @deprecated use api_get_user_info();
* @desc find all the information about a specified user. Without parameter this is the current user.
* @todo shouldn't this be in the user.lib.php script?
*/
public static function get_user_info_from_id($user_id = '')
{
if (empty($user_id)) {
return $GLOBALS['_user'];
}
$table = self::get_main_table(TABLE_MAIN_USER);
$user_id = self::escape_string($user_id);
return self::generate_abstract_user_field_names(
self::fetch_array(self::query("SELECT * FROM $table WHERE user_id = '$user_id'")));
}
/**
* Returns course code from a given gradebook category's id
* @param int Category ID
* @return string Course code
* @todo move this function in a gradebook-related library
*/
public static function get_course_by_category($category_id)
{
$category_id = intval($category_id);
$info = self::fetch_array(self::query('SELECT course_code FROM '.self::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY).' WHERE id='.$category_id), 'ASSOC');
return $info ? $info['course_code'] : false;
}
/**
* This method creates an abstraction layer between database field names
* and field names expected in code.
*
* This helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
*
* @todo add more array entries to abstract user info from field names
* @author Roan Embrechts
* @author Patrick Cool
*
* @todo what's the use of this function. I think this is better removed.
* There should be consistency in the variable names and the use throughout the scripts
*/
public static function generate_abstract_user_field_names($result_array) {
* @param string $table The table of which the rows should be counted
@ -378,13 +286,6 @@ class Database
*/
public static function escape_string($string, $connection = null, $addFix = true)
{
// Fixes security problem when there's no "" or '' between a variable.
// See #7440 for more info
/*
if ($addFix) {
//$string = "__@$string@__";
}
*/
return get_magic_quotes_gpc()
? (self::use_default_connection($connection)
? mysql_real_escape_string(stripslashes($string))
@ -473,41 +374,6 @@ class Database
return $result;
}
/**
* Returns a list of the fields that a given table contains. The list may contain all of the available field names or filtered field names by using a pattern.
* By using a special option, this method is able to return an indexed list of fields' properties, where field names are keys.
* @param string $table This is the examined table.
* @param string $pattern (optional) A pattern for filtering field names as if it was needed for the SQL's LIKE clause, for example 'column_%'.
* @param string $database (optional) The name of the targeted database. If it is omited, the current database is assumed, see Database::select_db().
* @param bool $including_properties (optional) When this option is true, the returned result has the followong format:
* @author Patrick Cool <patrick.cool@UGent.be>, expanded to get info for any user
* @author Roan Embrechts, first version + converted to Database API
* @version 30 September 2004
* @desc find all the information about a specified user. Without parameter this is the current user.
* @todo shouldn't this be in the user.lib.php script?
*/
public static function get_user_info_from_id($user_id = '')
{
if (empty($user_id)) {
return $GLOBALS['_user'];
}
$table = self::get_main_table(TABLE_MAIN_USER);
$user_id = self::escape_string($user_id);
return self::generate_abstract_user_field_names(
self::fetch_array(self::query("SELECT * FROM $table WHERE user_id = '$user_id'")));
}
/**
* Returns course code from a given gradebook category's id
* @param int Category ID
* @return string Course code
* @todo move this function in a gradebook-related library
*/
public static function get_course_by_category($category_id)
{
$category_id = intval($category_id);
$info = self::fetch_array(self::query('SELECT course_code FROM '.self::get_main_table(TABLE_MAIN_GRADEBOOK_CATEGORY).' WHERE id='.$category_id), 'ASSOC');
return $info ? $info['course_code'] : false;
}
/**
* This method creates an abstraction layer between database field names
* and field names expected in code.
*
* This helps when changing database names.
* It's also useful now to get rid of the 'franglais'.
*
* @todo add more array entries to abstract user info from field names
* @author Roan Embrechts
* @author Patrick Cool
*
* @todo what's the use of this function. I think this is better removed.
* There should be consistency in the variable names and the use throughout the scripts
*/
public static function generate_abstract_user_field_names($result_array)
* @param string $table The table of which the rows should be counted
@ -443,42 +353,6 @@ class MySQLIDatabase {
return $result;
}
/**
* Returns a list of the fields that a given table contains. The list may contain all of the available field names or filtered field names by using a pattern.
* By using a special option, this method is able to return an indexed list of fields' properties, where field names are keys.
* @param string $table This is the examined table.
* @param string $pattern (optional) A pattern for filtering field names as if it was needed for the SQL LIKE clause, for example 'column_%'.
* @param string $database (optional) The name of the targeted database. If it is omitted, the current database is assumed, see Database::select_db().
* @param bool $including_properties (optional) When this option is true, the returned result has the following format: