Feature #306 - Platform administration tool: Cleaning code for course import. Revision again the logic for username validation and language id validation. A modification in the function api_validate_language(). Other minor fixes.
$sql = "SELECT user_id, ".(api_is_western_name_order(null, $course_language) ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." AS name FROM $user_table WHERE username = '".Database::escape_string($course['Teacher'])."'";
$res = api_sql_query($sql,__FILE__,__LINE__);
$teacher = mysql_fetch_object($res);
$visual_code = $keys["currentCourseCode"];
$code = $keys["currentCourseId"];
$db_name = $keys["currentCourseDbName"];
$directory = $keys["currentCourseRepository"];
$sql = "SELECT user_id, ".(api_is_western_name_order(null, $course_language) ? "CONCAT(firstname,' ',lastname)" : "CONCAT(lastname,' ',firstname)")." AS name FROM $user_table WHERE username = '".Database::escape_string(UserManager::purify_username($course['Teacher'], $purification_option_for_usernames))."'";
@ -2792,7 +2792,7 @@ function api_is_valid_ascii(&$string) {
*/
/**
* Checks whether a given language identificator represents supported by the system language.
* Checks whether a given language identificator represents supported by this library language.
* @param string $language The language identificator to be checked ('english', 'french', 'spanish', ...).
* @return bool $language TRUE if the language is supported, FALSE otherwise.
*/
@ -2805,19 +2805,22 @@ function api_is_language_supported($language) {
}
/**
* Validates the input language identificator in order always to return a language that is supported by the system.
* Validates the input language identificator in order always to return a language that is enabled in the system.
* This function is to be used for data import when provided language identificators should be validated.
* @param string $language The language identificator to be validated.
* @param bool $purify A modifier to the returned result. If it is TRUE, then the returned language identificator is purified.
* @return string Returns the input language identificator, purified, if it was demanded. If the input language is not supported, the current interface language is returned then.
* @return string Returns the input language identificator. If the input language is not enabled, platform language is returned then.
*/
function api_validate_language($language, $purify = false) {