, Ghent University, Refactoring * @version $Id: index.php 22368 2009-07-24 23:25:57Z iflorespaz $ * @todo check the different @todos in this page and really do them * @todo check if the news management works as expected */ // Only this script should have this constant defined. This is used to activate the javascript that // gives the login name automatic focus in header.inc.html. /** @todo Couldn't this be done using the $HtmlHeadXtra array? */ define('DOKEOS_HOMEPAGE', true); $language_file = array('courses', 'index'); /* Flag forcing the 'current course' reset, as we're not inside a course anymore */ // Maybe we should change this into an api function? an example: Coursemanager::unset(); $cidReset = true; /* Included libraries */ /** @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).'course.lib.php'; require_once api_get_path(LIBRARY_PATH).'events.lib.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).'formvalidator/FormValidator.class.php'; require_once 'main/chat/chat_functions.lib.php'; $loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed); $setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true'; // the section (for the tabs) $this_section = SECTION_CAMPUS; unset($_SESSION['this_section']);//for hmtl editor repository /* 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? * by doing this you could logout from any page instead of only from index.php. From the moment there is a logout=true in the url you will be logged out * this can be usefull when you are on an open course and you need to log in to edit something and you immediately want to check how anonymous users * will see it. */ $my_user_id = api_get_user_id(); if (!empty($_GET['logout'])) { 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 dokeos config settings */ /** defines wether or not anonymous visitors can see a list of the courses on the Dokeos 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 */ /** * @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled. * @todo consider removing this piece of code because does nothing. */ if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) { // nice lie!!! echo 'Attempted breakin - sysadmins notified.'; session_destroy(); die(); } // Delete session neccesary for legal terms if (api_get_setting('allow_terms_conditions') == 'true') { unset($_SESSION['update_term_and_condition']); unset($_SESSION['info_current_user']); } /** * @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 is already authenticated, we now find the last login of the user. if (isset ($_user['user_id'])) { $sql_last_login = "SELECT UNIX_TIMESTAMP(login_date) FROM $track_login_table WHERE login_user_id = '".$_user['user_id']."' ORDER BY login_date DESC LIMIT 1"; $result_last_login = Database::query($sql_last_login); if (!$result_last_login) { if (Database::num_rows($result_last_login) > 0) { $user_last_login_datetime = Database::fetch_array($result_last_login); $user_last_login_datetime = $user_last_login_datetime[0]; api_session_register('user_last_login_datetime'); } } Database::free_result($result_last_login); //event_login(); if (api_is_platform_admin()) { // decode all open event informations and fill the track_c_* tables include api_get_path(LIBRARY_PATH).'stats.lib.inc.php'; decodeOpenInfos(); } } } // end login -- if ($_POST['submitAuth']) else { // only if login form was not sent because if the form is sent the user was already on the page. event_open(); } // the header $header_title = get_lang('Homepage'); $sitename = api_get_setting('siteName'); if (!empty($sitename)) { $header_title = null; } Display::display_header($header_title); /* MAIN CODE */ echo '
'; 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 .= "
\n"; if ($category != "" && !is_null($catLine['code'])) { $htmlTitre .= '', get_lang('_No_course_publicly_available'), "\n"; } 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) echo $courses_list_string; } if ($category != '') { echo '
', Display :: return_icon('back.png', get_lang('BackToHomePage')), get_lang('BackToHomePage'), '
', "\n"; } } /** * retrieves all the courses that the user has already subscribed to * @author Patrick Cool