Feature #306 - UserManager: Some minor optimizations ( this was the initial intention :-) ). A tricky rework about the method UserManager::get_user_picture_path_by_id(). A collateral fix about uploading user photos in the platform admin tool, now it works correctly, including the case api_get_setting('split_users_upload_directory') === 'true'. Uploading photos through user profile tool is to be checked. And... fixing two unsafe getimagesize() calls. By the way, the date picker in the forms "User add" and "User edit" (platform admin) does not work, IE8.
$sql = "SELECT * FROM $user_table WHERE username='".$username."'";
$res = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($res) > 0) {
$user = Database::fetch_array($res);
} else {
$user = false;
return Database::fetch_array($res);
}
return $user;
return false;
}
/**
@ -547,10 +546,9 @@ class UserManager {
}
}
}
} else {
$user = false;
return $user;
}
return $user;
return false;
}
/** Get the teacher list
@ -582,116 +580,59 @@ class UserManager {
* @param string Type of path to return (can be 'none', 'system', 'rel', 'web')
* @param bool Whether we want to have the directory name returned 'as if' there was a file or not (in the case we want to know which directory to create - otherwise no file means no split subdir)
* @param bool If we want that the function returns the /main/img/unknown.jpg image set it at true
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty array
* @return array Array of 2 elements: 'dir' and 'file' which contain the dir and file as the name implies if image does not exist it will return the unknow image if anonymous parameter is true if not it returns an empty er's
*/
public static function get_user_picture_path_by_id($id, $type = 'none', $preview = false, $anonymous = false) {
if (empty($id) or empty($type)) {
if ($anonymous) {
$dir = '';
switch ($type) {
case 'system': //return the complete path to the file, from root
$dir = api_get_path(SYS_CODE_PATH).'img/';
break;
case 'rel': //return the relative path to the file, from the Dokeos base dir
$dir = api_get_path(REL_CODE_PATH).'img/';
break;
case 'web': //return the complete web URL to the file
$dir = api_get_path(WEB_CODE_PATH).'img/';
break;
case 'none': //return only the picture_uri (as is, without subdir)