Browse Source

Load the user language instead of the platform language see #2554

When entering in the termns and condition page
Julio Montoya 6 years ago
parent
commit
7f822a138c
2 changed files with 9 additions and 19 deletions
  1. 0 19
      main/auth/inscription.php
  2. 9 0
      main/inc/global.inc.php

+ 0 - 19
main/auth/inscription.php

@@ -439,16 +439,6 @@ if (!CustomPages::enabled()) {
         if (isset($get)) {
             if (isset($get[0]) && $get[0] == 'legal') {
                 $language = api_get_interface_language();
-
-                $termAndCondition = Session::read('term_and_condition');
-                if (!empty($termAndCondition) && isset($termAndCondition['user_id'])) {
-                    $user_id = $termAndCondition['user_id'];
-                    $userInfo = api_get_user_info($user_id);
-                    if (!empty($userInfo['language'])) {
-                        $language = $userInfo['language'];
-                    }
-                }
-
                 $language = api_get_language_id($language);
                 $term_preview = LegalManager::get_last_condition($language);
                 if (!$term_preview) {
@@ -533,15 +523,6 @@ if (api_get_setting('allow_terms_conditions') === 'true' && $user_already_regist
 
     // Get user language ignoring the platform language
     $language = api_get_interface_language();
-    $termAndCondition = Session::read('term_and_condition');
-    if (!empty($termAndCondition) && isset($termAndCondition['user_id'])) {
-        $user_id = $termAndCondition['user_id'];
-        $userInfo = api_get_user_info($user_id);
-        if (!empty($userInfo['language'])) {
-            $language = $userInfo['language'];
-        }
-    }
-
     $language = api_get_language_id($language);
     $term_preview = LegalManager::get_last_condition($language);
 

+ 9 - 0
main/inc/global.inc.php

@@ -478,6 +478,15 @@ if (!empty($valid_languages)) {
         $language_interface = $user_language;
     }
 
+    // Load the user language, if user is entering in the terms and condition page
+    if (isset($_SESSION['term_and_condition']) && isset($_SESSION['term_and_condition']['user_id'])) {
+        $userTempId = $_SESSION['term_and_condition']['user_id'];
+        $userTempInfo = api_get_user_info($userTempId);
+        if (!empty($userTempInfo['language'])) {
+            $language_interface = $userTempInfo['language'];
+        }
+    }
+
     $allow = api_get_configuration_value('show_language_selector_in_menu');
     // Overwrite all lang configs and use the menu language
     if ($allow) {