From e9c19fc99a8f1bd500d089538c4d0f7ccbc8d943 Mon Sep 17 00:00:00 2001 From: Julio Montoya Date: Sat, 3 Sep 2011 09:20:48 +0200 Subject: [PATCH] Fixing fatal error when loging out + index.php and index-smarty.php are the same now --- index-smarty.php | 32 ++- index.php | 63 ++--- main/inc/lib/system_announcements.lib.php | 15 +- main/inc/lib/userportal.lib.php | 217 ++++++++++-------- main/template/default/layout/header.tpl | 7 + .../default/layout/layout_two_col.tpl | 8 +- .../experimental/layout/layout_two_col.tpl | 5 +- 7 files changed, 182 insertions(+), 165 deletions(-) diff --git a/index-smarty.php b/index-smarty.php index f5c4455988..ce39dc8100 100644 --- a/index-smarty.php +++ b/index-smarty.php @@ -13,31 +13,45 @@ $language_file = array('courses', 'index'); // Maybe we should change this into an api function? an example: Coursemanager::unset(); $cidReset = true; -/* Included libraries */ -// The section (for the tabs). -$this_section = SECTION_CAMPUS; - require_once 'main/inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'userportal.lib.php'; +// The section (for the tabs). +$this_section = SECTION_CAMPUS; + $header_title = null; if (!api_is_anonymous()) { $header_title = " "; } +$htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider')); +$htmlHeadXtra[] =' +'; + + $index = new IndexManager($header_title); $tpl = $index->tpl->get_template('layout/layout_two_col.tpl'); -$user_id = api_get_user_id(); //@todo move this inside the IndexManager -$index->tpl->assign('login_block', $index->show_login_form($user_id)); -$index->tpl->assign('teacher_block', $index->display_teacher_link($user_id)); -$index->tpl->assign('home_page', $index->return_home_page()); + +$index->tpl->assign('announcements_block', $index->return_announcements()); +$index->tpl->assign('teacher_block', $index->return_teacher_link()); +$index->tpl->assign('home_page_block', $index->return_home_page()); $index->tpl->assign('profile_block', $index->return_profile_block()); -$index->tpl->assign('notice_block', $index->return_notice($home)); +$index->tpl->assign('notice_block', $index->return_notice()); $index->tpl->assign('plugin_campushomepage', $index->return_plugin_campushomepage()); $index->tpl->display($tpl); \ No newline at end of file diff --git a/index.php b/index.php index 1345c48831..a15e62a124 100755 --- a/index.php +++ b/index.php @@ -24,11 +24,9 @@ $cidReset = true; /** @todo Make all the library files consistent, use filename.lib.php and not filename.lib.inc.php. */ require_once 'main/inc/global.inc.php'; -require_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php'; -require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; +require_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'userportal.lib.php'; - require_once 'main/chat/chat_functions.lib.php'; $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed); @@ -38,6 +36,13 @@ $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 't $this_section = SECTION_CAMPUS; unset($_SESSION['this_section']);//for hmtl editor repository +$header_title = null; +if (!api_is_anonymous()) { + $header_title = " "; +} + +$index = new IndexManager($header_title, false); + /* Action Handling */ /** @todo Wouldn't it make more sense if this would be done in local.inc.php so that local.inc.php become the only place where authentication is done? @@ -48,13 +53,11 @@ unset($_SESSION['this_section']);//for hmtl editor repository $my_user_id = api_get_user_id(); if (!empty($_GET['logout'])) { - logout(); + $index->logout(); } /* Table definitions */ -$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); -$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY); -$track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); + /* Constants and CONFIGURATION parameters */ /** @todo these configuration settings should move to the Chamilo config settings. */ @@ -62,11 +65,6 @@ $track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_ /** Defines wether or not anonymous visitors can see a list of the courses on the Chamilo homepage that are open to the world. */ $_setting['display_courses_to_anonymous_users'] = 'true'; -/** @todo Remove this piece of code because this is not used. */ -if (isset($_user['user_id'])) { - $nameTools = api_get_setting('siteName'); -} - /* LOGIN */ /** @@ -96,6 +94,7 @@ if (api_get_setting('allow_terms_conditions') == 'true') { if (!empty($_POST['submitAuth'])) { // The user has been already authenticated, we are now to find the last login of the user. if (isset ($_user['user_id'])) { + $track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN); $sql_last_login = "SELECT UNIX_TIMESTAMP(login_date) FROM $track_login_table WHERE login_user_id = '".$_user['user_id']."' @@ -123,17 +122,6 @@ if (!empty($_POST['submitAuth'])) { event_open(); } -// The header. -/*$header_title = get_lang('Homepage'); -//$sitename = api_get_setting('siteName'); -if (!api_get_user_id()) { - $header_title = null; -}*/ -$header_title = null; -if (!api_is_anonymous()) { - $header_title = " "; -} - $htmlHeadXtra[] = api_get_jquery_libraries_js(array('bxslider')); $htmlHeadXtra[] ='