diff --git a/index.php b/index.php index ad581ebeed..47f7895cd2 100644 --- a/index.php +++ b/index.php @@ -86,15 +86,15 @@ class IndexController //If we are not logged in and customapages activated if (!api_get_user_id() && CustomPages::enabled()) { - $loggedout = $request->get('loggedout'); - if ($loggedout) { + $logged_out = $request->get('loggedout'); + if ($logged_out) { CustomPages::display(CustomPages::LOGGED_OUT); } else { CustomPages::display(CustomPages::INDEX_UNLOGGED); } } - $this->check_last_login(); + //$this->check_last_login(); if (api_get_setting('display_categories_on_homepage') == 'true') { $app['template']->assign('course_category_block', PageController::return_courses_in_categories()); @@ -135,6 +135,7 @@ class IndexController $app['template']->assign('home_page_block', PageController::return_home_page()); $nav_links = $app['template']->return_navigation_links(); + $app['template']->assign('navigation_course_links', $nav_links); $app['template']->assign('main_navigation_block', $nav_links); @@ -144,20 +145,22 @@ class IndexController if (api_is_platform_admin() || api_is_drh()) { PageController::return_skills_links(); } + $response = $app['template']->render_layout('layout_2_col.tpl'); //return new Response($response, 200, array('Cache-Control' => 's-maxage=3600, public')); return new Response($response, 200, array()); } + /** + * + * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled. + * @todo Check if this code is used. I think this code is never executed because after clicking the submit button + * the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending + * on api_get_setting('page_after_login'). + * @deprecated + */ function check_last_login() { -// -// * @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled. -// * @todo Check if this code is used. I think this code is never executed because after clicking the submit button -// * the code does the stuff in local.inc.php and then redirects to index.php or user_portal.php depending -// * on api_get_setting('page_after_login'). -// - if (!empty($_POST['submitAuth'])) { // The user has been already authenticated, we are now to find the last login of the user. if (!empty($this->user_id)) { diff --git a/main/auth/shibboleth/app/controller/shibboleth_controller.class.php b/main/auth/shibboleth/app/controller/shibboleth_controller.class.php index c1568f1cd4..2afe8e658d 100644 --- a/main/auth/shibboleth/app/controller/shibboleth_controller.class.php +++ b/main/auth/shibboleth/app/controller/shibboleth_controller.class.php @@ -91,7 +91,6 @@ class ShibbolethController $message = get_lang('already_logged_in'); Shibboleth::display()->message_page($message, $title); } - //$index_manager = new IndexManager(''); $html = PageController::display_login_form(); Shibboleth::display()->page($html, $title); } diff --git a/main/inc/lib/autoload.class.php b/main/inc/lib/autoload.class.php index aa45e8d40b..3d4dbecd45 100644 --- a/main/inc/lib/autoload.class.php +++ b/main/inc/lib/autoload.class.php @@ -2,7 +2,7 @@ /** * Autoload Chamilo classes - * + * * @license see /license.txt * @author Laurent Opprecht for the Univesity of Geneva */ @@ -12,7 +12,7 @@ class Autoload static private $is_registered = false; /** - * Register the Chamilo autoloader on the stack. + * Register the Chamilo autoloader on the stack. * Will only do it once so this method is repeatable. */ static public function register() @@ -43,14 +43,14 @@ class Autoload $root = dirname(__FILE__) . '/../../'; /** * WARNING - * + * * This map is autogeneated by AutoloadClassFinder. It may be ovewrite * by future run. - * - * If you need to manually add mappings do it at the end and clearly - * identifies that as manually added or better ensure your class is - * captured by the finder. - * + * + * If you need to manually add mappings do it at the end and clearly + * identifies that as manually added or better ensure your class is + * captured by the finder. + * * If it comes from a different package you may want to add another autoload * function on the stack. */ @@ -73,7 +73,7 @@ class Autoload $result['Agenda'] = '/main/calendar/agenda.lib.php'; $result['AjaxController'] = '/main/inc/lib/ajax_controller.class.php'; $result['Announcement'] = '/main/coursecopy/classes/Announcement.class.php'; - $result['AnnouncementManager'] = '/main/announcements/announcements.inc.php'; + $result['AnnouncementManager'] = '/main/announcements/announcements.inc.php'; $result['AnnouncementEmail'] = '/main/announcements/announcement_email.class.php'; $result['Answer'] = '/main/exercice/answer.class.php'; $result['AppPlugin'] = '/main/inc/lib/plugin.lib.php'; @@ -493,7 +493,7 @@ class Autoload $result['Entity\SearchEngineRef'] = '/main/inc/entity/search_engine_ref.class.php'; $result['Entity\Session'] = '/main/inc/entity/session.class.php'; $result['Entity\SessionCategory'] = '/main/inc/entity/session_category.class.php'; - $result['Entity\SessionField'] = '/main/inc/entity/session_field.class.php'; + $result['Entity\SessionField'] = '/main/inc/entity/session_field.class.php'; $result['Entity\SessionFieldValues'] = '/main/inc/entity/session_field_values.class.php'; $result['Entity\SessionRelCourse'] = '/main/inc/entity/session_rel_course.class.php'; $result['Entity\SessionRelCourseRelUser'] = '/main/inc/entity/session_rel_course_rel_user.class.php'; @@ -585,12 +585,12 @@ class Autoload $result['EventsMail'] = '/main/inc/lib/events_email.class.php'; $result['Exercise'] = '/main/exercice/exercise.class.php'; $result['ExerciseLink'] = '/main/gradebook/lib/be/exerciselink.class.php'; - + $result['ExtraField'] = '/main/inc/lib/extra_field.lib.php'; $result['ExtraFieldOption'] = '/main/inc/lib/extra_field_option.lib.php'; $result['ExtraFieldValue'] = '/main/inc/lib/extra_field_value.lib.php'; - - $result['Testcategory'] = '/main/exercice/testcategory.class.php'; + + $result['Testcategory'] = '/main/exercice/testcategory.class.php'; $result['ExerciseResult'] = '/main/exercice/exercise_result.class.php'; $result['ExerciseShowFunctions'] = '/main/inc/lib/exercise_show_functions.lib.php'; $result['FileManager'] = '/main/inc/lib/fileManage.lib.php'; @@ -701,7 +701,6 @@ class Autoload $result['ImageWrapper'] = '/main/inc/lib/image.lib.php'; $result['ImagickWrapper'] = '/main/inc/lib/image.lib.php'; $result['Import'] = '/main/inc/lib/import.lib.php'; - $result['IndexManager'] = '/main/inc/lib/userportal.lib.php'; $result['IndexableChunk'] = '/main/inc/lib/search/IndexableChunk.class.php'; $result['Install'] = '/main/install/install.class.php'; $result['Javascript'] = '/main/inc/lib/javascript.class.php'; @@ -726,7 +725,7 @@ class Autoload $result['Log'] = '/main/inc/lib/log.class.php'; $result['Login'] = '/main/inc/lib/login.lib.php'; $result['LoginRedirection'] = '/main/inc/lib/login_redirection.class.php'; - $result['Matching'] = '/main/exercice/matching.class.php'; + $result['Matching'] = '/main/exercice/matching.class.php'; $result['MessageManager'] = '/main/inc/lib/message.lib.php'; $result['MediaQuestion'] = '/main/exercice/media_question.class.php'; $result['Model'] = '/main/inc/lib/model.lib.php'; @@ -812,10 +811,10 @@ class Autoload $result['SessionHandler'] = '/main/inc/lib/session_handler.class.php'; $result['SessionManager'] = '/main/inc/lib/sessionmanager.lib.php'; $result['SessionModel'] = '/main/inc/lib/session_model.lib.php'; - + $result['SessionField'] = '/main/inc/lib/session_field.lib.php'; $result['SessionFieldValue'] = '/main/inc/lib/session_field_value.lib.php'; - $result['SessionFieldOption'] = '/main/inc/lib/session_field_option.lib.php'; + $result['SessionFieldOption'] = '/main/inc/lib/session_field_option.lib.php'; $result['Shibboleth\Admin'] = '/main/auth/shibboleth/app/model/admin.class.php'; $result['Shibboleth\AdminStore'] = '/main/auth/shibboleth/app/model/admin.class.php'; $result['Shibboleth\Model'] = '/main/auth/shibboleth/lib/model.class.php'; @@ -981,7 +980,7 @@ class Autoload $result['vtimezone'] = '/main/inc/lib/icalcreator/iCalcreator.class.php'; $result['vtodo'] = '/main/inc/lib/icalcreator/iCalcreator.class.php'; $result['xhtdoc'] = '/main/inc/lib/xht.lib.php'; - + $result['xajax'] = '/main/inc/lib/xajax/xajax.inc.php'; $result['xajaxResponse'] = '/main/inc/lib/xajax/xajaxResponse.inc.php'; return $result; @@ -1011,10 +1010,10 @@ class Autoload } /** - * Scan directorie for class declarations and returns an array made of - * + * Scan directorie for class declarations and returns an array made of + * * classname => relative path - * + * * @license see /license.txt * @author Laurent Opprecht for the Univesity of Geneva */ @@ -1104,12 +1103,12 @@ class AutoloadClassFinder /** * Synchronize the autoloader map with the current file structure. - * + * * Searches all files and sub directories for class declarations. * Creates a map of class name to (relative) file path. * Update the autoloader with the map declaration if $update equals true. * Returns a map of class name to file path. - * + * * @param string $current_dir The current directory in which we search for class declarations */ protected function synch($current_dir = null) @@ -1121,7 +1120,7 @@ class AutoloadClassFinder $current_dir = $current_dir ? $current_dir : $root_dir; $current_dir = realpath($current_dir); - //plugins are not handled by the autoloader. + //plugins are not handled by the autoloader. if (basename($current_dir) == 'plugin') { return $result; } @@ -1140,7 +1139,7 @@ class AutoloadClassFinder foreach ($classes as $class) { /* a few classes have the same namespace and class name - * in this case we let the latest win as this may + * in this case we let the latest win as this may * relates to different autoloader. */ $rel_path = realpath($path); diff --git a/main/inc/lib/banner.lib.php b/main/inc/lib/banner.lib.php index b16522154f..e69de29bb2 100644 --- a/main/inc/lib/banner.lib.php +++ b/main/inc/lib/banner.lib.php @@ -1,613 +0,0 @@ -, Ghent University - */ -function get_tabs() { - global $_course; - - $navigation = array(); - - // Campus Homepage - $navigation[SECTION_CAMPUS]['url'] = api_get_path(WEB_PATH).'index.php'; - $navigation[SECTION_CAMPUS]['title'] = get_lang('CampusHomepage'); - - // My Courses - - if(api_is_allowed_to_create_course()) { - // Link to my courses for teachers - $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php?nosession=true'; - $navigation['mycourses']['title'] = get_lang('MyCourses'); - } else { - // Link to my courses for students - $navigation['mycourses']['url'] = api_get_path(WEB_PATH).'user_portal.php'; - $navigation['mycourses']['title'] = get_lang('MyCourses'); - } - - // My Profile - $navigation['myprofile']['url'] = api_get_path(WEB_CODE_PATH).'auth/profile.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); - $navigation['myprofile']['title'] = get_lang('ModifyProfile'); - - // Link to my agenda - $navigation['myagenda']['url'] = api_get_path(WEB_CODE_PATH).'calendar/agenda_js.php?type=personal'; - $navigation['myagenda']['title'] = get_lang('MyAgenda'); - - // Gradebook - if (api_get_setting('gradebook_enable') == 'true') { - $navigation['mygradebook']['url'] = api_get_path(WEB_CODE_PATH).'gradebook/gradebook.php'.(!empty($_course['path']) ? '?coursePath='.$_course['path'].'&courseCode='.$_course['official_code'] : '' ); - $navigation['mygradebook']['title'] = get_lang('MyGradebook'); - } - - // Reporting - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { - // Link to my space - $navigation['session_my_space']['url'] = api_get_path(WEB_CODE_PATH).'mySpace/'; - $navigation['session_my_space']['title'] = get_lang('MySpace'); - } else { - // Link to my progress - $navigation['session_my_progress']['url'] = api_get_path(WEB_CODE_PATH).'auth/my_progress.php'; - $navigation['session_my_progress']['title'] = get_lang('MyProgress'); - } - - - // Social - /* - if (api_get_setting('allow_social_tool')=='true') { - $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php'; - - // get count unread message and total invitations - $count_unread_message = MessageManager::get_number_of_messages(true); - - $number_of_new_messages_of_friend = SocialManager::get_message_number_invitation_by_user_id(api_get_user_id()); - $group_pending_invitations = GroupPortalManager::get_groups_by_user(api_get_user_id(), GROUP_USER_PERMISSION_PENDING_INVITATION,false); - $group_pending_invitations = 0; - if (!empty($group_pending_invitations )) { - $group_pending_invitations = count($group_pending_invitations); - } - $total_invitations = intval($number_of_new_messages_of_friend) + $group_pending_invitations + intval($count_unread_message); - $total_invitations = (!empty($total_invitations) ? Display::badge($total_invitations) :''); - - $navigation['social']['title'] = get_lang('SocialNetwork'). $total_invitations; - } - */ - - // Social - if (api_get_setting('allow_social_tool')=='true') { - $navigation['social']['url'] = api_get_path(WEB_CODE_PATH).'social/home.php'; - $navigation['social']['title'] = get_lang('SocialNetwork'); - } - - // Dashboard - if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { - $navigation['dashboard']['url'] = api_get_path(WEB_CODE_PATH).'dashboard/index.php'; - $navigation['dashboard']['title'] = get_lang('Dashboard'); - } - - // Reports - /* - if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { - $navigation['reports']['url'] = api_get_path(WEB_CODE_PATH).'reports/index.php'; - $navigation['reports']['title'] = get_lang('Reports'); - }*/ - - // Custom tabs - for ($i = 1; $i<=3; $i++) - if (api_get_setting('custom_tab_'.$i.'_name') && api_get_setting('custom_tab_'.$i.'_url')) { - $navigation['custom_tab_'.$i]['url'] = api_get_setting('custom_tab_'.$i.'_url'); - $navigation['custom_tab_'.$i]['title'] = api_get_setting('custom_tab_'.$i.'_name'); - } - - // Platform administration - if (api_is_platform_admin(true)) { - $navigation['platform_admin']['url'] = api_get_path(WEB_CODE_PATH).'admin/'; - $navigation['platform_admin']['title'] = get_lang('PlatformAdmin'); - } - return $navigation; -} - -function return_logo($theme) { - $_course = api_get_course_info(); - $html = ''; - $logo = api_get_path(SYS_CODE_PATH).'css/'.$theme.'/images/header-logo.png'; - - $site_name = api_get_setting('siteName'); - if (file_exists($logo)) { - $site_name = api_get_setting('Institution').' - '.$site_name; - $html .= ''; - } else { - $html .= ''.$site_name.''; - $iurl = api_get_setting('InstitutionUrl'); - $iname = api_get_setting('Institution'); - - if (!empty($iname)) { - $html .= '- '.$iname.''; - } - // External link section a.k.a Department - Department URL - if (isset($_course['extLink']) && $_course['extLink']['name'] != '') { - $html .= ' - '; - if ($_course['extLink']['url'] != '') { - $html .= ''; - $html .= $_course['extLink']['name']; - $html .= ''; - } else { - $html .= $_course['extLink']['name']; - } - } - } - - /* // Course title section - if (!empty($_cid) and $_cid != -1 and isset($_course)) { - //Put the name of the course in the header - $html .= '
'; - $html .= '
'; - } elseif (isset($nameTools) && $language_file != 'course_home') { - //Put the name of the user-tools in the header - if (!isset($user_id)) { - //echo '
'; - } elseif (!$noPHP_SELF) { - $html .= ''; - } else { - $html .= '
'.$nameTools.'
'; - } - }*/ - return $html; -} - -function return_notification_menu() { - - $_course = api_get_course_info(); - $course_id = api_get_course_id(); - $user_id = api_get_user_id(); - - $html = ''; - - if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id) OR (api_get_setting('showonline', 'course') == 'true' AND $user_id AND $course_id)) { - $number = who_is_online_count(api_get_setting('time_limit_whosonline')); - - $number_online_in_course = 0; - if(!empty($_course['id'])) { - $number_online_in_course = who_is_online_in_this_course_count($user_id, api_get_setting('time_limit_whosonline'), $_course['id']); - } - - // Display the who's online of the platform - if ($number) { - if ((api_get_setting('showonline', 'world') == 'true' AND !$user_id) OR (api_get_setting('showonline', 'users') == 'true' AND $user_id)) { - $html .= '
  • '. - Display::return_icon('user.png', get_lang('UsersOnline'), array(), ICON_SIZE_TINY).' '.$number.'
  • '; - } - } - - // Display the who's online for the course - if ($number_online_in_course) { - if (is_array($_course) AND api_get_setting('showonline', 'course') == 'true' AND isset($_course['sysCode'])) { - $html .= '
  • '. - Display::return_icon('course.png', get_lang('UsersOnline').' '.get_lang('InThisCourse'), array(), ICON_SIZE_TINY).' '.$number_online_in_course.'
  • '; - } - } - - // Display the who's online for the session - if (isset($user_id) && api_get_session_id() != 0) { - if (api_is_allowed_to_edit()) { - $html .= '
  • '. - Display::return_icon('session.png', get_lang('UsersConnectedToMySessions'), array(), ICON_SIZE_TINY).'
  • '; - } - } - } - - - if (api_get_setting('accessibility_font_resize') == 'true') { - $html .= '
  • '; - $html .= 'A A A'; - $html .= '
  • '; - } - return $html; -} - -function return_navigation_array() { - - $navigation = array(); - $menu_navigation = array(); - $possible_tabs = get_tabs(); - - // Campus Homepage - if (api_get_setting('show_tabs', 'campus_homepage') == 'true') { - $navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS]; - } else { - $menu_navigation[SECTION_CAMPUS] = $possible_tabs[SECTION_CAMPUS]; - } - - if (api_get_user_id() && !api_is_anonymous()) { - // My Courses - if (api_get_setting('show_tabs', 'my_courses') == 'true') { - $navigation['mycourses'] = $possible_tabs['mycourses']; - } else { - $menu_navigation['mycourses'] = $possible_tabs['mycourses']; - } - - // My Profile - if (api_get_setting('show_tabs', 'my_profile') == 'true' && api_get_setting('allow_social_tool') != 'true') { - $navigation['myprofile'] = $possible_tabs['myprofile']; - } else { - $menu_navigation['myprofile'] = $possible_tabs['myprofile']; - } - - // My Agenda - if (api_get_setting('show_tabs', 'my_agenda') == 'true') { - $navigation['myagenda'] = $possible_tabs['myagenda']; - } else { - $menu_navigation['myagenda'] = $possible_tabs['myagenda']; - } - - // Gradebook - if (api_get_setting('gradebook_enable') == 'true') { - if (api_get_setting('show_tabs', 'my_gradebook') == 'true') { - $navigation['mygradebook'] = $possible_tabs['mygradebook']; - } else{ - $menu_navigation['mygradebook'] = $possible_tabs['mygradebook']; - } - } - - // Reporting - if (api_get_setting('show_tabs', 'reporting') == 'true') { - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { - $navigation['session_my_space'] = $possible_tabs['session_my_space']; - } else { - $navigation['session_my_space'] = $possible_tabs['session_my_progress']; - } - } else { - if (api_is_allowed_to_create_course() || api_is_drh() || api_is_session_admin()) { - $menu_navigation['session_my_space'] = $possible_tabs['session_my_space']; - } else { - $menu_navigation['session_my_space'] = $possible_tabs['session_my_progress']; - } - } - - // Social Networking - if (api_get_setting('show_tabs', 'social') == 'true') { - if (api_get_setting('allow_social_tool') == 'true') { - $navigation['social'] = $possible_tabs['social']; - } - } else{ - $menu_navigation['social'] = $possible_tabs['social']; - } - - // Dashboard - if (api_get_setting('show_tabs', 'dashboard') == 'true') { - if (api_is_platform_admin() || api_is_drh() || api_is_session_admin()) { - $navigation['dashboard'] = $possible_tabs['dashboard']; - } - } else{ - $menu_navigation['dashboard'] = $possible_tabs['dashboard']; - } - - // Administration - if (api_is_platform_admin(true)) { - if (api_get_setting('show_tabs', 'platform_administration') == 'true') { - $navigation['platform_admin'] = $possible_tabs['platform_admin']; - } else { - $menu_navigation['platform_admin'] = $possible_tabs['platform_admin']; - } - } - - // Reports - if (!empty($possible_tabs['reports'])) { - if (api_get_setting('show_tabs', 'reports') == 'true') { - if ((api_is_platform_admin() || api_is_drh() || api_is_session_admin()) && Rights::hasRight('show_tabs:reports')) { - $navigation['reports'] = $possible_tabs['reports']; - } - } else { - $menu_navigation['reports'] = $possible_tabs['reports']; - } - } - - // Custom tabs - for ($i=1;$i<=3;$i++) { - if (api_get_setting('show_tabs', 'custom_tab_'.$i) == 'true' && isset($possible_tabs['custom_tab_'.$i])) { - $navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i]; - } else { - if (isset($possible_tabs['custom_tab_'.$i])) { - $menu_navigation['custom_tab_'.$i] = $possible_tabs['custom_tab_'.$i]; - } - } - } - - } - return array('menu_navigation' => $menu_navigation, 'navigation' => $navigation, 'possible_tabs' => $possible_tabs); -} - -function return_menu() { - $navigation = return_navigation_array(); - $navigation = $navigation['navigation']; - - // Displaying the tabs - - $lang = ''; //el for "Edit Language" - - if (!empty($_SESSION['user_language_choice'])) { - $lang = $_SESSION['user_language_choice']; - } elseif (!empty($_SESSION['_user']['language'])) { - $lang = $_SESSION['_user']['language']; - } else { - $lang = get_setting('platformLanguage'); - } - - //Preparing home folder for multiple urls - - if (api_get_multiple_access_url()) { - $access_url_id = api_get_current_access_url_id(); - if ($access_url_id != -1) { - $url_info = api_get_access_url($access_url_id); - $url = api_remove_trailing_slash(preg_replace('/https?:\/\//i', '', $url_info['url'])); - $clean_url = replace_dangerous_char($url); - $clean_url = str_replace('/', '-', $clean_url); - $clean_url .= '/'; - $homep = api_get_path(SYS_PATH).'home/'.$clean_url; //homep for Home Path - //we create the new dir for the new sites - if (!is_dir($homep)) { - mkdir($homep, api_get_permissions_for_new_directories()); - } - } - } else { - $homep = api_get_path(SYS_PATH).'home/'; - } - - $ext = '.html'; - $menutabs = 'home_tabs'; - $home_top = ''; - - if (is_file($homep.$menutabs.'_'.$lang.$ext) && is_readable($homep.$menutabs.'_'.$lang.$ext)) { - $home_top = @(string)file_get_contents($homep.$menutabs.'_'.$lang.$ext); - } elseif (is_file($homep.$menutabs.$lang.$ext) && is_readable($homep.$menutabs.$lang.$ext)) { - $home_top = @(string)file_get_contents($homep.$menutabs.$lang.$ext); - } else { - //$errorMsg = get_lang('HomePageFilesNotReadable'); - } - - $home_top = api_to_system_encoding($home_top, api_detect_encoding(strip_tags($home_top))); - - $open = str_replace('{rel_path}',api_get_path(REL_PATH), $home_top); - $open = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); - - $lis = ''; - - if (!empty($open)) { - if (strpos($open, 'show_menu') === false) { - if (api_is_anonymous()) { - $navigation[SECTION_CAMPUS] = null; - } - } else { - //$lis .= Display::tag('li', $open); - $lis .= $open; - } - } - - if (count($navigation) > 0 || !empty($lis)) { - $pre_lis = ''; - foreach ($navigation as $section => $navigation_info) { - if (isset($GLOBALS['this_section'])) { - $current = $section == $GLOBALS['this_section'] ? ' id="current" class="active" ' : ''; - } else { - $current = ''; - } - if (!empty($navigation_info['title'])) { - $pre_lis .= ''.$navigation_info['title'].''; - } - } - $lis = $pre_lis.$lis; - } - - $menu = null; - if (!empty($lis)) { - $menu .= $lis; - } - return $menu; -} - -function return_breadcrumb($interbreadcrumb, $language_file, $nameTools) { - $session_id = api_get_session_id(); - $session_name = api_get_session_name($session_id); - $_course = api_get_course_info(); - $user_id = api_get_user_id(); - $course_id = api_get_course_id(); - - - /* Plugins for banner section */ - $web_course_path = api_get_path(WEB_COURSE_PATH); - - /* If the user is a coach he can see the users who are logged in its session */ - $navigation = array(); - - // part 1: Course Homepage. If we are in a course then the first breadcrumb is a link to the course homepage - // hide_course_breadcrumb the parameter has been added to hide the name of the course, that appeared in the default $interbreadcrumb - $session_name = cut($session_name, MAX_LENGTH_BREADCRUMB); - $my_session_name = is_null($session_name) ? '' : ' ('.$session_name.')'; - - if (!empty($_course) && !isset($_GET['hide_course_breadcrumb'])) { - - $navigation_item['url'] = $web_course_path . $_course['path'].'/index.php'.(!empty($session_id) ? '?id_session='.$session_id : ''); - $course_title = cut($_course['name'], MAX_LENGTH_BREADCRUMB); - - switch (api_get_setting('breadcrumbs_course_homepage')) { - case 'get_lang': - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('CourseHomepageLink')).' '.get_lang('CourseHomepageLink'); - break; - case 'course_code': - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['official_code']).' '.$_course['official_code']; - break; - case 'session_name_and_course_title': - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; - break; - default: - if (api_get_session_id() != -1 ) { - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name'].$my_session_name).' '.$course_title.$my_session_name; - } else { - $navigation_item['title'] = Display::img(api_get_path(WEB_CSS_PATH).'home.png', $_course['name']).' '.$course_title; - } - break; - } - /** - * @todo could be useful adding the My courses in the breadcrumb - $navigation_item_my_courses['title'] = get_lang('MyCourses'); - $navigation_item_my_courses['url'] = api_get_path(WEB_PATH).'user_portal.php'; - $navigation[] = $navigation_item_my_courses; - */ - $navigation[] = $navigation_item; - } - - // part 2: Interbreadcrumbs. If there is an array $interbreadcrumb defined then these have to appear before the last breadcrumb (which is the tool itself) - if (isset($interbreadcrumb) && is_array($interbreadcrumb)) { - foreach ($interbreadcrumb as $breadcrumb_step) { - if (isset($breadcrumb_step['type']) && $breadcrumb_step['type'] == 'right') { - continue; - } - if ($breadcrumb_step['url'] != '#') { - $sep = (strrchr($breadcrumb_step['url'], '?') ? '&' : '?'); - $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq(); - } else { - $navigation_item['url'] = '#'; - } - $navigation_item['title'] = $breadcrumb_step['name']; - // titles for shared folders - if ($breadcrumb_step['name'] == 'shared_folder') { - $navigation_item['title'] = get_lang('UserFolders'); - } elseif(strstr($breadcrumb_step['name'], 'shared_folder_session_')) { - $navigation_item['title'] = get_lang('UserFolders'); - } elseif(strstr($breadcrumb_step['name'], 'sf_user_')) { - $userinfo = Database::get_user_info_from_id(substr($breadcrumb_step['name'], 8)); - $navigation_item['title'] = api_get_person_name($userinfo['firstname'], $userinfo['lastname']); - } elseif($breadcrumb_step['name'] == 'chat_files') { - $navigation_item['title'] = get_lang('ChatFiles'); - } elseif($breadcrumb_step['name'] == 'images') { - $navigation_item['title'] = get_lang('Images'); - } elseif($breadcrumb_step['name'] == 'video') { - $navigation_item['title'] = get_lang('Video'); - } elseif($breadcrumb_step['name'] == 'audio') { - $navigation_item['title'] = get_lang('Audio'); - } elseif($breadcrumb_step['name'] == 'flash') { - $navigation_item['title'] = get_lang('Flash'); - } elseif($breadcrumb_step['name'] == 'gallery') { - $navigation_item['title'] = get_lang('Gallery'); - } - //Fixes breadcrumb title now we applied the Security::remove_XSS and we cut the string depending of the MAX_LENGTH_BREADCRUMB value - - $navigation_item['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB); - $navigation_item['title'] = Security::remove_XSS($navigation_item['title']); - $navigation[] = $navigation_item; - } - } - - $navigation_right = array(); - - if (isset($interbreadcrumb) && is_array($interbreadcrumb)) { - foreach ($interbreadcrumb as $breadcrumb_step) { - if (isset($breadcrumb_step['type']) && $breadcrumb_step['type'] == 'right') { - if ($breadcrumb_step['url'] != '#') { - $sep = (strrchr($breadcrumb_step['url'], '?') ? '&' : '?'); - $navigation_item['url'] = $breadcrumb_step['url'].$sep.api_get_cidreq(); - } else { - $navigation_item['url'] = '#'; - } - $breadcrumb_step['title'] = cut($navigation_item['title'], MAX_LENGTH_BREADCRUMB); - $breadcrumb_step['title'] = Security::remove_XSS($navigation_item['title']); - $navigation_right[] = $breadcrumb_step; - } - } - } - - - // part 3: The tool itself. If we are on the course homepage we do not want to display the title of the course because this - // is the same as the first part of the breadcrumbs (see part 1) - if (isset($nameTools) && $language_file != 'course_home') { // TODO: This condition $language_file != 'course_home' might bring surprises. - $navigation_item['url'] = '#'; - $navigation_item['title'] = $nameTools; - $navigation[] = $navigation_item; - } - - $final_navigation = array(); - $counter = 0; - - foreach ($navigation as $index => $navigation_info) { - if (!empty($navigation_info['title'])) { - if ($navigation_info['url'] == '#') { - $final_navigation[$index] = $navigation_info['title']; - } else { - $final_navigation[$index] = ''.$navigation_info['title'].''; - } - $counter++; - } - } - - $html = ''; - - /* Part 4 . Show the teacher view/student view button at the right of the breadcrumb */ - $view_as_student_link = null; - if ($user_id && isset($course_id)) { - if ((api_is_course_admin() || api_is_platform_admin()) && api_get_setting('student_view_enabled') == 'true') { - $view_as_student_link = api_display_tool_view_option(); - } - } - - if (!empty($final_navigation)) { - $lis = ''; - $i = 0; - //$home_link = Display::url(Display::img(api_get_path(WEB_CSS_PATH).'home.png', get_lang('Homepage'), array('align'=>'middle')), api_get_path(WEB_PATH), array('class'=>'home')); - //$lis.= Display::tag('li', Display::url(get_lang('Homepage').'/', api_get_path(WEB_PATH))); - $final_navigation_count = count($final_navigation); - - if (!empty($final_navigation)) { - // $home_link.= '/'; - - if (!empty($home_link)) { - $lis.= Display::tag('li', $home_link); - } - - foreach ($final_navigation as $bread) { - $bread_check = trim(strip_tags($bread)); - if (!empty($bread_check)) { - if ($final_navigation_count-1 > $i) { - $bread .= '/'; - } - $lis.= Display::tag('li', $bread); - $i++; - } - } - } else { - if (!empty($home_link)) { - $lis.= Display::tag('li', $home_link); - } - } - - // View as student/teacher link - if (!empty($view_as_student_link)) { - $lis.= Display::tag('li', $view_as_student_link, array('id' => 'view_as_link','class' => 'pull-right')); - } - - if (!empty($navigation_right)) { - foreach($navigation_right as $item){ - $extra_class = isset($item['class']) ? $item['class'] : null; - $lis.= Display::tag('li', $item['title'], array('class' => $extra_class.' pull-right')); - } - } - - if (!empty($lis)) { - $html .= Display::tag('ul', $lis, array('class'=>'breadcrumb')); - } - } - return $html ; -} diff --git a/main/inc/lib/page.lib.php b/main/inc/lib/page.lib.php index 4bee3e6cc9..cb6b302e7f 100644 --- a/main/inc/lib/page.lib.php +++ b/main/inc/lib/page.lib.php @@ -44,7 +44,6 @@ class PageController $profile_content .=''; } } - self::show_right_block(null, null, 'user_image_block', array('content' => $profile_content)); } @@ -144,8 +143,9 @@ class PageController if (api_get_setting('allow_social_tool') == 'true') { $total_invitations = Display::badge($total_invitations); $profile_content[] = array('href' => api_get_path(WEB_PATH).'main/social/invitations.php', 'title' => get_lang('PendingInvitations').$total_invitations); + } else { + $profile_content[] = array('href' => api_get_path(WEB_PATH).'main/auth/profile.php', 'title' => get_lang('PendingInvitations').$total_invitations); } - $profile_content[] = array('href' => api_get_path(WEB_PATH).'main/auth/profile.php', 'title' => get_lang('PendingInvitations').$total_invitations); } self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block'); } diff --git a/main/inc/lib/template.lib.php b/main/inc/lib/template.lib.php index e961a9650f..2a3ce5be43 100644 --- a/main/inc/lib/template.lib.php +++ b/main/inc/lib/template.lib.php @@ -275,6 +275,7 @@ class Template { $user_info = array(); $user_info['logged'] = 0; $this->user_is_logged_in = false; + if (api_user_is_login()) { $user_info = api_get_user_info(); $user_info['logged'] = 1; @@ -285,6 +286,7 @@ class Template { } $user_info['messages_count'] = MessageManager::get_new_messages(); + $user_info['messages_invitations_count'] = GroupPortalManager::get_groups_by_user_count($user_info['user_id'], GROUP_USER_PERMISSION_PENDING_INVITATION, false); $this->user_is_logged_in = true; } diff --git a/main/inc/lib/userportal.lib.php b/main/inc/lib/userportal.lib.php index 86e91e584f..e69de29bb2 100644 --- a/main/inc/lib/userportal.lib.php +++ b/main/inc/lib/userportal.lib.php @@ -1,1067 +0,0 @@ -tpl = new Template($title, $app); - $this->home = api_get_home_path(); - $this->user_id = api_get_user_id(); - $this->load_directories_preview = false; - - if (api_get_setting('show_documents_preview') == 'true') { - $this->load_directories_preview = true; - } - } - - function set_login_form() { - global $loginFailed; - - $login_form = ''; - - if (!($this->user_id) || api_is_anonymous($this->user_id)) { - - // Only display if the user isn't logged in. - $this->tpl->assign('login_language_form', api_display_language_form(true)); - $this->tpl->assign('login_form', self::display_login_form()); - - if ($loginFailed) { - $this->tpl->assign('login_failed', self::handle_login_failed()); - } - - if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') { - $login_form .= ''; - } - $this->tpl->assign('login_options', $login_form); - } - } - - - function return_exercise_block($personal_course_list) { - require_once api_get_path(SYS_CODE_PATH).'exercice/exercise.lib.php'; - $exercise_list = array(); - if (!empty($personal_course_list)) { - foreach($personal_course_list as $course_item) { - $course_code = $course_item['c']; - $session_id = $course_item['id_session']; - - $exercises = get_exercises_to_be_taken($course_code, $session_id); - - foreach($exercises as $exercise_item) { - $exercise_item['course_code'] = $course_code; - $exercise_item['session_id'] = $session_id; - $exercise_item['tms'] = api_strtotime($exercise_item['end_time'], 'UTC'); - - $exercise_list[] = $exercise_item; - } - } - if (!empty($exercise_list)) { - $exercise_list = msort($exercise_list, 'tms'); - $my_exercise = $exercise_list[0]; - $url = Display::url($my_exercise['title'], api_get_path(WEB_CODE_PATH).'exercice/overview.php?exerciseId='.$my_exercise['id'].'&cidReq='.$my_exercise['course_code'].'&id_session='.$my_exercise['session_id']); - $this->tpl->assign('exercise_url', $url); - $this->tpl->assign('exercise_end_date', api_convert_and_format_date($my_exercise['end_time'], DATE_FORMAT_SHORT)); - } - } - } - - function return_announcements($show_slide = true) { - // Display System announcements - $announcement = isset($_GET['announcement']) ? $_GET['announcement'] : null; - $announcement = intval($announcement); - - if (!api_is_anonymous() && $this->user_id) { - $visibility = api_is_allowed_to_create_course() ? SystemAnnouncementManager::VISIBLE_TEACHER : SystemAnnouncementManager::VISIBLE_STUDENT; - if ($show_slide) { - $announcements = SystemAnnouncementManager :: display_announcements_slider($visibility, $announcement); - } else { - $announcements = SystemAnnouncementManager :: display_all_announcements($visibility, $announcement); - } - } else { - if ($show_slide) { - $announcements = SystemAnnouncementManager :: display_announcements_slider(SystemAnnouncementManager::VISIBLE_GUEST, $announcement); - } else { - $announcements = SystemAnnouncementManager :: display_all_announcements(SystemAnnouncementManager::VISIBLE_GUEST, $announcement); - } - } - return $announcements; - } - - /** - * Alias for the online_logout() function - */ - function logout() { - online_logout($this->user_id, true); - } - - /** - * This function checks if there are courses that are open to the world in the platform course categories (=faculties) - * - * @param string $category - * @return boolean - */ - function category_has_open_courses($category) { - $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; - $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); - $category = Database::escape_string($category); - $sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'"; - $sql_result = Database::query($sql_query); - while ($course = Database::fetch_array($sql_result)) { - if (!$setting_show_also_closed_courses) { - if ((api_get_user_id() > 0 && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { - return true; //at least one open course - } - } else { - if (isset($course['visibility'])) { - return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true). - } - } - } - return false; - } - - - /** - * Displays the right-hand menu for anonymous users: - * login form, useful links, help section - * Warning: function defines globals - * @version 1.0.1 - * @todo does $_plugins need to be global? - */ - function display_anonymous_right_menu() { - global $loginFailed, $_user; - $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview'); - $current_user_id = api_get_user_id(); - - echo self::set_login_form(false); - echo self::return_teacher_link(); - echo self::return_notice(); - } - - function return_teacher_link() { - $html = ''; - if (!empty($this->user_id)) { - // tabs that are deactivated are added here - - $show_menu = false; - $show_create_link = false; - $show_course_link = false; - - if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { - $show_menu = true; - $show_course_link = true; - } else { - if (api_get_setting('allow_students_to_browse_courses') == 'true') { - $show_menu = true; - $show_course_link = true; - } - } - - if ($show_menu && ($show_create_link || $show_course_link )) { - $show_menu = true; - } else { - $show_menu = false; - } - } - - // My Account section - - if ($show_menu) { - $html .= ''; - } - - if (!empty($html)) { - $html = self::show_right_block(get_lang('Courses'), $html, 'teacher_block'); - } - return $html; - } - - /* Includes a created page */ - function return_home_page() { - - // Including the page for the news - $html = ''; - - if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) { - $open = @(string)file_get_contents(api_get_path(SYS_PATH).$this->home.$_GET['include']); - $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); - } else { - if (!empty($_SESSION['user_language_choice'])) { - $user_selected_language = $_SESSION['user_language_choice']; - } elseif (!empty($_SESSION['_user']['language'])) { - $user_selected_language = $_SESSION['_user']['language']; - } else { - $user_selected_language = api_get_setting('platformLanguage'); - } - if (!file_exists($this->home.'home_news_'.$user_selected_language.'.html')) { - if (file_exists($this->home.'home_top.html')) { - $home_top_temp = file($this->home.'home_top.html'); - } else { - $home_top_temp = file($this->default_home.'home_top.html'); - } - $home_top_temp = implode('', $home_top_temp); - } else { - if (file_exists($this->home.'home_top_'.$user_selected_language.'.html')) { - $home_top_temp = file_get_contents($this->home.'home_top_'.$user_selected_language.'.html'); - } else { - $home_top_temp = file_get_contents($this->home.'home_top.html'); - } - } - if (trim($home_top_temp) == '' && api_is_platform_admin()) { - $home_top_temp = get_lang('PortalHomepageDefaultIntroduction'); - } - $open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp); - $html = api_to_system_encoding($open, api_detect_encoding(strip_tags($open))); - } - return $html; - } - - function return_notice() { - $sys_path = api_get_path(SYS_PATH); - $user_selected_language = api_get_interface_language(); - - $html = ''; - // Notice - $home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice_'.$user_selected_language.'.html'); - if (empty($home_notice)) { - $home_notice = @(string)file_get_contents($sys_path.$this->home.'home_notice.html'); - } - - if (!empty($home_notice)) { - $home_notice = api_to_system_encoding($home_notice, api_detect_encoding(strip_tags($home_notice))); - $home_notice = Display::div($home_notice, array('class' => 'homepage_notice')); - $html = self::show_right_block(get_lang('Notice'), $home_notice, 'notice_block'); - } - return $html; - } - - function return_help() { - $user_selected_language = api_get_interface_language(); - $sys_path = api_get_path(SYS_PATH); - $platformLanguage = api_get_setting('platformLanguage'); - - // Help section. - /* Hide right menu "general" and other parts on anonymous right menu. */ - - if (!isset($user_selected_language)) { - $user_selected_language = $platformLanguage; - } - - $html = null; - $home_menu = @(string)file_get_contents($sys_path.$this->home.'home_menu_'.$user_selected_language.'.html'); - if (!empty($home_menu)) { - $home_menu_content = ''; - $html .= self::show_right_block(get_lang('MenuGeneral'), $home_menu_content, 'help_block'); - } - return $html; - } - - function return_skills_links() { - $html = ''; - if (api_get_setting('allow_skills_tool') == 'true') { - $content = ''; - $html = self::show_right_block(get_lang("Skills"), $content, 'skill_block'); - } - return $html; - } - - /** - * Reacts on a failed login: - * Displays an explanation with a link to the registration form. - * - * @version 1.0.1 - */ - function handle_login_failed() { - $message = get_lang('InvalidId'); - - if (!isset($_GET['error'])) { - if (api_is_self_registration_allowed()) { - $message = get_lang('InvalidForSelfRegistration'); - } - } else { - switch ($_GET['error']) { - case '': - if (api_is_self_registration_allowed()) { - $message = get_lang('InvalidForSelfRegistration'); - } - break; - case 'account_expired': - $message = get_lang('AccountExpired'); - break; - case 'account_inactive': - $message = get_lang('AccountInactive'); - break; - case 'user_password_incorrect': - $message = get_lang('InvalidId'); - break; - case 'access_url_inactive': - $message = get_lang('AccountURLInactive'); - break; - case 'unrecognize_sso_origin': - //$message = get_lang('SSOError'); - break; - } - } - return Display::return_message($message, 'error'); - } - - /** - * Display list of courses in a category. - * (for anonymous users) - * - * @version 1.1 - * @author Patrick Cool , Ghent University - refactoring and code cleaning - * @author Julio Montoya , Beeznest template modifs - */ - function return_courses_in_categories() { - $result = ''; - $ctok = $_SESSION['sec_token']; - $stok = Security::get_token(); - - // Initialization. - $user_identified = (api_get_user_id() > 0 && !api_is_anonymous()); - $web_course_path = api_get_path(WEB_COURSE_PATH); - $category = Database::escape_string($_GET['category']); - $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; - - // Database table definitions. - $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); - $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY); - - // Get list of courses in category $category. - $sql_get_course_list = "SELECT * FROM $main_course_table cours - WHERE category_code = '".Database::escape_string($_GET['category'])."' - ORDER BY title, UPPER(visual_code)"; - - // Showing only the courses of the current access_url_id. - global $_configuration; - if ($_configuration['multiple_access_urls']) { - $url_access_id = api_get_current_access_url_id(); - if ($url_access_id != -1) { - $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql_get_course_list = "SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=course.code) - WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET['category'])."' ORDER BY title, UPPER(visual_code)"; - } - } - - // Removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' - $sql_result_courses = Database::query($sql_get_course_list); - - while ($course_result = Database::fetch_array($sql_result_courses)) { - $course_list[] = $course_result; - } - - $platform_visible_courses = ''; - // $setting_show_also_closed_courses - if ($user_identified) { - if ($setting_show_also_closed_courses) { - $platform_visible_courses = ''; - } else { - $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )"; - } - } else { - if ($setting_show_also_closed_courses) { - $platform_visible_courses = ''; - } else { - $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )"; - } - } - $sqlGetSubCatList = " - SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse - FROM $main_category_table t1 - LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id - LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) - WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." - GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; - - - // Showing only the category of courses of the current access_url_id - if ($_configuration['multiple_access_urls']) { - $url_access_id = api_get_current_access_url_id(); - if ($url_access_id != -1) { - $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sqlGetSubCatList = " - SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse - FROM $main_category_table t1 - LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id - LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) - INNER JOIN $tbl_url_rel_course as url_rel_course - ON (url_rel_course.course_code=t3.code) - WHERE access_url_id = $url_access_id AND t1.parent_id ".(empty($category) ? "IS NULL" : "='$category'")." - GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; - } - } - - $resCats = Database::query($sqlGetSubCatList); - $thereIsSubCat = false; - if (Database::num_rows($resCats) > 0) { - $htmlListCat = Display::page_header(get_lang('CatList')); - $htmlListCat .= '
      '; - while ($catLine = Database::fetch_array($resCats)) { - if ($catLine['code'] != $category) { - $category_has_open_courses = self::category_has_open_courses($catLine['code']); - if ($category_has_open_courses) { - // The category contains courses accessible to anonymous visitors. - $htmlListCat .= '
    • '; - $htmlListCat .= ''.$catLine['name'].''; - if (api_get_setting('show_number_of_courses') == 'true') { - $htmlListCat .= ' ('.$catLine['nbCourse'].' '.get_lang('Courses').')'; - } - $htmlListCat .= "
    • "; - $thereIsSubCat = true; - } elseif ($catLine['children_count'] > 0) { - // The category has children, subcategories. - $htmlListCat .= '
    • '; - $htmlListCat .= ''.$catLine['name'].''; - $htmlListCat .= "
    • "; - $thereIsSubCat = true; - } - /* End changed code to eliminate the (0 courses) after empty categories. */ - elseif (api_get_setting('show_empty_course_categories') == 'true') { - $htmlListCat .= '
    • '; - $htmlListCat .= $catLine['name']; - $htmlListCat .= "
    • "; - $thereIsSubCat = true; - } // Else don't set thereIsSubCat to true to avoid printing things if not requested. - } else { - $htmlTitre = '

      '; - if (api_get_setting('show_back_link_on_top_of_tree') == 'true') { - $htmlTitre .= '<< '.get_lang('BackToHomePage').''; - } - if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') != 'true' && !is_null($catLine['code']))) { - $htmlTitre .= '<< '.get_lang('Up').''; - } - $htmlTitre .= "

      "; - if ($category != "" && !is_null($catLine['code'])) { - $htmlTitre .= '

      '.$catLine['name']."

      "; - } else { - $htmlTitre .= '

      '.get_lang('Categories')."

      "; - } - } - } - $htmlListCat .= "
    "; - } - $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 .= "
      "; - - if (api_get_user_id()) { - $courses_of_user = self::get_courses_of_user(api_get_user_id()); - } - - foreach ($course_list as $course) { - // $setting_show_also_closed_courses - if (!$setting_show_also_closed_courses) { - // If we do not show the closed courses - // we only show the courses that are open to the world (to everybody) - // and the courses that are open to the platform (if the current user is a registered user. - if( ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { - $courses_shown++; - $courses_list_string .= "
    • \n"; - $courses_list_string .= ''.$course['title'].'
      '; - $course_details = array(); - if (api_get_setting('display_coursecode_in_courselist') == 'true') { - $course_details[] = $course['visual_code']; - } - if (api_get_setting('display_teacher_in_courselist') == 'true') { - $course_details[] = $course['tutor_name']; - } - if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { - $course_details[] = $course['course_language']; - } - $courses_list_string .= implode(' - ', $course_details); - $courses_list_string .= "
    • \n"; - } - } else { - // We DO show the closed courses. - // The course is accessible if (link to the course homepage): - // 1. the course is open to the world (doesn't matter if the user is logged in or not): $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD); - // 2. the user is logged in and the course is open to the world or open to the platform: ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM); - // 3. the user is logged in and the user is subscribed to the course and the course visibility is not COURSE_VISIBILITY_CLOSED; - // 4. the user is logged in and the user is course admin of te course (regardless of the course visibility setting); - // 5. the user is the platform admin api_is_platform_admin(). - // - $courses_shown++; - $courses_list_string .= "
    • \n"; - if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD - || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) - || ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) - || $courses_of_user[$course['code']]['status'] == '1' - || api_is_platform_admin()) { - $courses_list_string .= ''; - } - $courses_list_string .= $course['title']; - if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD - || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) - || ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED) - || $courses_of_user[$course['code']]['status'] == '1' - || api_is_platform_admin()) { - $courses_list_string .= '
      '; - } - $course_details = array(); - if (api_get_setting('display_coursecode_in_courselist') == 'true') { - $course_details[] = $course['visual_code']; - } -// if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') { -// $courses_list_string .= ' - '; -// } - if (api_get_setting('display_teacher_in_courselist') == 'true') { - $course_details[] = $course['tutor_name']; - } - if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { - $course_details[] = $course['course_language']; - } - if (api_get_setting('show_different_course_language') == 'true' && $course['course_language'] != api_get_setting('platformLanguage')) { - $course_details[] = $course['course_language']; - } - - $courses_list_string .= implode(' - ', $course_details); - // We display a subscription link if: - // 1. it is allowed to register for the course and if the course is not already in the courselist of the user and if the user is identiefied - // 2. - if ($user_identified && !key_exists($course['code'], $courses_of_user)) { - if ($course['subscribe'] == '1') { - $courses_list_string .= '
      '; - $courses_list_string .= ''; - $courses_list_string .= ''; - $courses_list_string .= ''.get_lang('Subscribe').'
      '; - } else { - $courses_list_string .= '
      '.get_lang('SubscribingNotAllowed'); - } - } - $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') . '

    '; - } - return $result; - } - - /** - * retrieves all the courses that the user has already subscribed to - * @author Patrick Cool , Ghent University, Belgium - * @param int $user_id: the id of the user - * @return array an array containing all the information of the courses of the given user - */ - function get_courses_of_user($user_id) { - $table_course = Database::get_main_table(TABLE_MAIN_COURSE); - $table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER); - // Secondly we select the courses that are in a category (user_course_cat <> 0) and sort these according to the sort of the category - $user_id = intval($user_id); - $sql_select_courses = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr, - course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status, - course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat - FROM $table_course course, - $table_course_user course_rel_user - WHERE course.code = course_rel_user.course_code - AND course_rel_user.user_id = '".$user_id."' - AND course_rel_user.relation_type<>".COURSE_RELATION_TYPE_RRHH." - ORDER BY course_rel_user.sort ASC"; - $result = Database::query($sql_select_courses); - $courses = array(); - while ($row = Database::fetch_array($result)) { - // We only need the database name of the course. - $courses[$row['k']] = array('db' => $row['db'], 'code' => $row['k'], 'visual_code' => $row['vc'], 'title' => $row['i'], 'directory' => $row['dir'], 'status' => $row['status'], 'tutor' => $row['t'], 'subscribe' => $row['subscr'], 'unsubscribe' => $row['unsubscr'], 'sort' => $row['sort'], 'user_course_category' => $row['user_course_cat']); - } - return $courses; - } - - /** - * @todo use the template system - */ - function show_right_block($title, $content, $id = null, $params = null) { - if (!empty($id)) { - $params['id'] = $id; - } - $params['class'] = 'well sidebar-nav'; - $html = null; - if (!empty($title)) { - $html.= '

    '.$title.'

    '; - } - $html.= $content; - $html = Display::div($html, $params); - return $html; - } - - /** - * Adds a form to let users login - * @version 1.1 - */ - function display_login_form() { - $form = new FormValidator('formLogin', 'POST', null, null, array('class'=>'form-vertical')); - // 'placeholder'=>get_lang('UserName') - //'autocomplete'=>"off", - - $form->addElement('text', 'login', get_lang('UserName'), array('class' => 'span2 autocapitalize_off', 'autofocus' => 'autofocus')); - $form->addElement('password', 'password', get_lang('Pass'), array('class' => 'span2')); - $form->addElement('style_submit_button','submitAuth', get_lang('LoginEnter'), array('class' => 'btn')); - $html = $form->return_form(); - if (api_get_setting('openid_authentication') == 'true') { - include_once 'main/auth/openid/login.php'; - $html .= '
    '.openid_form().'
    '; - } - return $html; - } - - function return_search_block() { - $html = ''; - if (api_get_setting('search_enabled') == 'true') { - $html .= ''; - $html .= self::show_right_block(get_lang('Search'), $search_content, 'search_block'); - } - return $html; - } - - function return_classes_block() { - $html = ''; - if (api_get_setting('show_groups_to_users') == 'true') { - require_once api_get_path(LIBRARY_PATH).'usergroup.lib.php'; - $usergroup = new Usergroup(); - $usergroup_list = $usergroup->get_usergroup_by_user(api_get_user_id()); - $classes = ''; - if (!empty($usergroup_list)) { - foreach($usergroup_list as $group_id) { - $data = $usergroup->get($group_id); - $data['name'] = Display::url($data['name'], api_get_path(WEB_CODE_PATH).'user/classes.php?id='.$data['id']); - $classes .= Display::tag('li', $data['name']); - } - } - if (api_is_platform_admin()) { - $classes .= Display::tag('li', Display::url(get_lang('AddClasses') ,api_get_path(WEB_CODE_PATH).'admin/usergroups.php?action=add')); - } - if (!empty($classes)) { - $classes = Display::tag('ul', $classes, array('class'=>'nav nav-list')); - $html .= self::show_right_block(get_lang('Classes'), $classes, 'classes_block'); - } - } - return $html; - } - - function return_reservation_block() { - $html = ''; - if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course()) { - $booking_content .=''; - $html .= self::show_right_block(get_lang('Booking'), $booking_content, 'reservation_block'); - } - return $html; - } - - function return_user_image_block() { - $img_array = UserManager::get_user_picture_path_by_id(api_get_user_id(), 'web', true, true); - $img_array = UserManager::get_picture_user(api_get_user_id(), $img_array['file'], 50, USER_IMAGE_SIZE_MEDIUM, ' width="90" height="90" '); - if (api_get_setting('allow_social_tool') == 'true') { - $profile_content .=''; - } else { - $profile_content .=''; - } - $html = self::show_right_block(null, $profile_content, 'user_image_block', array('style' => 'text-align:center;')); - return $html; - } - - function return_profile_block() { - $html = ''; - $user_id = api_get_user_id(); - - if (empty($user_id)) { - return; - } - - $profile_content .= ''; - $html = self::show_right_block(get_lang('Profile'), $profile_content, 'profile_block'); - return $html; - } - - function return_navigation_links() { - $html = ''; - - // Deleting the myprofile link. - if (api_get_setting('allow_social_tool') == 'true') { - unset($this->tpl->menu_navigation['myprofile']); - } - - // Main navigation section. - // Tabs that are deactivated are added here. - if (!empty($this->tpl->menu_navigation)) { - $content = ''; - $html = self::show_right_block(get_lang('MainNavigation'), $content, 'navigation_link_block'); - } - return $html; - } - - function return_course_block() { - $html = ''; - - $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'); - 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; - } - } - - // 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; - } - - /** - * The most important function here, prints the sessions and courses - * list for use in user_portal.php for one given user - * @param int User ID - * @return string HTML list of session categories, sessions and courses - * @assert (null) === false - */ - function return_courses_and_sessions($user_id) { - if (!isset($user_id)) { - return false; - } - $session_categories = array(); - $load_history = (isset($_GET['history']) && intval($_GET['history']) == 1) ? true : false; - - if ($load_history) { - //Load sessions in category in *history* - $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); - } - - $html = ''; - //Showing history title - if ($load_history) { - $html .= Display::page_subheader(get_lang('HistoryTrainingSession')); - if (empty($session_categories)) { - $html .= get_lang('YouDoNotHaveAnySessionInItsHistory'); - } - } - - $courses_html = ''; - $special_courses = ''; - - // If we're not in the history view... - if (!isset($_GET['history'])) { - //Display special courses - $special_courses = CourseManager::display_special_courses($user_id, $this->load_directories_preview); - //Display courses - $courses_html .= CourseManager::display_courses($user_id, $this->load_directories_preview); - } - - $sessions_with_category = ''; - $sessions_with_no_category = ''; - - 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 - if ($session_category_id == 0) { - - // Independent sessions - if (isset($session_category['sessions'])) { - foreach ($session_category['sessions'] as $session) { - - $session_id = $session['session_id']; - - // Don't show empty sessions. - if (count($session['courses']) < 1) { - continue; - } - - $html_courses_session = ''; - $count_courses_session = 0; - - foreach ($session['courses'] as $course) { - //read only and accesible - if (api_get_setting('hide_courses_in_sessions') == 'false') { - $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id, $this->load_directories_preview); - } - $count_courses_session++; - } - - if ($count_courses_session > 0) { - $params = array(); - $params['icon'] = Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_'.$session_id), ICON_SIZE_LARGE); - - if (api_is_drh()) { - $session_link = $session['session_name']; - $params['link'] = null; - } else { - $session_link = Display::tag('a', $session['session_name'], array('href'=>api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id)); - $params['link'] = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id; - } - - $params['title'] = $session_link; - - $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']); - $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null; - - $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status; - $params['dates'] = $session['date_message']; - - $params['right_actions'] = ''; - if (api_is_platform_admin()) { - $params['right_actions'] .= ''; - $params['right_actions'] .= Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; - } - - if (api_get_setting('hide_courses_in_sessions') == 'false') { - // $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 - $count_courses_session = 0; - $html_sessions = ''; - foreach ($session_category['sessions'] as $session) { - $session_id = $session['session_id']; - // Don't show empty sessions. - if (count($session['courses']) < 1) { - continue; - } - - $html_courses_session = ''; - $count = 0; - foreach ($session['courses'] as $course) { - if (api_get_setting('hide_courses_in_sessions') == 'false') { - $html_courses_session .= CourseManager :: get_logged_user_course_html($course, $session_id); - } - $count_courses_session++; - $count++; - } - - $params = array(); - if ($count > 0) { - $params['icon'] = Display::return_icon('window_list.png', $session['session_name'], array('id' => 'session_img_'.$session_id), ICON_SIZE_LARGE); - - if (api_is_drh()) { - $session_link = $session['session_name']; - $params['link'] = null; - } else { - $session_link = Display::tag('a', $session['session_name'], array('href'=>api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id)); - $params['link'] = api_get_path(WEB_CODE_PATH).'session/index.php?session_id='.$session_id; - } - - $params['title'] .= $session_link; - - $moved_status = SessionManager::get_session_change_user_reason($session['moved_status']); - $moved_status = isset($moved_status) && !empty($moved_status) ? ' ('.$moved_status.')' : null; - - $params['subtitle'] = isset($session['coach_info']) ? $session['coach_info']['complete_name'] : null.$moved_status; - $params['dates'] = $session['date_message']; - - if (api_is_platform_admin()) { - $params['right_actions'] .= ''.Display::return_icon('edit.png', get_lang('Edit'), array('align' => 'absmiddle'), ICON_SIZE_SMALL).''; - } - $html_sessions .= CourseManager::course_item_html($params, true).$html_courses_session; - } - } - - if ($count_courses_session > 0) { - $params = array(); - $params['icon'] = Display::return_icon('folder_blue.png', $session_category['session_category']['name'], array(), ICON_SIZE_LARGE); - - if (api_is_platform_admin()) { - $params['right_actions'] .= ''.Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_SMALL).''; - } - - $params['title'] .= $session_category['session_category']['name']; - - if (api_is_platform_admin()) { - $params['link'] = api_get_path(WEB_CODE_PATH).'admin/session_category_edit.php?&id='.$session_category['session_category']['id']; - } - - $session_category_start_date = $session_category['session_category']['date_start']; - $session_category_end_date = $session_category['session_category']['date_end']; - - if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00' && !empty($session_category_end_date) && $session_category_end_date != '0000-00-00' ) { - $params['subtitle'] = sprintf(get_lang('FromDateXToDateY'), $session_category['session_category']['date_start'], $session_category['session_category']['date_end']); - } else { - if (!empty($session_category_start_date) && $session_category_start_date != '0000-00-00') { - $params['subtitle'] = get_lang('From').' '.$session_category_start_date; - } - if (!empty($session_category_end_date) && $session_category_end_date != '0000-00-00') { - $params['subtitle'] = get_lang('Until').' '.$session_category_end_date; - } - } - $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 - */ - function return_welcome_to_course_block() { - $count_courses = CourseManager::count_courses(); - $tpl = $this->tpl->get_template('layout/welcome_to_course.tpl'); - - $course_catalog_url = api_get_path(WEB_CODE_PATH).'auth/courses.php'; - $course_list_url = api_get_path(WEB_PATH).'user_portal.php'; - - $this->tpl->assign('course_catalog_url', $course_catalog_url); - $this->tpl->assign('course_list_url', $course_list_url); - $this->tpl->assign('course_catalog_link', Display::url(get_lang('here'), $course_catalog_url)); - $this->tpl->assign('course_list_link', Display::url(get_lang('here'), $course_list_url)); - $this->tpl->assign('count_courses', $count_courses); - - return $this->tpl->fetch($tpl); - } - - function return_hot_courses() { - return CourseManager::return_hot_courses(); - } -} diff --git a/main/template/default/layout/layout_3_col.tpl b/main/template/default/layout/layout_3_col.tpl index ecf176536e..ab81e6e350 100644 --- a/main/template/default/layout/layout_3_col.tpl +++ b/main/template/default/layout/layout_3_col.tpl @@ -1,7 +1,7 @@ {# This template is NOT used in chamilo 1.9 #} -{{ extends "default/layout/main.tpl" }} +{% extends "default/layout/main.tpl" %} -{% block body %} +{% block body %}
    {{ plugin_courses_block}} {{ home_page_block}} @@ -9,11 +9,11 @@ {{ content}} {{ announcements_block}}
    - -