Browse Source

Adding new behaviour in user_portal: if the Platform Setting : \"Go directly to the course after login\" is ON and \"Hide courses in session\" is TRUE AND the user is registered ONLY in ONE session then the user will be redirected to the new session view see BT#2067 (temporal change, waiting from approval)

Julio Montoya 14 years ago
parent
commit
bc618f7420
1 changed files with 13 additions and 2 deletions
  1. 13 2
      user_portal.php

+ 13 - 2
user_portal.php

@@ -97,14 +97,25 @@ $personal_course_list = UserManager::get_personal_session_course_list($_user['us
 // Check if a user is enrolled only in one course for going directly to the course after the login.
 if (api_get_setting('go_to_course_after_login') == 'true') {
     if (!isset($_SESSION['coursesAlreadyVisited']) && is_array($personal_course_list) && count($personal_course_list) == 1) {
-
         $key = array_keys($personal_course_list);
         $course_info = $personal_course_list[$key[0]];
-
         $course_directory = $course_info['d'];
         $id_session = isset($course_info['id_session']) ? $course_info['id_session'] : 0;
         header('location:'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$id_session);
         exit;
+    } else {
+        if (api_get_setting('hide_courses_in_sessions') == 'true') {
+            //Check sessions
+            $session_list = array();
+            $only_session_id = 0;
+            foreach($personal_course_list as $course_item) {
+                $session_list[$course_item['id_session']] = $course_item;
+                $only_session_id = $course_item['id_session'];
+            }        
+            if (count($session_list) == 1 && !empty($only_session_id)) {            
+                header('Location:'.api_get_path(WEB_CODE_PATH).'session/?session_id='.$session_list[$only_session_id]['id_session']);    
+            }
+        }
     }
 }