@ -2,11 +2,10 @@
/* For licensing terms, see /license.txt */
/* For licensing terms, see /license.txt */
/**
/**
* @package chamilo.main
* @package chamilo.main
* @author Patrick Cool < patrick.cool @ UGent . be > , Ghent University, Refactoring
* @author Patrick Cool < patrick.cool @ UGent . be > , 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 the different @todos in this page and really do them
* @todo check if the news management works as expected
* @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
// Only this script should have this constant defined. This is used to activate the javascript that
@ -16,13 +15,13 @@ define('DOKEOS_HOMEPAGE', true);
$language_file = array('courses', 'index');
$language_file = array('courses', 'index');
/* Flag forcing the 'current course' reset, as we're not inside a course anymore */
/* 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();
// Maybe we should change this into an api function? an example: Coursemanager::unset();
$cidReset = true;
$cidReset = true;
/* Included libraries */
/* Included libraries */
/** @todo m ake all the library files consistent, use filename.lib.php and not filename.lib.inc.php */
/** @todo M ake all the library files consistent, use filename.lib.php and not filename.lib.inc.php. */
require_once 'main/inc/global.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).'course.lib.php';
@ -35,16 +34,16 @@ require_once 'main/chat/chat_functions.lib.php';
$loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
$loginFailed = isset($_GET['loginFailed']) ? true : isset($loginFailed);
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
$setting_show_also_closed_courses = api_get_setting('show_closed_courses') == 'true';
// the section (for the tabs)
// The section (for the tabs).
$this_section = SECTION_CAMPUS;
$this_section = SECTION_CAMPUS;
unset($_SESSION['this_section']);//for hmtl editor repository
unset($_SESSION['this_section']);//for hmtl editor repository
/* Action Handling */
/* 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?
/** @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
* 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
* 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.
* will see it.
*/
*/
$my_user_id = api_get_user_id();
$my_user_id = api_get_user_id();
@ -52,26 +51,27 @@ if (!empty($_GET['logout'])) {
logout();
logout();
}
}
/* Table definitions */
/* Table definitions */
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$track_login_table = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
/* Constants and CONFIGURATION parameters */
/* Constants and CONFIGURATION parameters */
/** @todo these configuration settings should move to the dokeos config settings */
/** @todo these configuration settings should move to the Chamilo 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 */
/** 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';
$_setting['display_courses_to_anonymous_users'] = 'true';
/** @todo remove this piece of code because this is not used */
/** @todo Remove this piece of code because this is not used. */
if (isset($_user['user_id'])) {
if (isset($_user['user_id'])) {
$nameTools = api_get_setting('siteName');
$nameTools = api_get_setting('siteName');
}
}
/* LOGIN */
/* LOGIN */
/**
/**
* @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled.
* @todo This piece of code should probably move to local.inc.php where the actual login / logout procedure is handled.
* @todo c onsider removing this piece of code because does nothing.
* @todo C onsider removing this piece of code because does nothing.
*/
*/
if (isset($_GET['submitAuth']) & & $_GET['submitAuth'] == 1) {
if (isset($_GET['submitAuth']) & & $_GET['submitAuth'] == 1) {
// nice lie!!!
// nice lie!!!
@ -88,13 +88,13 @@ if (api_get_setting('allow_terms_conditions') == 'true') {
/**
/**
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
* @todo This piece of code should probably move to local.inc.php where the actual login procedure is handled.
* @todo c heck if this code is used. I think this code is never executed because after clicking the submit button
* @todo C heck 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
* 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')
* on api_get_setting('page_after_login').
*/
*/
if (!empty($_POST['submitAuth'])) {
if (!empty($_POST['submitAuth'])) {
// the user is already authenticated, we now find the last login of the user.
// The user has been already authenticated, we are now to find the last login of the user.
if (isset ($_user['user_id'])) {
if (isset ($_user['user_id'])) {
$sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
$sql_last_login = "SELECT UNIX_TIMESTAMP(login_date)
FROM $track_login_table
FROM $track_login_table
@ -118,13 +118,13 @@ if (!empty($_POST['submitAuth'])) {
}
}
}
}
} // e nd login -- if ($_POST['submitAuth'])
} // E nd login -- if ($_POST['submitAuth'])
else {
else {
// o nly if login form was not sent because if the form is sent the user was already on the page.
// O nly if login form was not sent because if the form is sent the user was already on the page.
event_open();
event_open();
}
}
// the header
// The header.
$header_title = get_lang('Homepage');
$header_title = get_lang('Homepage');
$sitename = api_get_setting('siteName');
$sitename = api_get_setting('siteName');
if (!empty($sitename)) {
if (!empty($sitename)) {
@ -132,13 +132,11 @@ if (!empty($sitename)) {
}
}
Display::display_header($header_title);
Display::display_header($header_title);
/*
/* MAIN CODE */
MAIN CODE
*/
echo '< div class = "maincontent" id = "content" > ';
echo '< div class = "maincontent" id = "content" > ';
// Plugins for loginpage_main AND campushomepage_main
// Plugins for loginpage_main AND campushomepage_main.
if (!api_get_user_id()) {
if (!api_get_user_id()) {
api_plugin('loginpage_main');
api_plugin('loginpage_main');
} else {
} else {
@ -191,7 +189,7 @@ if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['in
$home_top_temp = file_get_contents($home.'home_top.html');
$home_top_temp = file_get_contents($home.'home_top.html');
}
}
}
}
if(trim($home_top_temp)=='') {
if (trim($home_top_temp) == '') {
$home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
$home_top_temp = get_lang('PortalHomepageDefaultIntroduction');
}
}
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
$open = str_replace('{rel_path}', api_get_path(REL_PATH), $home_top_temp);
@ -199,7 +197,7 @@ if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['in
echo $open;
echo $open;
}
}
// Display courses and category list
// Display courses and category list.
if (!$page_included) {
if (!$page_included) {
// Display System announcements
// Display System announcements
@ -221,15 +219,16 @@ if (!$page_included) {
}
}
echo '< / div > ';
echo '< / div > ';
// Display right menu: language form, login section + useful weblinks
// Display right menu: language form, login section + useful weblinks.
echo '< div class = "menu" id = "menu" > ';
echo '< div class = "menu" id = "menu" > ';
display_anonymous_right_menu();
display_anonymous_right_menu();
echo '< / div > ';
echo '< / div > ';
/* Footer */
/* Footer */
Display :: display_footer();
Display :: display_footer();
/* Functions */
/* Functions */
/**
/**
* This function handles the logout and is called whenever there is a $_GET['logout']
* This function handles the logout and is called whenever there is a $_GET['logout']
@ -238,17 +237,17 @@ Display :: display_footer();
*/
*/
function logout() {
function logout() {
global $_configuration, $extAuthSource;
global $_configuration, $extAuthSource;
// variable initialisation
// Variable initialisation.
$query_string = '';
$query_string = '';
if (!empty($_SESSION['user_language_choice'])) {
if (!empty($_SESSION['user_language_choice'])) {
$query_string = '?language='.$_SESSION['user_language_choice'];
$query_string = '?language='.$_SESSION['user_language_choice'];
}
}
// Database table definition
// Database table definition.
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
$tbl_track_login = Database :: get_statistic_table(TABLE_STATISTIC_TRACK_E_LOGIN);
// selecting the last login of the user
// Selecting the last login of the user.
$uid = intval($_GET['uid']);
$uid = intval($_GET['uid']);
$sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='$uid' ORDER BY login_date DESC LIMIT 0,1";
$sql_last_connection = "SELECT login_id, login_date FROM $tbl_track_login WHERE login_user_id='$uid' ORDER BY login_date DESC LIMIT 0,1";
$q_last_connection = Database::query($sql_last_connection);
$q_last_connection = Database::query($sql_last_connection);
@ -261,13 +260,13 @@ function logout() {
$s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'";
$s_sql_update_logout_date = "UPDATE $tbl_track_login SET logout_date='".$current_date."' WHERE login_id='$i_id_last_connection'";
Database::query($s_sql_update_logout_date);
Database::query($s_sql_update_logout_date);
}
}
LoginDelete($uid, $_configuration['statistics_database']); //f rom inc/lib/online.inc.php - removes the "online" status
LoginDelete($uid, $_configuration['statistics_database']); // F rom inc/lib/online.inc.php - removes the "online" status.
//t he following code enables the use of an external logout function.
// T he following code enables the use of an external logout function.
//example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php
// Example: define a $extAuthSource['ldap']['logout'] = 'file.php' in configuration.php.
// t hen a function called ldap_logout() inside that file
// T hen a function called ldap_logout() inside that file
// (using *authent_name*_logout as the function name) and the following code
// (using *authent_name*_logout as the function name) and the following code
// will find and execute it
// will find and execute it.
$uinfo = api_get_user_info($uid);
$uinfo = api_get_user_info($uid);
if (($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) & & is_array($extAuthSource)) {
if (($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) & & is_array($extAuthSource)) {
if (is_array($extAuthSource[$uinfo['auth_source']])) {
if (is_array($extAuthSource[$uinfo['auth_source']])) {
@ -309,7 +308,7 @@ function category_has_open_courses($category) {
}
}
} else {
} else {
if (isset($course['visibility'])) {
if (isset($course['visibility'])) {
return true; //at least one course ( does not matter weither it's open or not because $setting_show_also_closed_courses = true
return true; // At least one course (it does not matter weither it's open or not because $setting_show_also_closed_courses = true).
}
}
}
}
}
}
@ -351,7 +350,7 @@ function display_anonymous_right_menu() {
$platformLanguage = api_get_setting('platformLanguage');
$platformLanguage = api_get_setting('platformLanguage');
$sys_path = api_get_path(SYS_PATH);
$sys_path = api_get_path(SYS_PATH);
if (!($_user['user_id']) || api_is_anonymous($_user['user_id']) ) { // Only display if the user isn't logged in
if (!($_user['user_id']) || api_is_anonymous($_user['user_id']) ) { // Only display if the user isn't logged in.
api_display_language_form(true);
api_display_language_form(true);
echo '< br / > ';
echo '< br / > ';
display_login_form();
display_login_form();
@ -377,8 +376,7 @@ function display_anonymous_right_menu() {
}
}
}
}
// My Account section.
// My Account section
if (isset($_SESSION['_user']['user_id']) & & $_SESSION['_user']['user_id'] != 0) {
if (isset($_SESSION['_user']['user_id']) & & $_SESSION['_user']['user_id'] != 0) {
// tabs that are deactivated are added here
// tabs that are deactivated are added here
@ -421,7 +419,7 @@ function display_anonymous_right_menu() {
echo '< / ul > < / div > ';
echo '< / ul > < / div > ';
}
}
// Deleting the myprofile link
// Deleting the myprofile link.
if (api_get_setting('allow_social_tool') == 'true') {
if (api_get_setting('allow_social_tool') == 'true') {
unset($menu_navigation['myprofile']);
unset($menu_navigation['myprofile']);
}
}
@ -438,8 +436,8 @@ function display_anonymous_right_menu() {
}
}
}
}
// Help section
// Help section.
/*** Hide right menu "general" and other parts on anonymous right menu **** */
/* Hide right menu "general" and other parts on anonymous right menu. */
$user_selected_language = api_get_interface_language();
$user_selected_language = api_get_interface_language();
global $home, $home_old;
global $home, $home_old;
@ -471,7 +469,7 @@ function display_anonymous_right_menu() {
echo '< / div > ';
echo '< / div > ';
}
}
// i ncludes for any files to be displayed below anonymous right menu
// I ncludes for any files to be displayed below anonymous right menu.
$home_notice = @(string)file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html');
$home_notice = @(string)file_get_contents($sys_path.$home.'home_notice_'.$user_selected_language.'.html');
if (empty($home_notice)) {
if (empty($home_notice)) {
@ -486,11 +484,11 @@ function display_anonymous_right_menu() {
}
}
/**
/**
* Reacts on a failed login:
* Reacts on a failed login:
* Displays an explanation with a link to the registration form.
* Displays an explanation with a link to the registration form.
*
*
* @version 1.0.1
* @version 1.0.1
*/
*/
function handle_login_failed() {
function handle_login_failed() {
if (!isset($_GET['error'])) {
if (!isset($_GET['error'])) {
$message = get_lang('InvalidId');
$message = get_lang('InvalidId');
@ -523,9 +521,9 @@ function handle_login_failed() {
}
}
/**
/**
* Adds a form to let users login
* Adds a form to let users login
* @version 1.1
* @version 1.1
*/
*/
function display_login_form() {
function display_login_form() {
$form = new FormValidator('formLogin');
$form = new FormValidator('formLogin');
$form->addElement('text', 'login', get_lang('UserName'), array('size' => 17));
$form->addElement('text', 'login', get_lang('UserName'), array('size' => 17));
@ -558,24 +556,24 @@ function display_anonymous_course_list() {
$ctok = $_SESSION['sec_token'];
$ctok = $_SESSION['sec_token'];
$stok = Security::get_token();
$stok = Security::get_token();
//init
// Initialization.
$user_identified = (api_get_user_id() > 0 & & !api_is_anonymous());
$user_identified = (api_get_user_id() > 0 & & !api_is_anonymous());
$web_course_path = api_get_path(WEB_COURSE_PATH);
$web_course_path = api_get_path(WEB_COURSE_PATH);
$category = Database::escape_string($_GET['category']);
$category = Database::escape_string($_GET['category']);
global $setting_show_also_closed_courses;
global $setting_show_also_closed_courses;
// Database table definitions
// Database table definitions.
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
$platformLanguage = api_get_setting('platformLanguage');
$platformLanguage = api_get_setting('platformLanguage');
//get list of courses in category $category
// Get list of courses in category $category.
$sql_get_course_list = "SELECT * FROM $main_course_table cours
$sql_get_course_list = "SELECT * FROM $main_course_table cours
WHERE category_code = '".Database::escape_string($_GET['category'])."'
WHERE category_code = '".Database::escape_string($_GET['category'])."'
ORDER BY title, UPPER(visual_code)";
ORDER BY title, UPPER(visual_code)";
//s howing only the courses of the current access_url_id
// S howing only the courses of the current access_url_id.
global $_configuration;
global $_configuration;
if ($_configuration['multiple_access_urls']) {
if ($_configuration['multiple_access_urls']) {
$url_access_id = api_get_current_access_url_id();
$url_access_id = api_get_current_access_url_id();
@ -596,7 +594,7 @@ function display_anonymous_course_list() {
$platform_visible_courses = '';
$platform_visible_courses = '';
// $setting_show_also_closed_courses
// $setting_show_also_closed_courses
if($user_identified) {
if ($user_identified) {
if ($setting_show_also_closed_courses) {
if ($setting_show_also_closed_courses) {
$platform_visible_courses = '';
$platform_visible_courses = '';
} else {
} else {
@ -618,7 +616,7 @@ function display_anonymous_course_list() {
GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
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
// Showing only the category of courses of the current access_url_id.
global $_configuration;
global $_configuration;
if ($_configuration['multiple_access_urls']) {
if ($_configuration['multiple_access_urls']) {
$url_access_id = api_get_current_access_url_id();
$url_access_id = api_get_current_access_url_id();
@ -645,7 +643,7 @@ function display_anonymous_course_list() {
$category_has_open_courses = category_has_open_courses($catLine['code']);
$category_has_open_courses = category_has_open_courses($catLine['code']);
if ($category_has_open_courses) {
if ($category_has_open_courses) {
// The category contains courses accessible to anonymous visitors
// The category contains courses accessible to anonymous visitors.
$htmlListCat .= '< li > ';
$htmlListCat .= '< li > ';
$htmlListCat .= '< a href = "'.api_get_self().'?category='.$catLine['code'].'" > '.$catLine['name'].'< / a > ';
$htmlListCat .= '< a href = "'.api_get_self().'?category='.$catLine['code'].'" > '.$catLine['name'].'< / a > ';
if (api_get_setting('show_number_of_courses') == 'true') {
if (api_get_setting('show_number_of_courses') == 'true') {
@ -654,21 +652,19 @@ function display_anonymous_course_list() {
$htmlListCat .= "< / li > \n";
$htmlListCat .= "< / li > \n";
$thereIsSubCat = true;
$thereIsSubCat = true;
} elseif ($catLine['children_count'] > 0) {
} elseif ($catLine['children_count'] > 0) {
// The category has children, subcategories
// The category has children, subcategories.
$htmlListCat .= '< li > ';
$htmlListCat .= '< li > ';
$htmlListCat .= '< a href = "'.api_get_self().'?category='.$catLine['code'].'" > '.$catLine['name'].'< / a > ';
$htmlListCat .= '< a href = "'.api_get_self().'?category='.$catLine['code'].'" > '.$catLine['name'].'< / a > ';
$htmlListCat .= "< / li > \n";
$htmlListCat .= "< / li > \n";
$thereIsSubCat = true;
$thereIsSubCat = true;
}
}
/************************************************************************
/* End changed code to eliminate the (0 courses) after empty categories. */
end changed code to eliminate the (0 courses) after empty categories
************************************************************************/
elseif (api_get_setting('show_empty_course_categories') == 'true') {
elseif (api_get_setting('show_empty_course_categories') == 'true') {
$htmlListCat .= '< li > ';
$htmlListCat .= '< li > ';
$htmlListCat .= $catLine['name'];
$htmlListCat .= $catLine['name'];
$htmlListCat .= "< / li > \n";
$htmlListCat .= "< / li > \n";
$thereIsSubCat = true;
$thereIsSubCat = true;
} //e lse don't set thereIsSubCat to true to avoid printing things if not requested
} // E lse don't set thereIsSubCat to true to avoid printing things if not requested.
} else {
} else {
$htmlTitre = '< p > ';
$htmlTitre = '< p > ';
if (api_get_setting('show_back_link_on_top_of_tree') == 'true') {
if (api_get_setting('show_back_link_on_top_of_tree') == 'true') {
@ -709,11 +705,10 @@ function display_anonymous_course_list() {
foreach ($course_list as $course) {
foreach ($course_list as $course) {
// $setting_show_also_closed_courses
// $setting_show_also_closed_courses
if (!$setting_show_also_closed_courses) {
if (!$setting_show_also_closed_courses) {
// If we do not show the closed courses
// If we do not show the closed courses
// we only show the courses that are open to the world (to everybody)
// 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
// 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)) {
if( ($user_identified & & $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
$courses_shown++;
$courses_shown++;
$courses_list_string .= "< li > \n";
$courses_list_string .= "< li > \n";
@ -734,12 +729,12 @@ function display_anonymous_course_list() {
}
}
}
}
// We DO show the closed courses.
// We DO show the closed courses.
// The course is accessible if (link to the course homepage)
// 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)
// 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)
// 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
// 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)
// 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()
// 5. the user is the platform admin api_is_platform_admin().
//
//
else {
else {
$courses_shown++;
$courses_shown++;
@ -774,9 +769,9 @@ function display_anonymous_course_list() {
if (api_get_setting('show_different_course_language') == 'true' & & $course['course_language'] != api_get_setting('platformLanguage')) {
if (api_get_setting('show_different_course_language') == 'true' & & $course['course_language'] != api_get_setting('platformLanguage')) {
$courses_list_string .= ' - '.$course['course_language'];
$courses_list_string .= ' - '.$course['course_language'];
}
}
// We display a subscription link if
// 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
// 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
// 2.
if ($user_identified & & !key_exists($course['code'], $courses_of_user)) {
if ($user_identified & & !key_exists($course['code'], $courses_of_user)) {
if ($course['subscribe'] == '1') {
if ($course['subscribe'] == '1') {
$courses_list_string .= '< form action = "main/auth/courses.php?action=subscribe&category='.Security::remove_XSS($_GET['category']).'" method = "post" > ';
$courses_list_string .= '< form action = "main/auth/courses.php?action=subscribe&category='.Security::remove_XSS($_GET['category']).'" method = "post" > ';
@ -792,10 +787,10 @@ function display_anonymous_course_list() {
}
}
$courses_list_string .= "< / ul > \n";
$courses_list_string .= "< / ul > \n";
} else {
} else {
// echo '< blockquote > ', get_lang('_No_course_publicly_available'), "< / blockquote > \n";
//echo '< blockquote > ', get_lang('_No_course_publicly_available'), "< / blockquote > \n";
}
}
if ($courses_shown > 0) { //o nly display the list of courses and categories if there was more than
if ($courses_shown > 0) { // O nly 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)
// 0 courses visible to the world (we're in the anonymous list here).
echo $courses_list_string;
echo $courses_list_string;
}
}
if ($category != '') {
if ($category != '') {
@ -810,8 +805,8 @@ function display_anonymous_course_list() {
* @return array an array containing all the information of the courses of the given user
* @return array an array containing all the information of the courses of the given user
*/
*/
function get_courses_of_user($user_id) {
function get_courses_of_user($user_id) {
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course = Database::get_main_table(TABLE_MAIN_COURSE);
$table_course_user = Database::get_main_table(TABLE_MAIN_COURSE_USER);
$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
// 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);
$user_id = intval($user_id);
$sql_select_courses = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr,
$sql_select_courses = "SELECT course.code k, course.visual_code vc, course.subscribe subscr, course.unsubscribe unsubscr,
@ -826,7 +821,7 @@ function get_courses_of_user($user_id) {
$result = Database::query($sql_select_courses);
$result = Database::query($sql_select_courses);
$courses = array();
$courses = array();
while ($row = Database::fetch_array($result)) {
while ($row = Database::fetch_array($result)) {
// We only need the database name of the course
// 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']);
$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;
return $courses;