diff --git a/main/inc/lib/page.lib.php b/main/inc/lib/page.lib.php index f3e0211ee2..62c7cba01f 100644 --- a/main/inc/lib/page.lib.php +++ b/main/inc/lib/page.lib.php @@ -13,67 +13,67 @@ class PageController { $user_id = api_get_user_id(); } - //Always show the user image - $img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true); - $no_image = false; - if ($img_array['file'] == 'unknown.jpg') { - $no_image = true; - } - $img_array = UserManager::get_picture_user($user_id, $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" '); + //Always show the user image + $img_array = UserManager::get_user_picture_path_by_id($user_id, 'web', true, true); + $no_image = false; + if ($img_array['file'] == 'unknown.jpg') { + $no_image = true; + } + $img_array = UserManager::get_picture_user($user_id, $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" '); $profile_content = null; if (api_get_setting('allow_social_tool') == 'true') { if (!$no_image) { - $profile_content .=''; - } else { - $profile_content .=''; - } - } + $profile_content .=''; + } else { + $profile_content .=''; + } + } $html = self::show_right_block(null, $profile_content, 'user_image_block', array('style' => 'text-align:center;')); return $html; } - static function return_course_block() { - $html = ''; + static function return_course_block() { + $html = ''; - $show_create_link = false; - $show_course_link = false; + $show_create_link = false; + $show_course_link = false; if ((api_get_setting('allow_users_to_create_courses') == 'false' && !api_is_platform_admin()) || api_is_student()) { $display_add_course_link = false; } else { $display_add_course_link = true; } - //$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview'); + //$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview'); - if ($display_add_course_link) { - $show_create_link = true; - } + if ($display_add_course_link) { + $show_create_link = true; + } - if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { - $show_course_link = true; - } else { - if (api_get_setting('allow_students_to_browse_courses') == 'true') { - $show_course_link = true; - } - } + if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { + $show_course_link = true; + } else { + if (api_get_setting('allow_students_to_browse_courses') == 'true') { + $show_course_link = true; + } + } - // My account section - $my_account_content = ''; - if (!empty($my_account_content)) { - $html = self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block'); - } - return $html; - } + if (!empty($my_account_content)) { + $html = self::show_right_block(get_lang('Courses'), $my_account_content, 'course_block'); + } + return $html; + } static function return_profile_block() { - $user_id = api_get_user_id(); + $user_id = api_get_user_id(); - if (empty($user_id)) { - return; - } + if (empty($user_id)) { + return; + } - $profile_content = '"; + } + $result .= $htmlTitre; + if ($thereIsSubCat) { + $result .= $htmlListCat; + } + while ($categoryName = Database::fetch_array($resCats)) { + $result .= '

' . $categoryName['name'] . "

\n"; + } + $numrows = Database::num_rows($sql_result_courses); + $courses_list_string = ''; + $courses_shown = 0; + if ($numrows > 0) { + + $courses_list_string .= Display::page_header(get_lang('CourseList')); $courses_list_string .= ""; + } //end else + } // end foreach + $courses_list_string .= ""; } if ($courses_shown > 0) { // Only display the list of courses and categories if there was more than // 0 courses visible to the world (we're in the anonymous list here). $result .= $courses_list_string; } - if ($category != '') { - $result .= '

' . Display :: return_icon('back.png', get_lang('BackToHomePage')) . get_lang('BackToHomePage') . '

'; - } + if ($category != '') { + $result .= '

' . Display :: return_icon('back.png', get_lang('BackToHomePage')) . get_lang('BackToHomePage') . '

'; + } return $result; - } + } - /** - * The most important function here, prints the session and course list (user_portal.php) - * - * */ - static function return_courses_and_sessions($user_id) { + /** + * The most important function here, prints the session and course list (user_portal.php) + * + * */ + static function return_courses_and_sessions($user_id) { $session_categories = array(); $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false; - if ($load_history) { + if ($load_history) { //Load sessions in category in *history* - $session_categories = UserManager::get_sessions_by_category($user_id, true); - } else { + $session_categories = UserManager::get_sessions_by_category($user_id, true); + } else { //Load sessions in category - $session_categories = UserManager::get_sessions_by_category($user_id, false); - } + $session_categories = UserManager::get_sessions_by_category($user_id, false); + } $html = ''; //Showing history title - if ($load_history) { - $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); - if (empty($session_categories)) { - $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); - } - } + if ($load_history) { + $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); + if (empty($session_categories)) { + $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); + } + } $courses_html = ''; $special_courses = ''; @@ -730,7 +730,7 @@ class PageController { $load_directories_preview = api_get_setting('show_documents_preview') == 'true' ? true : false; - if (is_array($session_categories)) { + if (is_array($session_categories)) { foreach ($session_categories as $session_category) { $session_category_id = $session_category['session_category']['id']; // Sessions and courses that are not in a session category @@ -787,15 +787,15 @@ class PageController { } if (api_get_setting('hide_courses_in_sessions') == 'false') { - // $params['extra'] .= $html_courses_session; + // $params['extra'] .= $html_courses_session; } $sessions_with_no_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_courses_session); } } } - } else { - // All sessions included in + } else { + // All sessions included in $count_courses_session = 0; $html_sessions = ''; foreach ($session_category['sessions'] as $session) { @@ -874,11 +874,11 @@ class PageController { } $sessions_with_category .= CourseManager::course_item_parent(CourseManager::course_item_html($params, true), $html_sessions); } - } - } - } + } + } + } return $sessions_with_category.$sessions_with_no_category.$courses_html.$special_courses; - } + } /** * Shows a welcome message when the user doesn't have any content in the course list