Fix the Issues with languages priorities

1.10.x
José Loguercio 9 years ago
parent 5ac54cf549
commit 1bbbea10ee
  1. 18
      main/inc/lib/api.lib.php

@ -4297,8 +4297,6 @@ function api_get_language_id($language)
**/ **/
function api_get_language_from_type($lang_type) function api_get_language_from_type($lang_type)
{ {
$_user = api_get_user_info();
$_course = api_get_course_info();
$return = false; $return = false;
switch ($lang_type) { switch ($lang_type) {
@ -4308,6 +4306,7 @@ function api_get_language_from_type($lang_type)
$return = $temp_lang; $return = $temp_lang;
break; break;
case 'user_profil_lang': case 'user_profil_lang':
$_user = api_get_user_info();
if (isset($_user['language']) && !empty($_user['language'])) if (isset($_user['language']) && !empty($_user['language']))
$return = $_user['language']; $return = $_user['language'];
break; break;
@ -4316,6 +4315,21 @@ function api_get_language_from_type($lang_type)
$return = $_SESSION['user_language_choice']; $return = $_SESSION['user_language_choice'];
break; break;
case 'course_lang': case 'course_lang':
global $_course;
$cidReq = null;
if (empty($_course)) {
// Code modified because the local.inc.php file it's declarated after this work
// causing the function api_get_course_info() returns a null value
$cidReq = isset($_GET["cidReq"]) ? Database::escape_string($_GET["cidReq"]) : null;
$cDir = (!empty($_GET['cDir']) ? $_GET['cDir'] : null);
if (empty($cidReq) && !empty($cDir)) {
$c = CourseManager::get_course_id_from_path($cDir);
if ($c) {
$cidReq = $c;
}
}
}
$_course = api_get_course_info($cidReq);
if (isset($_course['language']) && !empty($_course['language'])) if (isset($_course['language']) && !empty($_course['language']))
$return = $_course['language']; $return = $_course['language'];
break; break;

Loading…
Cancel
Save