Feature #306 - Cleaning the top-directory php source files.

skala
Ivan Tcholakov 16 years ago
parent 65d6998db5
commit 9f7498f692
  1. 299
      index.php
  2. 23
      newsList.php
  3. 187
      user_portal.php
  4. 13
      webchatdeny.php
  5. 160
      whoisonline.php
  6. 53
      whoisonlinesession.php

@ -25,13 +25,12 @@
*/ */
/** /**
* @package dokeos.main * @package dokeos.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 $ * @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
// gives the login name automatic focus in header.inc.html. // gives the login name automatic focus in header.inc.html.
@ -51,35 +50,40 @@ $cidReset = true;
Included libraries Included libraries
----------------------------------------------------------- -----------------------------------------------------------
*/ */
/** @todo make all the library files consistent, use filename.lib.php and not filename.lib.inc.php */ /** @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 'main/inc/global.inc.php';
include_once (api_get_path(LIBRARY_PATH).'course.lib.php'); include_once api_get_path(LIBRARY_PATH).'course.lib.php';
include_once (api_get_path(LIBRARY_PATH).'debug.lib.inc.php'); include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
include_once (api_get_path(LIBRARY_PATH).'events.lib.inc.php'); include_once api_get_path(LIBRARY_PATH).'events.lib.inc.php';
include_once (api_get_path(LIBRARY_PATH).'system_announcements.lib.php'); include_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php'); include_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
require_once 'main/chat/chat_functions.lib.php'; 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') ? true : false; $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;
/* /*
----------------------------------------------------------- -----------------------------------------------------------
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();
if (!empty($_GET['logout'])) { if (!empty($_GET['logout'])) {
logout(); logout();
} }
/* /*
----------------------------------------------------------- -----------------------------------------------------------
Table definitions Table definitions
@ -103,12 +107,12 @@ 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 consider removing this piece of code because does nothing. * @todo consider removing this piece of code because does nothing.
@ -119,11 +123,13 @@ if (isset($_GET['submitAuth']) && $_GET['submitAuth'] == 1) {
session_destroy(); session_destroy();
die(); die();
} }
//Delete session neccesary for legal terms //Delete session neccesary for legal terms
if (api_get_setting('allow_terms_conditions')=='true') { if (api_get_setting('allow_terms_conditions')=='true') {
unset($_SESSION['update_term_and_condition']); unset($_SESSION['update_term_and_condition']);
unset($_SESSION['info_current_user']); 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 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 * @todo check if this code is used. I think this code is never executed because after clicking the submit button
@ -131,31 +137,32 @@ if (api_get_setting('allow_terms_conditions')=='true') {
* 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 is already authenticated, we now 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
WHERE login_user_id = '".$_user['user_id']."' WHERE login_user_id = '".$_user['user_id']."'
ORDER BY login_date DESC LIMIT 1"; ORDER BY login_date DESC LIMIT 1";
$result_last_login = api_sql_query($sql_last_login, __FILE__, __LINE__); $result_last_login = Database::query($sql_last_login, __FILE__, __LINE__);
if (!$result_last_login) if (!$result_last_login) {
if (Database::num_rows($result_last_login) > 0) { if (Database::num_rows($result_last_login) > 0) {
$user_last_login_datetime = Database::fetch_array($result_last_login); $user_last_login_datetime = Database::fetch_array($result_last_login);
$user_last_login_datetime = $user_last_login_datetime[0]; $user_last_login_datetime = $user_last_login_datetime[0];
api_session_register('user_last_login_datetime'); api_session_register('user_last_login_datetime');
} }
}
mysql_free_result($result_last_login); mysql_free_result($result_last_login);
//event_login(); //event_login();
if (api_is_platform_admin()) { if (api_is_platform_admin()) {
// decode all open event informations and fill the track_c_* tables // decode all open event informations and fill the track_c_* tables
include (api_get_path(LIBRARY_PATH)."stats.lib.inc.php"); include api_get_path(LIBRARY_PATH).'stats.lib.inc.php';
decodeOpenInfos(); decodeOpenInfos();
} }
} }
} // end login -- if($_POST["submitAuth"]) } // end login -- if ($_POST['submitAuth'])
else { else {
// only if login form was not sent because if the form is sent the user was already on the page. // only if login form was not sent because if the form is sent the user was already on the page.
@ -170,6 +177,7 @@ Display :: display_header('', 'dokeos');
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
@ -179,15 +187,15 @@ if (!api_get_user_id()) {
api_plugin('campushomepage_main'); api_plugin('campushomepage_main');
} }
$home= 'home/'; $home = 'home/';
if ($_configuration['multiple_access_urls']==true) { if ($_configuration['multiple_access_urls']) {
$access_url_id = api_get_current_access_url_id(); $access_url_id = api_get_current_access_url_id();
if ($access_url_id != -1){ if ($access_url_id != -1){
$url_info = api_get_access_url($access_url_id); $url_info = api_get_access_url($access_url_id);
// "http://" and the final "/" replaced // "http://" and the final "/" replaced
$url = substr($url_info['url'],7,strlen($url_info['url'])-8); $url = substr($url_info['url'], 7, strlen($url_info['url']) - 8);
$clean_url = replace_dangerous_char($url); $clean_url = replace_dangerous_char($url);
$clean_url = str_replace('/','-',$clean_url); $clean_url = str_replace('/', '-', $clean_url);
$clean_url = $clean_url.'/'; $clean_url = $clean_url.'/';
$home_old = 'home/'; $home_old = 'home/';
$home= 'home/'.$clean_url; $home= 'home/'.$clean_url;
@ -197,35 +205,35 @@ if ($_configuration['multiple_access_urls']==true) {
// Including the page for the news // Including the page for the news
$page_included = false; $page_included = false;
if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['include'])) { if (!empty($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/', $_GET['include'])) {
include ('./'.$home.$_GET['include']); include './'.$home.$_GET['include'];
$page_included = true; $page_included = true;
} else { } else {
if (!empty($_SESSION['user_language_choice'])) { if (!empty($_SESSION['user_language_choice'])) {
$user_selected_language=$_SESSION['user_language_choice']; $user_selected_language = $_SESSION['user_language_choice'];
} elseif(!empty($_SESSION['_user']['language'])) { } elseif (!empty($_SESSION['_user']['language'])) {
$user_selected_language=$_SESSION['_user']['language']; $user_selected_language = $_SESSION['_user']['language'];
} else { } else {
$user_selected_language=api_get_setting('platformLanguage'); $user_selected_language = api_get_setting('platformLanguage');
} }
if(!file_exists($home.'home_news_'.$user_selected_language.'.html')) { if (!file_exists($home.'home_news_'.$user_selected_language.'.html')) {
if (file_exists($home.'home_top.html')) if (file_exists($home.'home_top.html')) {
$home_top_temp=file($home.'home_top.html'); $home_top_temp = file($home.'home_top.html');
else { } else {
$home_top_temp=file($home_old.'home_top.html'); $home_top_temp = file($home_old.'home_top.html');
} }
$home_top_temp=implode('',$home_top_temp); $home_top_temp = implode('', $home_top_temp);
$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);
echo $open; echo $open;
} else { } else {
if(file_exists($home.'home_top_'.$user_selected_language.'.html')) { if (file_exists($home.'home_top_'.$user_selected_language.'.html')) {
$home_top_temp = file_get_contents($home.'home_top_'.$user_selected_language.'.html'); $home_top_temp = file_get_contents($home.'home_top_'.$user_selected_language.'.html');
} else { } else {
$home_top_temp = file_get_contents($home.'home_top.html'); $home_top_temp = file_get_contents($home.'home_top.html');
} }
$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);
echo $open; echo $open;
} }
} }
@ -272,10 +280,10 @@ 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
@ -283,16 +291,16 @@ function logout()
// 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=api_sql_query($sql_last_connection); $q_last_connection = Database::query($sql_last_connection, __FILE__, __LINE__);
if (Database::num_rows($q_last_connection)>0) { if (Database::num_rows($q_last_connection) > 0) {
$i_id_last_connection=Database::result($q_last_connection,0,"login_id"); $i_id_last_connection = Database::result($q_last_connection, 0, 'login_id');
} }
if (!isset($_SESSION['login_as'])) { if (!isset($_SESSION['login_as'])) {
$current_date=date('Y-m-d H:i:s',time()); $current_date = date('Y-m-d H:i:s', time());
$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'";
api_sql_query($s_sql_update_logout_date); Database::query($s_sql_update_logout_date, __FILE__, __LINE__);
} }
LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status
@ -306,7 +314,7 @@ function logout()
if (is_array($extAuthSource[$uinfo['auth_source']])) { if (is_array($extAuthSource[$uinfo['auth_source']])) {
$subarray = $extAuthSource[$uinfo['auth_source']]; $subarray = $extAuthSource[$uinfo['auth_source']];
if (!empty($subarray['logout']) && file_exists($subarray['logout'])) { if (!empty($subarray['logout']) && file_exists($subarray['logout'])) {
include_once($subarray['logout']); include_once ($subarray['logout']);
$logout_function = $uinfo['auth_source'].'_logout'; $logout_function = $uinfo['auth_source'].'_logout';
if (function_exists($logout_function)) { if (function_exists($logout_function)) {
$logout_function($uinfo); $logout_function($uinfo);
@ -329,19 +337,19 @@ function logout()
function category_has_open_courses($category) { function category_has_open_courses($category) {
global $setting_show_also_closed_courses; global $setting_show_also_closed_courses;
$user_identified = (api_get_user_id()>0 && !api_is_anonymous()); $user_identified = (api_get_user_id() > 0 && !api_is_anonymous());
$main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE);
$sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'"; $sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'";
$sql_result = api_sql_query($sql_query, __FILE__, __LINE__); $sql_result = Database::query($sql_query, __FILE__, __LINE__);
while ($course = Database::fetch_array($sql_result)) { while ($course = Database::fetch_array($sql_result)) {
if ($setting_show_also_closed_courses == false) { if (!$setting_show_also_closed_courses) {
if ((api_get_user_id()>0 if ((api_get_user_id() > 0
and $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
or ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { || ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) {
return true; //at least one open course return true; //at least one open course
} }
} 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 (does not matter weither it's open or not because $setting_show_also_closed_courses = true
} }
} }
@ -369,7 +377,7 @@ function display_anonymous_right_menu() {
$platformLanguage = api_get_setting('platformLanguage'); $platformLanguage = api_get_setting('platformLanguage');
if ( !($_user['user_id']) or 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();
@ -378,7 +386,7 @@ function display_anonymous_right_menu() {
echo '<br />'; echo '<br />';
handle_login_failed(); handle_login_failed();
} }
if (api_get_setting('allow_lostpassword') == 'true' OR api_get_setting('allow_registration') == 'true') { if (api_get_setting('allow_lostpassword') == 'true' || api_get_setting('allow_registration') == 'true') {
echo '<div class="menusection"><span class="menusectioncaption">'.get_lang('MenuUser').'</span><ul class="menulist">'; echo '<div class="menusection"><span class="menusectioncaption">'.get_lang('MenuUser').'</span><ul class="menulist">';
if (api_get_setting('allow_registration') <> 'false') { if (api_get_setting('allow_registration') <> 'false') {
echo '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>'; echo '<li><a href="main/auth/inscription.php">'.get_lang('Reg').'</a></li>';
@ -397,29 +405,28 @@ 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
$show_menu = false;
$show_menu=false; $show_create_link = false;
$show_create_link=false; $show_course_link = false;
$show_course_link=false;
$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION["studentview"] != "studentenview"); $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION["studentview"] != "studentenview");
if ($display_add_course_link) { if ($display_add_course_link) {
//display_create_course_link(); //display_create_course_link();
$show_menu=true; $show_menu = true;
$show_create_link=true; $show_create_link = true;
} }
if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
$show_menu=true; $show_menu = true;
$show_course_link=true; $show_course_link = true;
} else { } else {
if (api_get_setting('allow_students_to_browse_courses')=='true') { if (api_get_setting('allow_students_to_browse_courses') == 'true') {
$show_menu=true; $show_menu = true;
$show_course_link=true; $show_course_link = true;
} }
} }
@ -427,10 +434,12 @@ function display_anonymous_right_menu() {
echo "<div class=\"menusection\">"; echo "<div class=\"menusection\">";
echo "<span class=\"menusectioncaption\">".get_lang("MenuUser")."</span>"; echo "<span class=\"menusectioncaption\">".get_lang("MenuUser")."</span>";
echo "<ul class=\"menulist\">"; echo "<ul class=\"menulist\">";
if ($show_create_link) if ($show_create_link) {
display_create_course_link(); display_create_course_link();
if ($show_course_link) }
if ($show_course_link) {
display_edit_course_list_links(); display_edit_course_list_links();
}
echo "</ul>"; echo "</ul>";
echo "</div>"; echo "</div>";
} }
@ -439,8 +448,8 @@ function display_anonymous_right_menu() {
echo "<div class=\"menusection\">"; echo "<div class=\"menusection\">";
echo "<span class=\"menusectioncaption\">".get_lang("MainNavigation")."</span>"; echo "<span class=\"menusectioncaption\">".get_lang("MainNavigation")."</span>";
echo "<ul class=\"menulist\">"; echo "<ul class=\"menulist\">";
foreach($menu_navigation as $section => $navigation_info) { foreach ($menu_navigation as $section => $navigation_info) {
$current = ($section == $GLOBALS['this_section'] ? ' id="current"' : ''); $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
echo '<li'.$current.'>'; echo '<li'.$current.'>';
echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>'; echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
echo '</li>'; echo '</li>';
@ -456,29 +465,25 @@ function display_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;
if (!isset ($user_selected_language)) if (!isset($user_selected_language)) {
{
$user_selected_language = $platformLanguage; $user_selected_language = $platformLanguage;
} }
if (!file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_exists($home.'home_menu.html') && file_get_contents($home.'home_menu.html')!='') if (!file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_exists($home.'home_menu.html') && file_get_contents($home.'home_menu.html') != '') {
{
echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>"; echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>";
echo "<ul class=\"menulist\">"; echo "<ul class=\"menulist\">";
if (file_exists($home.'home_menu.html')) if (file_exists($home.'home_menu.html')) {
include ($home.'home_menu.html'); include ($home.'home_menu.html');
else { } else {
include ($home_old.'home_menu.html'); include ($home_old.'home_menu.html');
} }
echo '</ul>'; echo '</ul>';
echo '</div>'; echo '</div>';
} }
elseif(file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_get_contents($home.'home_menu_'.$user_selected_language.'.html') != '') {
elseif(file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_get_contents($home.'home_menu_'.$user_selected_language.'.html')!='')
{
echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>"; echo "<div class=\"menusection\">", "<span class=\"menusectioncaption\">".get_lang("MenuGeneral")."</span>";
echo "<ul class=\"menulist\">"; echo "<ul class=\"menulist\">";
include($home.'home_menu_'.$user_selected_language.'.html'); include ($home.'home_menu_'.$user_selected_language.'.html');
echo '</ul>'; echo '</ul>';
echo '</div>'; echo '</div>';
} }
@ -491,15 +496,16 @@ function display_anonymous_right_menu() {
// includes for any files to be displayed below anonymous right menu // includes for any files to be displayed below anonymous right menu
if (!file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_exists($home.'home_notice.html') && file_get_contents($home.'home_notice.html')!='') { if (!file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_exists($home.'home_notice.html') && file_get_contents($home.'home_notice.html') != '') {
echo '<div class="note">'; echo '<div class="note">';
if (file_exists($home.'home_notice.html')) if (file_exists($home.'home_notice.html')) {
include ($home.'home_notice.html'); include ($home.'home_notice.html');
else { } else {
include ($home_old.'home_notice.html'); include ($home_old.'home_notice.html');
} }
echo '</div>'; echo '</div>';
} elseif(file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_get_contents($home.'home_notice_'.$user_selected_language.'.html')!='') { }
elseif(file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_get_contents($home.'home_notice_'.$user_selected_language.'.html') != '') {
echo '<div class="note">'; echo '<div class="note">';
include($home.'home_notice_'.$user_selected_language.'.html'); include($home.'home_notice_'.$user_selected_language.'.html');
echo '</div>'; echo '</div>';
@ -528,16 +534,16 @@ function handle_login_failed() {
} }
break; break;
case 'account_expired': case 'account_expired':
$message=get_lang('AccountExpired'); $message = get_lang('AccountExpired');
break; break;
case 'account_inactive': case 'account_inactive':
$message=get_lang('AccountInactive'); $message = get_lang('AccountInactive');
break; break;
case 'user_password_incorrect': case 'user_password_incorrect':
$message=get_lang('InvalidId'); $message = get_lang('InvalidId');
break; break;
case 'access_url_inactive': case 'access_url_inactive':
$message=get_lang('AccountURLInactive'); $message = get_lang('AccountURLInactive');
break; break;
} }
} }
@ -548,20 +554,20 @@ 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));
$form->addElement('password','password',get_lang('Pass'),array('size'=>17)); $form->addElement('password', 'password', get_lang('Pass'), array('size' => 17));
$form->addElement('style_submit_button','submitAuth',get_lang('langEnter'), array('class'=>'login')); $form->addElement('style_submit_button','submitAuth', get_lang('langEnter'), array('class' => 'login'));
$renderer =& $form->defaultRenderer(); $renderer =& $form->defaultRenderer();
$renderer->setElementTemplate('<div><label>{label}</label></div><div>{element}</div>'); $renderer->setElementTemplate('<div><label>{label}</label></div><div>{element}</div>');
$form->display(); $form->display();
if (api_get_setting('openid_authentication')=='true') { if (api_get_setting('openid_authentication') == 'true') {
include_once('main/auth/openid/login.php'); include_once 'main/auth/openid/login.php';
echo '<div>'.openid_form().'</div>'; echo '<div>'.openid_form().'</div>';
} }
} }
/** /**
* Displays a link to the lost password section * Displays a link to the lost password section
*/ */
@ -581,7 +587,7 @@ function display_anonymous_course_list() {
$stok = Security::get_token(); $stok = Security::get_token();
//init //init
$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;
@ -599,18 +605,18 @@ function display_anonymous_course_list() {
//showing only the courses of the current access_url_id //showing only the courses of the current access_url_id
global $_configuration; global $_configuration;
if ($_configuration['multiple_access_urls']==true) { if ($_configuration['multiple_access_urls'] == true) {
$url_access_id = api_get_current_access_url_id(); $url_access_id = api_get_current_access_url_id();
if ($url_access_id !=-1) { if ($url_access_id !=-1) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $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 $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) 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)"; 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."' //removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."'
$sql_result_courses = api_sql_query($sql_get_course_list, __FILE__, __LINE__); $sql_result_courses = Database::query($sql_get_course_list, __FILE__, __LINE__);
while ($course_result = Database::fetch_array($sql_result_courses)) { while ($course_result = Database::fetch_array($sql_result_courses)) {
$course_list[] = $course_result; $course_list[] = $course_result;
@ -642,9 +648,9 @@ function display_anonymous_course_list() {
//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']==true) { if ($_configuration['multiple_access_urls'] == true) {
$url_access_id = api_get_current_access_url_id(); $url_access_id = api_get_current_access_url_id();
if ($url_access_id !=-1) { if ($url_access_id != -1) {
$tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE);
$sqlGetSubCatList = " $sqlGetSubCatList = "
SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse
@ -653,12 +659,12 @@ function display_anonymous_course_list() {
LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) 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 INNER JOIN $tbl_url_rel_course as url_rel_course
ON (url_rel_course.course_code=t3.code) ON (url_rel_course.course_code=t3.code)
WHERE access_url_id = $url_access_id AND t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." 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"; GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name";
} }
} }
$resCats = api_sql_query($sqlGetSubCatList, __FILE__, __LINE__); $resCats = Database::query($sqlGetSubCatList, __FILE__, __LINE__);
$thereIsSubCat = false; $thereIsSubCat = false;
if (Database::num_rows($resCats) > 0) { if (Database::num_rows($resCats) > 0) {
$htmlListCat = "<h4 style=\"margin-top: 0px;\">".get_lang("CatList")."</h4>"."<ul>"; $htmlListCat = "<h4 style=\"margin-top: 0px;\">".get_lang("CatList")."</h4>"."<ul>";
@ -690,14 +696,14 @@ function display_anonymous_course_list() {
$htmlListCat .= $catLine['name']; $htmlListCat .= $catLine['name'];
$htmlListCat .= "</li>\n"; $htmlListCat .= "</li>\n";
$thereIsSubCat = true; $thereIsSubCat = true;
}//else don't set thereIsSubCat to true to avoid printing things if not requested } //else 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') {
$htmlTitre .= "<a href=\"".api_get_self()."\">"."&lt;&lt; ".get_lang("BackToHomePage")."</a>"; $htmlTitre .= "<a href=\"".api_get_self()."\">"."&lt;&lt; ".get_lang("BackToHomePage")."</a>";
} }
if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') <> 'true' && !is_null($catLine['code']))) { if (!is_null($catLine['parent_id']) || (api_get_setting('show_back_link_on_top_of_tree') <> 'true' && !is_null($catLine['code']))) {
$htmlTitre .= "<a href=\"".api_get_self()."?category=".$catLine['parent_id']."\">"."&lt;&lt; ".get_lang("Up")."</a>"; $htmlTitre .= "<a href=\"".api_get_self()."?category=".$catLine['parent_id']."\">"."&lt;&lt; ".get_lang('Up')."</a>";
} }
$htmlTitre .= "</p>\n"; $htmlTitre .= "</p>\n";
if ($category != "" && !is_null($catLine['code'])) { if ($category != "" && !is_null($catLine['code'])) {
@ -729,27 +735,27 @@ function display_anonymous_course_list() {
$courses_of_user = get_courses_of_user(api_get_user_id()); $courses_of_user = get_courses_of_user(api_get_user_id());
} }
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==false) { if ($setting_show_also_closed_courses == false) {
// 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) OR ($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";
$courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">".$course['title']."</a><br />"; $courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">".$course['title']."</a><br />";
if (api_get_setting("display_coursecode_in_courselist") == "true") { if (api_get_setting('display_coursecode_in_courselist') == 'true') {
$courses_list_string .= $course['visual_code']; $courses_list_string .= $course['visual_code'];
} }
if (api_get_setting("display_coursecode_in_courselist") == "true" AND api_get_setting("display_teacher_in_courselist") == "true") { if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
$courses_list_string .= " - "; $courses_list_string .= ' - ';
} }
if (api_get_setting("display_teacher_in_courselist") == "true") { if (api_get_setting('display_teacher_in_courselist') == 'true') {
$courses_list_string .= $course['tutor_name']; $courses_list_string .= $course['tutor_name'];
} }
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'];
} }
$courses_list_string .= "</li>\n"; $courses_list_string .= "</li>\n";
@ -766,41 +772,40 @@ function display_anonymous_course_list() {
else { else {
$courses_shown++; $courses_shown++;
$courses_list_string .= "<li>\n"; $courses_list_string .= "<li>\n";
if ( $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
OR ($user_identified AND $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
OR ($user_identified AND key_exists($course['code'],$courses_of_user) AND $course['visibility'] <> COURSE_VISIBILITY_CLOSED) || ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
OR $courses_of_user[$course['code']]['status'] == '1' || $courses_of_user[$course['code']]['status'] == '1'
OR api_is_platform_admin()) { || api_is_platform_admin()) {
$courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">"; $courses_list_string .= "<a href=\"".$web_course_path.$course['directory']."/\">";
} }
$courses_list_string .= $course['title']; $courses_list_string .= $course['title'];
if ( $course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD if ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD
OR ($user_identified AND $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) || ($user_identified && $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM)
OR ($user_identified AND key_exists($course['code'],$courses_of_user) AND $course['visibility'] <> COURSE_VISIBILITY_CLOSED) || ($user_identified && key_exists($course['code'], $courses_of_user) && $course['visibility'] != COURSE_VISIBILITY_CLOSED)
OR $courses_of_user[$course['code']]['status'] == '1' || $courses_of_user[$course['code']]['status'] == '1'
OR api_is_platform_admin()) { || api_is_platform_admin()) {
$courses_list_string .="</a><br />"; $courses_list_string .= "</a><br />";
} }
if (api_get_setting("display_coursecode_in_courselist") == "true") { if (api_get_setting('display_coursecode_in_courselist') == 'true') {
$courses_list_string .= $course['visual_code']; $courses_list_string .= $course['visual_code'];
} }
if (api_get_setting("display_coursecode_in_courselist") == "true" AND api_get_setting("display_teacher_in_courselist") == "true") { if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
$courses_list_string .= " - "; $courses_list_string .= ' - ';
} }
if (api_get_setting("display_teacher_in_courselist") == "true") if (api_get_setting('display_teacher_in_courselist') == 'true') {
{
$courses_list_string .= $course['tutor_name']; $courses_list_string .= $course['tutor_name'];
} }
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'];
} }
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 AND !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=".$_GET['category']."\" method=\"post\">"; $courses_list_string .= "<form action=\"main/auth/courses.php?action=subscribe&category=".$_GET['category']."\" method=\"post\">";
$courses_list_string .= '<input type="hidden" name="sec_token" value="'.$stok.'">'; $courses_list_string .= '<input type="hidden" name="sec_token" value="'.$stok.'">';
@ -821,8 +826,8 @@ function display_anonymous_course_list() {
// 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 != '') {
echo "<p>", "<a href=\"".api_get_self()."\"><b></b> ", Display :: return_icon('back.png', get_lang('BackToHomePage')),get_lang("BackToHomePage"), "</a>", "</p>\n"; echo "<p>", "<a href=\"".api_get_self()."\"> ", Display :: return_icon('back.png', get_lang('BackToHomePage')), get_lang("BackToHomePage"), "</a>", "</p>\n";
} }
} }
@ -836,9 +841,9 @@ 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,
course.title i, course.tutor_name t, course.db_name db, course.directory dir, course_rel_user.status status, 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 course_rel_user.sort sort, course_rel_user.user_course_cat user_course_cat
FROM $table_course course, FROM $table_course course,
@ -846,10 +851,10 @@ function get_courses_of_user($user_id) {
WHERE course.code = course_rel_user.course_code WHERE course.code = course_rel_user.course_code
AND course_rel_user.user_id = '".$user_id."' AND course_rel_user.user_id = '".$user_id."'
ORDER BY course_rel_user.sort ASC"; ORDER BY course_rel_user.sort ASC";
$result = api_sql_query($sql_select_courses,__FILE__,__LINE__); $result = Database::query($sql_select_courses, __FILE__, __LINE__);
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;
} }

@ -4,34 +4,23 @@
* Created on 30 mai 2006 by Elixir Interactive http://www.elixir-interactive.com * Created on 30 mai 2006 by Elixir Interactive http://www.elixir-interactive.com
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = array ('courses', 'index'); $language_file = array ('courses', 'index');
// including necessary files // including necessary files
include_once('main/inc/global.inc.php'); include_once 'main/inc/global.inc.php';
include_once (api_get_path(LIBRARY_PATH).'/system_announcements.lib.php'); include_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
$tool_name = get_lang("SystemAnnouncements"); $tool_name = get_lang("SystemAnnouncements");
Display::display_header($tool_name); Display::display_header($tool_name);
if(isset($_GET['start'])) $start = isset($_GET['start']) ? (int)$_GET['start'] : $start = 0;
{
$start = (int)$_GET['start'];
}
else
{
$start = 0;
}
if (isset($_user['user_id'])) if (isset($_user['user_id'])) {
{
$visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT; $visibility = api_is_allowed_to_create_course() ? VISIBLE_TEACHER : VISIBLE_STUDENT;
SystemAnnouncementManager :: display_all_announcements($visibility, $announcement, $start, $_user['user_id']); SystemAnnouncementManager :: display_all_announcements($visibility, $announcement, $start, $_user['user_id']);
} } else {
else
{
SystemAnnouncementManager :: display_all_announcements(VISIBLE_GUEST, $announcement, $start); SystemAnnouncementManager :: display_all_announcements(VISIBLE_GUEST, $announcement, $start);
} }
Display::display_footer(); Display::display_footer();
?>

@ -44,8 +44,7 @@ define('SCRIPTVAL_NewEntriesOfTheDayOfLastLogin', 5);
define('SCRIPTVAL_NoTimeLimit', 6); define('SCRIPTVAL_NoTimeLimit', 6);
// End 'don't change' section // End 'don't change' section
// Language files that should be included
// name of the language file that needs to be included
$language_file = array ('courses', 'index'); $language_file = array ('courses', 'index');
$cidReset = true; /* Flag forcing the 'current course' reset, $cidReset = true; /* Flag forcing the 'current course' reset,
@ -55,12 +54,12 @@ $cidReset = true; /* Flag forcing the 'current course' reset,
Included libraries Included libraries
----------------------------------------------------------- -----------------------------------------------------------
*/ */
include_once ('./main/inc/global.inc.php'); include_once './main/inc/global.inc.php';
include_once (api_get_path(LIBRARY_PATH).'course.lib.php'); include_once api_get_path(LIBRARY_PATH).'course.lib.php';
include_once (api_get_path(LIBRARY_PATH).'debug.lib.inc.php'); include_once api_get_path(LIBRARY_PATH).'debug.lib.inc.php';
include_once (api_get_path(LIBRARY_PATH).'system_announcements.lib.php'); include_once api_get_path(LIBRARY_PATH).'system_announcements.lib.php';
include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); include_once api_get_path(LIBRARY_PATH).'groupmanager.lib.php';
include_once (api_get_path(LIBRARY_PATH).'usermanager.lib.php'); include_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
api_block_anonymous_users(); // only users who are logged in can proceed api_block_anonymous_users(); // only users who are logged in can proceed
@ -82,7 +81,7 @@ $main_category_table = Database :: get_main_table(TABLE_MAIN_CATEGORY);
----------------------------------------------------------- -----------------------------------------------------------
*/ */
// ---- Course list options ---- // ---- Course list options ----
define('CONFVAL_showCourseLangIfNotSameThatPlatform', TRUE); define('CONFVAL_showCourseLangIfNotSameThatPlatform', true);
// Preview of course content // Preview of course content
// to disable all: set CONFVAL_maxTotalByCourse = 0 // to disable all: set CONFVAL_maxTotalByCourse = 0
// to enable all: set e.g. CONFVAL_maxTotalByCourse = 5 // to enable all: set e.g. CONFVAL_maxTotalByCourse = 5
@ -109,20 +108,16 @@ define("CONFVAL_limitPreviewTo", SCRIPTVAL_NewEntriesOfTheDayOfLastLogin);
/*if(api_is_allowed_to_create_course() && !isset($_GET['sessionview'])){ /*if(api_is_allowed_to_create_course() && !isset($_GET['sessionview'])){
$nosession = true; $nosession = true;
} } else {
else {
$nosession = false; $nosession = false;
}*/ }*/
$nosession=false; $nosession = false;
if(api_get_setting('use_session_mode')=='true' && !$nosession) { if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
if (isset($_GET['inactives'])){ $display_actives = !isset($_GET['inactives']);
$display_actives = false;
} else {
$display_actives = true;
}
} }
$nameTools = get_lang('MyCourses'); $nameTools = get_lang('MyCourses');
$this_section = SECTION_COURSES; $this_section = SECTION_COURSES;
@ -251,12 +246,12 @@ function get_personal_course_list($user_id) {
} }
/* /*
----------------------------------------------------------- -----------------------------------------------------------
Display functions Display functions
----------------------------------------------------------- -----------------------------------------------------------
*/ */
/** /**
* Warning: this function defines a global. * Warning: this function defines a global.
* @todo use the correct get_path function * @todo use the correct get_path function
@ -265,6 +260,7 @@ function display_admin_links() {
global $rootAdminWeb; global $rootAdminWeb;
echo "<li><a href=\"".$rootAdminWeb."\">".get_lang('PlatformAdmin')."</a></li>"; echo "<li><a href=\"".$rootAdminWeb."\">".get_lang('PlatformAdmin')."</a></li>";
} }
/** /**
* Enter description here... * Enter description here...
* *
@ -272,6 +268,7 @@ function display_admin_links() {
function display_create_course_link() { function display_create_course_link() {
echo "<li><a href=\"main/create_course/add_course.php\">".get_lang('CourseCreate')."</a></li>"; echo "<li><a href=\"main/create_course/add_course.php\">".get_lang('CourseCreate')."</a></li>";
} }
/** /**
* Enter description here... * Enter description here...
* *
@ -293,10 +290,10 @@ function display_digest($toolsList, $digest, $orderKey, $courses) {
// // // LEVEL 1 // // // // // // LEVEL 1 // // //
reset($digest); reset($digest);
echo "<br /><br />\n"; echo "<br /><br />\n";
while (list ($key1) = each($digest)) { while (list($key1) = each($digest)) {
if (is_array($digest[$key1])) { if (is_array($digest[$key1])) {
// // // Title of LEVEL 1 // // // // // // Title of LEVEL 1 // // //
echo "<b>\n"; echo "<strong>\n";
if ($orderKey[0] == 'keyTools') { if ($orderKey[0] == 'keyTools') {
$tools = $key1; $tools = $key1;
echo $toolsList[$key1]['name']; echo $toolsList[$key1]['name'];
@ -306,7 +303,7 @@ function display_digest($toolsList, $digest, $orderKey, $courses) {
} elseif ($orderKey[0] == 'keyTime') { } elseif ($orderKey[0] == 'keyTime') {
echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($digest[$key1])); echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($digest[$key1]));
} }
echo "</b>\n"; echo "</strong>\n";
// // // End Of Title of LEVEL 1 // // // // // // End Of Title of LEVEL 1 // // //
// // // LEVEL 2 // // // // // // LEVEL 2 // // //
reset($digest[$key1]); reset($digest[$key1]);
@ -428,56 +425,55 @@ function get_logged_user_course_html($my_course) {
$s_course_status=$my_course['s']; $s_course_status=$my_course['s'];
$s_htlm_status_icon=""; $s_htlm_status_icon = '';
if ($s_course_status==1) { if ($s_course_status == 1) {
$s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher')); $s_htlm_status_icon=Display::return_icon('teachers.gif', get_lang('Teacher'));
} }
if ($s_course_status==2) { if ($s_course_status == 2) {
$s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach')); $s_htlm_status_icon=Display::return_icon('coachs.gif', get_lang('GeneralCoach'));
} }
if ($s_course_status==5) { if ($s_course_status == 5) {
$s_htlm_status_icon=Display::return_icon('students.gif', get_lang('Student')); $s_htlm_status_icon = Display::return_icon('students.gif', get_lang('Student'));
} }
//display course entry //display course entry
$result.="\n\t"; $result .= "\n\t";
$result .= '<li class="courses"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>'; $result .= '<li class="courses"><div class="coursestatusicons">'.$s_htlm_status_icon.'</div>';
//show a hyperlink to the course, unless the course is closed and user is not course admin //show a hyperlink to the course, unless the course is closed and user is not course admin
if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) { if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) {
if(api_get_setting('use_session_mode')=='true' && !$nosession) { if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
if(empty($my_course['id_session'])) { if (empty($my_course['id_session'])) {
$my_course['id_session'] = 0; $my_course['id_session'] = 0;
} }
if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') { if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start == '0000-00-00') {
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>'; $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/?id_session='.$my_course['id_session'].'">'.$course_display_title.'</a>';
} }
} else { } else {
$result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>'; $result .= '<a href="'.api_get_path(WEB_COURSE_PATH).$course_directory.'/">'.$course_display_title.'</a>';
} }
} else { } else {
$result .= $course_display_title." "." ".get_lang('CourseClosed').""; $result .= $course_display_title.' '.get_lang('CourseClosed');
} }
// show the course_code and teacher if chosen to display this // show the course_code and teacher if chosen to display this
if (api_get_setting('display_coursecode_in_courselist') == 'true' OR api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_coursecode_in_courselist') == 'true' || api_get_setting('display_teacher_in_courselist') == 'true') {
$result .= '<br />'; $result .= '<br />';
} }
if (api_get_setting('display_coursecode_in_courselist') == 'true') { if (api_get_setting('display_coursecode_in_courselist') == 'true') {
$result .= $course_display_code; $result .= $course_display_code;
} }
if (api_get_setting('display_coursecode_in_courselist') == 'true' AND api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_coursecode_in_courselist') == 'true' && api_get_setting('display_teacher_in_courselist') == 'true') {
$result .= ' &ndash; '; $result .= ' &ndash; ';
} }
if (api_get_setting('display_teacher_in_courselist') == 'true') { if (api_get_setting('display_teacher_in_courselist') == 'true') {
$result .= $course_teacher; $result .= $course_teacher;
if(!empty($course_teacher_email)) { if (!empty($course_teacher_email)) {
$result .= ' ('.$course_teacher_email.')'; $result .= ' ('.$course_teacher_email.')';
} }
} }
$current_course_settings = CourseManager :: get_access_settings($my_course['k']); $current_course_settings = CourseManager :: get_access_settings($my_course['k']);
// display the what's new icons // display the what's new icons
$result .= show_notification($my_course); $result .= show_notification($my_course);
@ -495,7 +491,7 @@ function get_logged_user_course_html($my_course) {
} }
$result .= '</li>'; $result .= '</li>';
$result .= '<ul>'; $result .= '<ul>';
reset($digest[$thisCourseSysCode][$key2]); reset ($digest[$thisCourseSysCode][$key2]);
while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) { while (list ($key3, $dataFromCourse) = each($digest[$thisCourseSysCode][$key2])) {
$result .= '<li>'; $result .= '<li>';
if ($orderKey[2] == 'keyTools') { if ($orderKey[2] == 'keyTools') {
@ -522,7 +518,7 @@ function get_logged_user_course_html($my_course) {
$result .= '</li>'; $result .= '</li>';
if (api_get_setting('use_session_mode')=='true' && !$nosession) { if (api_get_setting('use_session_mode') == 'true' && !$nosession) {
$session = ''; $session = '';
$active = false; $active = false;
if (!empty($my_course['session_name'])) { if (!empty($my_course['session_name'])) {
@ -542,19 +538,19 @@ function get_logged_user_course_html($my_course) {
$session['title'] = $my_course['session_name']; $session['title'] = $my_course['session_name'];
if ( $my_course['date_start']=='0000-00-00' ) { if ( $my_course['date_start']=='0000-00-00' ) {
$session['dates'] = get_lang('WithoutTimeLimits'); $session['dates'] = get_lang('WithoutTimeLimits');
if ( api_get_setting('show_session_coach') === 'true' ) { if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']); $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
} }
$active = true; $active = true;
} else { } else {
$session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end']; $session ['dates'] = ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end'];
if ( api_get_setting('show_session_coach') === 'true' ) { if (api_get_setting('show_session_coach') === 'true') {
$session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']); $session['coach'] = get_lang('GeneralCoach').': '.api_get_person_name($sessioncoach['firstname'], $sessioncoach['lastname']);
} }
$active = ($date_start <= $now && $date_end >= $now)?true:false; $active = $date_start <= $now && $date_end >= $now;
} }
} }
$output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active); $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active' => $active);
} else { } else {
$output = array ($my_course['user_course_cat'], $result); $output = array ($my_course['user_course_cat'], $result);
} }
@ -584,9 +580,10 @@ function show_notification($my_course) {
$oldestTrackDate = "3000-01-01 00:00:00"; $oldestTrackDate = "3000-01-01 00:00:00";
while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) { while ($lastTrackInCourse = Database::fetch_array($resLastTrackInCourse)) {
$lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date']; $lastTrackInCourseDate[$lastTrackInCourse['access_tool']] = $lastTrackInCourse['access_date'];
if ($oldestTrackDate > $lastTrackInCourse['access_date']) if ($oldestTrackDate > $lastTrackInCourse['access_date']) {
$oldestTrackDate = $lastTrackInCourse['access_date']; $oldestTrackDate = $lastTrackInCourse['access_date'];
} }
}
// get the last edits of all tools of this course // get the last edits of all tools of this course
$sql = "SELECT tet.*, tet.lastedit_date last_date, tet.tool tool, tet.ref ref, $sql = "SELECT tet.*, tet.lastedit_date last_date, tet.tool tool, tet.ref ref,
tet.lastedit_type type, tet.to_group_id group_id, tet.lastedit_type type, tet.to_group_id group_id,
@ -610,8 +607,7 @@ function show_notification($my_course) {
|| $item_property['to_user_id'] == $user_id) || $item_property['to_user_id'] == $user_id)
&& ($item_property['visibility'] == '1' && ($item_property['visibility'] == '1'
|| ($my_course['s'] == '1' && $item_property['visibility'] == '0') || ($my_course['s'] == '1' && $item_property['visibility'] == '0')
|| !isset ($item_property['visibility']))) || !isset ($item_property['visibility']))) {
{
$notifications[$item_property['tool']] = $item_property; $notifications[$item_property['tool']] = $item_property;
} }
} }
@ -636,7 +632,6 @@ function show_notification($my_course) {
*/ */
function get_user_course_categories() { function get_user_course_categories() {
global $_user; global $_user;
$output = array(); $output = array();
$table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY); $table_category = Database::get_user_personal_table(TABLE_USER_COURSE_CATEGORY);
$sql = "SELECT * FROM ".$table_category." WHERE user_id='".Database::escape_string($_user['user_id'])."'"; $sql = "SELECT * FROM ".$table_category." WHERE user_id='".Database::escape_string($_user['user_id'])."'";
@ -680,6 +675,7 @@ if ($maxCourse > 0) {
echo ' <div class="maincontent" id="maincontent">'; // start of content for logged in users echo ' <div class="maincontent" id="maincontent">'; // start of content for logged in users
// Plugins for the my courses main area // Plugins for the my courses main area
api_plugin('mycourses_main'); api_plugin('mycourses_main');
/* /*
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
System Announcements System Announcements
@ -744,12 +740,11 @@ if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['in
// take care mysql -> DATE_FORMAT(time,format) php -> date(format,date) // take care mysql -> DATE_FORMAT(time,format) php -> date(format,date)
$sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date("Y m d", $_user["lastLogin"])."'"; $sqlGetLastAnnouncements .= "WHERE DATE_FORMAT(end_date,'%Y %m %d') >= '".date("Y m d", $_user["lastLogin"])."'";
} }
$sqlGetLastAnnouncements .= "ORDER BY end_date DESC $sqlGetLastAnnouncements .= "ORDER BY end_date DESC LIMIT ".$maxValvas;
LIMIT ".$maxValvas;
$resGetLastAnnouncements = api_sql_query($sqlGetLastAnnouncements, __FILE__, __LINE__); $resGetLastAnnouncements = api_sql_query($sqlGetLastAnnouncements, __FILE__, __LINE__);
if ($resGetLastAnnouncements) { if ($resGetLastAnnouncements) {
while ($annoncement = Database::fetch_array($resGetLastAnnouncements)) { while ($annoncement = Database::fetch_array($resGetLastAnnouncements)) {
$keyTools = "valvas"; $keyTools = 'valvas';
$keyTime = $annoncement['publicationDate']; $keyTime = $annoncement['publicationDate'];
$keyCourse = $thisCourseSysCode; $keyCourse = $thisCourseSysCode;
$digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = htmlspecialchars(api_substr(strip_tags($annoncement["content"]), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset); $digest[$$orderKey[0]][$$orderKey[1]][$$orderKey[2]][] = htmlspecialchars(api_substr(strip_tags($annoncement["content"]), 0, CONFVAL_NB_CHAR_FROM_CONTENT), ENT_QUOTES, $charset);
@ -773,7 +768,7 @@ if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['in
// collect from agenda, but only if tool is visible for the course // collect from agenda, but only if tool is visible for the course
if ($result && $thisAgenda > 0 && Database::num_rows($result) > 0) { if ($result && $thisAgenda > 0 && Database::num_rows($result) > 0) {
$tableCal = $courseTablePrefix.$thisCourseDbName.$_configuration['db_glue']."calendar_event"; $tableCal = $courseTablePrefix.$thisCourseDbName.$_configuration['db_glue']."calendar_event";
$sqlGetNextAgendaEvent = "SELECT start_date , title content, start_time $sqlGetNextAgendaEvent = "SELECT start_date, title content, start_time
FROM $tableCal FROM $tableCal
WHERE start_date >= CURDATE() WHERE start_date >= CURDATE()
ORDER BY start_date, start_time ORDER BY start_date, start_time
@ -799,24 +794,24 @@ if (!empty ($_GET['include']) && preg_match('/^[a-zA-Z0-9_-]*\.html$/',$_GET['in
} //end while mycourse... } //end while mycourse...
} }
if ( is_array($list) ) { if (is_array($list)) {
//Courses whithout sessions //Courses whithout sessions
$old_user_category = 0; $old_user_category = 0;
foreach($list as $key=>$value) { foreach ($list as $key => $value) {
if ( empty($value[2]) ) { //if out of any session if (empty($value[2])) { //if out of any session
$userdefined_categories = get_user_course_categories(); $userdefined_categories = get_user_course_categories();
echo '<ul class="courseslist">'; echo '<ul class="courseslist">';
if ($old_user_category<>$value[0]) { if ($old_user_category<>$value[0]) {
if ($key<>0 OR $value[0]<>0) {// there are courses in the previous category if ($key <> 0 || $value[0] <> 0) {// there are courses in the previous category
echo "\n</ul>"; echo "\n</ul>";
} }
echo "\n\n\t<ul class=\"user_course_category\"><li>".$userdefined_categories[$value[0]]."</li></ul>\n"; echo "\n\n\t<ul class=\"user_course_category\"><li>".$userdefined_categories[$value[0]]."</li></ul>\n";
if ($key<>0 OR $value[0]<>0){ // there are courses in the previous category if ($key<>0 OR $value[0]<>0){ // there are courses in the previous category
echo "<ul class=\"courseslist\">"; echo "<ul class=\"courseslist\">";
} }
$old_user_category=$value[0]; $old_user_category = $value[0];
} }
echo $value[1]; echo $value[1];
@ -824,21 +819,19 @@ if ( is_array($list) ) {
} }
} }
$listActives = $listInactives = $listCourses = array(); $listActives = $listInactives = $listCourses = array();
foreach ( $list as $key=>$value ) { foreach ($list as $key => $value) {
if ( $value['active'] ) { //if the session is still active (as told by get_logged_user_course_html()) if ($value['active']) { //if the session is still active (as told by get_logged_user_course_html())
$listActives[] = $value; $listActives[] = $value;
} else if ( !empty($value[2]) ) { //if there is a session but it is not active } else if (!empty($value[2])) { //if there is a session but it is not active
$listInactives[] = $value; $listInactives[] = $value;
} }
} }
$old_user_category = 0; $old_user_category = 0;
$userdefined_categories = get_user_course_categories(); $userdefined_categories = get_user_course_categories();
if(count($listActives)>0 && $display_actives){ if (count($listActives) > 0 && $display_actives) {
echo "<ul class=\"courseslist\">\n"; echo "<ul class=\"courseslist\">\n";
foreach ($listActives as $key => $value) { foreach ($listActives as $key => $value) {
if (!empty($value[2])) { if (!empty($value[2])) {
if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) { if ((isset($old_session) && $old_session != $value[2]) or ((!isset($old_session)) && isset($value[2]))) {
@ -848,25 +841,20 @@ if ( is_array($list) ) {
} }
echo '<ul class="session_box">' . echo '<ul class="session_box">' .
'<li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>'; '<li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>';
if ( !empty($value[3]['coach']) ) { if (!empty($value[3]['coach'])) {
echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>'; echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>';
} }
echo "</ul>\n"; echo "</ul>\n";
echo '<ul class="session_course_item">'; echo '<ul class="session_course_item">';
} }
} }
echo $value[1]; echo $value[1];
} }
echo "\n</ul><br /><br />\n"; echo "\n</ul><br /><br />\n";
} }
if (count($listInactives)>0 && !$display_actives) { if (count($listInactives) > 0 && !$display_actives) {
echo '<ul class="sessions_list_inactive">'; echo '<ul class="sessions_list_inactive">';
foreach ($listInactives as $key => $value) { foreach ($listInactives as $key => $value) {
if (!empty($value[2])) { if (!empty($value[2])) {
if ($old_session != $value[2]) { if ($old_session != $value[2]) {
@ -876,23 +864,21 @@ if ( is_array($list) ) {
} }
echo '<ul class="session_box">' . echo '<ul class="session_box">' .
'<li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>'; '<li class="session_box_title">'.$value[3]['title'].' '.$value[3]['dates'].'</li>';
if ( !empty($value[3]['coach']) ) { if (!empty($value[3]['coach'])) {
echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>'; echo '<li class="session_box_coach">'.$value[3]['coach'].'</li>';
} }
echo "</ul>\n"; echo "</ul>\n";
echo '<ul>'; echo '<ul>';
} }
} }
echo $value[1]; echo $value[1];
} }
echo "\n</ul><br /><br />\n"; echo "\n</ul><br /><br />\n";
} }
} }
echo '</div>'; // end of content section echo '</div>'; // end of content section
// Register whether full admin or null admin course // Register whether full admin or null admin course
// by course through an array dbname x user status // by course through an array dbname x user status
api_session_register('status'); api_session_register('status');
@ -906,43 +892,46 @@ echo ' <div class="menu">';
// api_display_language_form(); // moved to the profile page. // api_display_language_form(); // moved to the profile page.
$show_menu=false; $show_menu = false;
$show_create_link=false; $show_create_link = false;
$show_course_link=false; $show_course_link = false;
$show_digest_link=false; $show_digest_link = false;
$display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION["studentview"] != "studentenview"); $display_add_course_link = api_is_allowed_to_create_course() && ($_SESSION['studentview'] != 'studentenview');
if ($display_add_course_link) { if ($display_add_course_link) {
$show_menu=true; $show_menu = true;
$show_create_link=true; $show_create_link = true;
} }
if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) { if (api_is_platform_admin() || api_is_course_admin() || api_is_allowed_to_create_course()) {
$show_menu=true; $show_menu = true;
$show_course_link=true; $show_course_link = true;
} else { } else {
if (api_get_setting('allow_students_to_browse_courses')=='true') { if (api_get_setting('allow_students_to_browse_courses')=='true') {
$show_menu=true; $show_menu = true;
$show_course_link=true; $show_course_link = true;
} }
} }
if(isset($toolsList) and is_array($toolsList) and isset($digest)) { if (isset($toolsList) and is_array($toolsList) and isset($digest)) {
$show_digest_link=true; $show_digest_link = true;
$show_menu=true; $show_menu = true;
} }
// My account section // My account section
if ($show_menu){ if ($show_menu) {
echo '<div class="menusection">'; echo '<div class="menusection">';
echo '<span class="menusectioncaption">'.get_lang('MenuUser').'</span>'; echo '<span class="menusectioncaption">'.get_lang('MenuUser').'</span>';
echo '<ul class="menulist">'; echo '<ul class="menulist">';
if ($show_create_link) if ($show_create_link) {
display_create_course_link(); display_create_course_link();
if ($show_course_link) }
if ($show_course_link) {
display_edit_course_list_links(); display_edit_course_list_links();
if ($show_digest_link) }
if ($show_digest_link) {
display_digest($toolsList, $digest, $orderKey, $courses); display_digest($toolsList, $digest, $orderKey, $courses);
}
echo '</ul>'; echo '</ul>';
echo '</div>'; echo '</div>';
} }
@ -954,7 +943,7 @@ if (!empty($menu_navigation)) {
echo '<span class="menusectioncaption">'.get_lang('MainNavigation').'</span>'; echo '<span class="menusectioncaption">'.get_lang('MainNavigation').'</span>';
echo '<ul class="menulist">'; echo '<ul class="menulist">';
foreach ($menu_navigation as $section => $navigation_info) { foreach ($menu_navigation as $section => $navigation_info) {
$current = ($section == $GLOBALS['this_section'] ? ' id="current"' : ''); $current = $section == $GLOBALS['this_section'] ? ' id="current"' : '';
echo '<li'.$current.'>'; echo '<li'.$current.'>';
echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>'; echo '<a href="'.$navigation_info['url'].'" target="_self">'.$navigation_info['title'].'</a>';
echo '</li>'; echo '</li>';
@ -964,7 +953,6 @@ if (!empty($menu_navigation)) {
echo '</div>'; echo '</div>';
} }
// plugins for the my courses menu // plugins for the my courses menu
if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu'])) { if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu'])) {
echo '<div class="note">'; echo '<div class="note">';
@ -972,18 +960,18 @@ if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu']))
echo '</div>'; echo '</div>';
} }
if (api_get_setting('allow_reservation')=='true' && api_is_allowed_to_create_course() ){ if (api_get_setting('allow_reservation') == 'true' && api_is_allowed_to_create_course() ){
//include_once('main/reservation/rsys.php'); //include_once('main/reservation/rsys.php');
echo '<div class="menusection">'; echo '<div class="menusection">';
echo '<span class="menusectioncaption">'.get_lang('Booking').'</span>'; echo '<span class="menusectioncaption">'.get_lang('Booking').'</span>';
echo '<ul class="menulist">'; echo '<ul class="menulist">';
echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br/>'; echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
//echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br/>'; //echo '<a href="main/reservation/reservation.php">'.get_lang('ManageReservations').'</a><br />';
/*require_once('main/reservation/rsys.php'); /*require_once('main/reservation/rsys.php');
if(api_is_platform_admin() || Rsys :: check_user_status() == 1) { // Only for admins & teachers... if(api_is_platform_admin() || Rsys :: check_user_status() == 1) { // Only for admins & teachers...
echo '<a href="main/reservation/m_item.php">'.get_lang('ManageItems').'</a><br/>'; echo '<a href="main/reservation/m_item.php">'.get_lang('ManageItems').'</a><br />';
echo '<a href="main/reservation/m_reservation.php">'.get_lang('ManageReservationPeriods').'</a><br/>'; echo '<a href="main/reservation/m_reservation.php">'.get_lang('ManageReservationPeriods').'</a><br />';
} }
*/ */
echo '</ul>'; echo '</ul>';
@ -996,7 +984,7 @@ if (api_get_setting('search_enabled') == 'true') {
$search_btn = get_lang('Search'); $search_btn = get_lang('Search');
$search_text_default = get_lang('YourTextHere'); $search_text_default = get_lang('YourTextHere');
echo <<<EOD echo <<<EOD
<br/> <br />
<form action="main/search/" method="post"> <form action="main/search/" method="post">
&nbsp;&nbsp;<input type="text" id="query" size="15" name="query" value="" /> &nbsp;&nbsp;<input type="text" id="query" size="15" name="query" value="" />
&nbsp;&nbsp;<button class="save" type="submit" name="submit" value="$search_btn"/>$search_btn </button> &nbsp;&nbsp;<button class="save" type="submit" name="submit" value="$search_btn"/>$search_btn </button>
@ -1006,5 +994,6 @@ EOD;
} }
echo '</div>'; // end of menu echo '</div>'; // end of menu
//footer //footer
Display :: display_footer(); Display :: display_footer();

@ -12,22 +12,22 @@
*/ */
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = "index"; $language_file = 'index';
// including necessary files // including necessary files
include_once('./main/inc/global.inc.php'); include_once './main/inc/global.inc.php';
// table definitions // table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER); $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
if (isset($_user['user_id']) && $_user['user_id']!='') { if (isset($_user['user_id']) && $_user['user_id'] != '') {
$_user['user_id'] = intval($_user['user_id']); $_user['user_id'] = intval($_user['user_id']);
$sql="update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='DENIED' where (user_id = ".$_user['user_id'].")"; $sql = "update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='DENIED' where (user_id = ".$_user['user_id'].")";
$result=api_sql_query($sql,__FILE__,__LINE__); $result = Database::query($sql, __FILE__, __LINE__);
} }
Display::display_header(); Display::display_header();
$message=get_lang("RequestDenied")."<br><br><a href='javascript:history.back()'>".get_lang("Back")."</a>"; $message = get_lang('RequestDenied').'<br /><br /><a href="javascript: history.back();">'.get_lang('Back').'</a>';
Display::display_normal_message($message); Display::display_normal_message($message);
/* /*
@ -37,4 +37,3 @@ Display::display_normal_message($message);
*/ */
Display::display_footer(); Display::display_footer();
?>

@ -6,16 +6,20 @@
* Who is online list * Who is online list
============================================================================== ==============================================================================
*/ */
// name of the language file that needs to be included
$language_file = array('index','registration','messages','userInfo'); // language files that should be included
$language_file = array('index', 'registration', 'messages', 'userInfo');
if (!isset($_GET['cidReq'])) { if (!isset($_GET['cidReq'])) {
$cidReset = true; $cidReset = true;
} }
// including necessary files // including necessary files
require_once './main/inc/global.inc.php'; require_once './main/inc/global.inc.php';
require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php'; require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php'; require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
require_once api_get_path(LIBRARY_PATH).'social.lib.php'; require_once api_get_path(LIBRARY_PATH).'social.lib.php';
// table definitions // table definitions
$track_user_table = Database::get_main_table(TABLE_MAIN_USER); $track_user_table = Database::get_main_table(TABLE_MAIN_USER);
@ -93,44 +97,43 @@ function hide_display_message () {
} }
} }
</script>'; </script>';
if ($_GET['chatid'] != '') { if ($_GET['chatid'] != '') {
//send out call request //send out call request
$time = time(); $time = time();
$time = date("Y-m-d H:i:s", $time); $time = date("Y-m-d H:i:s", $time);
$chatid = addslashes($_GET['chatid']); $chatid = addslashes($_GET['chatid']);
if ($_GET['chatid']==strval(intval($_GET['chatid']))) { if ($_GET['chatid'] == strval(intval($_GET['chatid']))) {
$sql="update $track_user_table set chatcall_user_id = '".Database::escape_string($_user['user_id'])."', chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")"; $sql = "update $track_user_table set chatcall_user_id = '".Database::escape_string($_user['user_id'])."', chatcall_date = '".Database::escape_string($time)."', chatcall_text = '' where (user_id = ".(int)Database::escape_string($chatid).")";
$result=api_sql_query($sql,__FILE__,__LINE__); $result = Database::query($sql, __FILE__, __LINE__);
//redirect caller to chat //redirect caller to chat
header("Location: ".$_configuration['code_append']."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid)); header("Location: ".$_configuration['code_append']."chat/chat.php?".api_get_cidreq()."&origin=whoisonline&target=".Security::remove_XSS($chatid));
exit; exit;
} }
} }
/** /**
* Displays a sortable table with the list of online users. * Displays a sortable table with the list of online users.
* @param array $user_list * @param array $user_list
*/ */
function display_user_list($user_list, $_plugins) function display_user_list($user_list, $_plugins) {
{
global $charset; global $charset;
if ($_GET["id"]=='') { if ($_GET['id'] == '') {
$extra_params = array(); $extra_params = array();
$course_url = ''; $course_url = '';
if(strlen($_GET['cidReq']) > 0) { if (strlen($_GET['cidReq']) > 0) {
$extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']); $extra_params['cidReq'] = Security::remove_XSS($_GET['cidReq']);
$course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']); $course_url = '&amp;cidReq='.Security::remove_XSS($_GET['cidReq']);
} }
foreach ($user_list as $user) { foreach ($user_list as $user) {
$uid=$user[0]; $uid = $user[0];
$user_info = api_get_user_info($uid); $user_info = api_get_user_info($uid);
$table_row = array(); $table_row = array();
$url = '?id='.$uid.$course_url; $url = '?id='.$uid.$course_url;
$image_array=UserManager::get_user_picture_path_by_id($uid,'system',false,true); $image_array = UserManager::get_user_picture_path_by_id($uid, 'system', false, true);
$friends_profile = UserFriend::get_picture_user($uid, $image_array['file'], 92, 'medium_', ' width="90" height="90" '); $friends_profile = UserFriend::get_picture_user($uid, $image_array['file'], 92, 'medium_', ' width="90" height="90" ');
//reduce image // reduce image
$table_row[] = '<center><a href="'.$url.'"><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' border="1"></a></center>'; $table_row[] = '<center><a href="'.$url.'"><img src="'.$friends_profile['file'].'" '.$friends_profile['style'].' border="1"></a></center>';
$table_row[] = '<a href="'.$url.'">'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</a>'; $table_row[] = '<a href="'.$url.'">'.api_get_person_name($user_info['firstName'], $user_info['lastName']).'</a>';
@ -139,11 +142,11 @@ function display_user_list($user_list, $_plugins)
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') == 'true') {
$table_row[] = Display::encrypted_mailto_link($user_info['mail']); $table_row[] = Display::encrypted_mailto_link($user_info['mail']);
} }
$user_anonymous=api_get_anonymous_id(); $user_anonymous = api_get_anonymous_id();
if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) { if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
if ($user_info['user_id'] != api_get_user_id() && !api_is_anonymous($user_info['user_id'])) { if ($user_info['user_id'] != api_get_user_id() && !api_is_anonymous($user_info['user_id'])) {
$user_relation=UserFriend::get_relation_between_contacts(api_get_user_id(),$user_info['user_id']); $user_relation = UserFriend::get_relation_between_contacts(api_get_user_id(), $user_info['user_id']);
if ($user_relation==0 || $user_relation==6) { if ($user_relation == 0 || $user_relation == 6) {
$table_row[] = '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=365&width=610&user_friend='.$user_info['user_id'].'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a><br /> $table_row[] = '<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=2&height=365&width=610&user_friend='.$user_info['user_id'].'" class="thickbox" title="'.get_lang('SendInvitation').'">'.Display :: return_icon('add_multiple_users.gif', get_lang('SocialInvitationToFriends')).'&nbsp;'.get_lang('SendInvitation').'</a><br />
<a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=365&width=610&user_friend='.$user_info['user_id'].'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>'; <a href="main/messages/send_message_to_userfriend.inc.php?view_panel=1&height=365&width=610&user_friend='.$user_info['user_id'].'" class="thickbox" title="'.get_lang('SendAMessage').'">'.Display :: return_icon('mail_send.png', get_lang('SendAMessage')).'&nbsp;'.get_lang('SendAMessage').'</a>';
} else { } else {
@ -153,31 +156,31 @@ function display_user_list($user_list, $_plugins)
} }
$table_data[] = $table_row; $table_data[] = $table_row;
} }
$table_header[] = array(get_lang('UserPicture'),false,'width="90"'); $table_header[] = array(get_lang('UserPicture'), false, 'width="90"');
$table_header[] = array(get_lang('Name'),true); $table_header[] = array(get_lang('Name'), true);
//$table_header[] = array(get_lang('LastName'),true); //$table_header[] = array(get_lang('LastName'), true);
if (api_get_setting('show_email_addresses') == 'true') { if (api_get_setting('show_email_addresses') == 'true') {
$table_header[] = array(get_lang('Email'),true); $table_header[] = array(get_lang('Email'), true);
} }
$user_anonymous=api_get_anonymous_id(); $user_anonymous = api_get_anonymous_id();
if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) { if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
$table_header[] = array(get_lang('Friends'),false,'width="200"'); $table_header[] = array(get_lang('Friends'), false, 'width="200"');
} }
/*this feature is deprecated /*this feature is deprecated
if ( api_get_setting('allow_message_tool')=='true' && isset($_SESSION['_user'])) { if (api_get_setting('allow_message_tool') == 'true' && isset($_SESSION['_user'])) {
$table_header[] = array(get_lang('SendMessage'),true); $table_header[] = array(get_lang('SendMessage'), true);
} }
*/ */
$sorting_options['column'] = (isset ($_GET['column']) ? (int)$_GET['column'] : 2); $sorting_options['column'] = (isset($_GET['column']) ? (int)$_GET['column'] : 2);
/*if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true' ) { /*if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true') {
//send_invitation_friend_user(); //send_invitation_friend_user();
echo '<div align="right"><input type="button" name="id_btn_send_invitation" id="id_btn_send_invitation" value="'.get_lang('SendInviteMessage').'"/></div>'; echo '<div align="right"><input type="button" name="id_btn_send_invitation" id="id_btn_send_invitation" value="'.get_lang('SendInviteMessage').'"/></div>';
echo '<form action="whoisonline.php" name="form_register_friend" id="form_register_friend" method="post">'; echo '<form action="whoisonline.php" name="form_register_friend" id="form_register_friend" method="post">';
}*/ }*/
Display::display_sortable_table($table_header,$table_data,$sorting_options,array('per_page_default'=>count($table_data)),$extra_params); Display::display_sortable_table($table_header, $table_data, $sorting_options, array('per_page_default' => count($table_data)), $extra_params);
/*if (api_get_setting('allow_social_tool')=='true' && api_get_setting('allow_message_tool')=='true' ) { /*if (api_get_setting('allow_social_tool') == 'true' && api_get_setting('allow_message_tool') == 'true' ) {
echo '</form>'; echo '</form>';
}*/ }*/
} }
@ -186,34 +189,33 @@ function display_user_list($user_list, $_plugins)
* Displays the information of an individual user * Displays the information of an individual user
* @param int $user_id * @param int $user_id
*/ */
function display_individual_user($user_id) function display_individual_user($user_id) {
{
global $interbreadcrumb; global $interbreadcrumb;
$safe_user_id = Database::escape_string($user_id); $safe_user_id = Database::escape_string($user_id);
// to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363 // to prevent a hacking attempt: http://www.dokeos.com/forum/viewtopic.php?t=5363
$user_table=Database::get_main_table(TABLE_MAIN_USER); $user_table = Database::get_main_table(TABLE_MAIN_USER);
$sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'"; $sql = "SELECT * FROM $user_table WHERE user_id='".$safe_user_id."'";
$result=api_sql_query($sql,__FILE__,__LINE__); $result = Database::query($sql, __FILE__, __LINE__);
if (Database::num_rows($result)==1) { if (Database::num_rows($result) == 1) {
$user_object = Database::fetch_object($result); $user_object = Database::fetch_object($result);
$name = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;<b>('.get_lang('Me').')</b>' : '' ); $name = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;<strong>('.get_lang('Me').')</strong>' : '' );
$alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;('.get_lang('Me').')' : ''); $alt = GetFullUserName($user_id).($_SESSION['_uid'] == $user_id ? '&nbsp;('.get_lang('Me').')' : '');
$status = ($user_object->status == COURSEMANAGER ? get_lang('Teacher') : get_lang('Student')); $status = ($user_object->status == COURSEMANAGER ? get_lang('Teacher') : get_lang('Student'));
$interbreadcrumb[]=array("url" => "whoisonline.php","name" => get_lang('UsersOnLineList')); $interbreadcrumb[] = array('url' => 'whoisonline.php', 'name' => get_lang('UsersOnLineList'));
Display::display_header($alt); Display::display_header($alt);
echo '<div class="actions-title">'; echo '<div class="actions-title">';
echo $alt; echo $alt;
echo '</div><br/>'; echo '</div><br />';
echo '<div style="text-align: center">'; echo '<div style="text-align: center">';
if (strlen(trim($user_object->picture_uri)) > 0) { if (strlen(trim($user_object->picture_uri)) > 0) {
$sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'system'); $sysdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'system');
$sysdir = $sysdir_array['dir']; $sysdir = $sysdir_array['dir'];
$webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'web'); $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id, 'web');
$webdir = $webdir_array['dir']; $webdir = $webdir_array['dir'];
$fullurl=$webdir.$user_object->picture_uri; $fullurl = $webdir.$user_object->picture_uri;
$system_image_path=$sysdir.$user_object->picture_uri; $system_image_path = $sysdir.$user_object->picture_uri;
list($width, $height, $type, $attr) = getimagesize($system_image_path); list($width, $height, $type, $attr) = @getimagesize($system_image_path);
$resizing = (($height > 200) ? 'height="200"' : ''); $resizing = (($height > 200) ? 'height="200"' : '');
$height += 30; $height += 30;
$width += 30; $width += 30;
@ -221,23 +223,22 @@ function display_individual_user($user_id)
// get the path,width and height from original picture // get the path,width and height from original picture
$big_image = $webdir.'big_'.$user_object->picture_uri; $big_image = $webdir.'big_'.$user_object->picture_uri;
$big_image_size = api_getimagesize($big_image); $big_image_size = api_getimagesize($big_image);
$big_image_width= $big_image_size[0]; $big_image_width = $big_image_size[0];
$big_image_height= $big_image_size[1]; $big_image_height = $big_image_size[1];
$url_big_image = $big_image.'?rnd='.time(); $url_big_image = $big_image.'?rnd='.time();
echo '<input type="image" src="'.$fullurl.'" alt="'.$alt.'" onclick="return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/><br />'; echo '<input type="image" src="'.$fullurl.'" alt="'.$alt.'" onclick="javascript: return show_image(\''.$url_big_image.'\',\''.$big_image_width.'\',\''.$big_image_height.'\');"/><br />';
global $user_anonymous; global $user_anonymous;
if (api_get_setting('allow_social_tool')=='true' && api_get_user_id()<>$user_anonymous && api_get_user_id()<>0) { if (api_get_setting('allow_social_tool') == 'true' && api_get_user_id() <> $user_anonymous && api_get_user_id() <> 0) {
echo '<br />'; echo '<br />';
echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.get_lang('ViewSharedProfile').'</a>'; echo '<a href="'.api_get_path(WEB_CODE_PATH).'social/profile.php?u='.$safe_user_id.'">'.get_lang('ViewSharedProfile').'</a>';
echo '<br />'; echo '<br />';
} }
} else { } else {
echo Display::return_icon('unknown.jpg',get_lang('Unknown')); echo Display::return_icon('unknown.jpg', get_lang('Unknown'));
echo '<br />'; echo '<br />';
} }
if (api_get_setting("show_email_addresses") == "true") if (api_get_setting('show_email_addresses') == 'true') {
{
echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />'; echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'<br />';
} }
echo $status.'<br />'; echo $status.'<br />';
@ -275,11 +276,11 @@ function display_individual_user($user_id)
*/ */
function display_productions($user_id) function display_productions($user_id)
{ {
$sysdir_array = UserManager::get_user_picture_path_by_id($user_id,'system'); $sysdir_array = UserManager::get_user_picture_path_by_id($user_id, 'system');
$sysdir = $sysdir_array['dir'].$user_id.'/'; $sysdir = $sysdir_array['dir'].$user_id.'/';
$webdir_array = UserManager::get_user_picture_path_by_id($user_id,'web'); $webdir_array = UserManager::get_user_picture_path_by_id($user_id, 'web');
$webdir = $webdir_array['dir'].$user_id.'/'; $webdir = $webdir_array['dir'].$user_id.'/';
if( !is_dir($sysdir)) { if (!is_dir($sysdir)) {
mkpath($sysdir); mkpath($sysdir);
} }
$handle = opendir($sysdir); $handle = opendir($sysdir);
@ -290,20 +291,19 @@ function display_productions($user_id)
} }
$productions[] = $file; $productions[] = $file;
} }
if(count($productions) > 0) { if (count($productions) > 0) {
echo '<dt><strong>'.get_lang('Productions').'</strong></dt>'; echo '<dt><strong>'.get_lang('Productions').'</strong></dt>';
echo '<dd><ul>'; echo '<dd><ul>';
foreach($productions as $index => $file) { foreach ($productions as $index => $file) {
// Only display direct file links to avoid browsing an empty directory // Only display direct file links to avoid browsing an empty directory
if(is_file($sysdir.$file) && $file != $webdir_array['file']){ if (is_file($sysdir.$file) && $file != $webdir_array['file']) {
echo '<li><a href="'.$webdir.urlencode($file).'" target=_blank>'.$file.'</a></li>'; echo '<li><a href="'.$webdir.urlencode($file).'" target=_blank>'.$file.'</a></li>';
} }
// Real productions are under a subdirectory by the User's id // Real productions are under a subdirectory by the User's id
if(is_dir($sysdir.$file)) { if (is_dir($sysdir.$file)) {
$subs = scandir($sysdir.$file); $subs = scandir($sysdir.$file);
foreach($subs as $my => $sub) { foreach ($subs as $my => $sub) {
if(substr($sub,0,1) != '.' && is_file($sysdir.$file.'/'.$sub)) if (substr($sub, 0, 1) != '.' && is_file($sysdir.$file.'/'.$sub)) {
{
echo '<li><a href="'.$webdir.urlencode($file).'/'.urlencode($sub).'" target=_blank>'.$sub.'</a></li>'; echo '<li><a href="'.$webdir.urlencode($file).'/'.urlencode($sub).'" target=_blank>'.$sub.'</a></li>';
} }
} }
@ -314,57 +314,50 @@ function display_productions($user_id)
} }
// This if statement prevents users accessing the who's online feature when it has been disabled. // This if statement prevents users accessing the who's online feature when it has been disabled.
if ((api_get_setting('showonline','world') == 'true' AND !$_user['user_id']) OR ((api_get_setting('showonline','users') == 'true' OR api_get_setting('showonline','course') == 'true') AND $_user['user_id'])) { if ((api_get_setting('showonline', 'world') == 'true' && !$_user['user_id']) || ((api_get_setting('showonline', 'users') == 'true' || api_get_setting('showonline', 'course') == 'true') && $_user['user_id'])) {
if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) { if(isset($_GET['cidReq']) && strlen($_GET['cidReq']) > 0) {
$user_list = Who_is_online_in_this_course($_user['user_id'],api_get_setting('time_limit_whosonline'),$_GET['cidReq']); $user_list = Who_is_online_in_this_course($_user['user_id'], api_get_setting('time_limit_whosonline'), $_GET['cidReq']);
} else { } else {
$user_list = WhoIsOnline($_user['user_id'],$_configuration['statistics_database'],api_get_setting('time_limit_whosonline')); $user_list = WhoIsOnline($_user['user_id'], $_configuration['statistics_database'], api_get_setting('time_limit_whosonline'));
} }
$total = count($user_list);
$total=count($user_list); if (!isset($_GET['id'])) {
if (!isset($_GET['id']))
{
Display::display_header(get_lang('UsersOnLineList')); Display::display_header(get_lang('UsersOnLineList'));
echo '<div class="actions-title">'; echo '<div class="actions-title">';
echo get_lang('UsersOnLineList'); echo get_lang('UsersOnLineList');
echo '</div>'; echo '</div>';
echo '<div class="actions-message">'.get_lang('TotalOnLine').' : '.$total.'</div>'; echo '<div class="actions-message">'.get_lang('TotalOnLine').' : '.$total.'</div>';
if ($_GET['id']=='') { if ($_GET['id'] == '') {
echo '<p><a class="refresh" href="javascript:window.location.reload()">'.get_lang('Refresh').'</a></p>'; echo '<p><a class="refresh" href="javascript:window.location.reload()">'.get_lang('Refresh').'</a></p>';
} else { } else {
if(0) // if ($_user['user_id'] && $_GET["id"] != $_user['user_id']) if (0) {
{ // if ($_user['user_id'] && $_GET["id"] != $_user['user_id']) {
echo '<a href="'.api_get_self().'?chatid='.Security::remove_XSS($_GET['id']).'">'.get_lang('SendChatRequest').'</a>'; echo '<a href="'.api_get_self().'?chatid='.Security::remove_XSS($_GET['id']).'">'.get_lang('SendChatRequest').'</a>';
} }
} }
} }
if ($user_list!=false) if ($user_list) {
{ if (!isset($_GET['id'])) {
if (!isset($_GET['id']))
{
display_user_list($user_list, $_plugins); display_user_list($user_list, $_plugins);
} } else {
else //individual user information - also displays header info //individual user information - also displays header info
{
display_individual_user(Security::remove_XSS($_GET['id'])); display_individual_user(Security::remove_XSS($_GET['id']));
} }
} }
elseif(isset($_GET['id'])) elseif (isset($_GET['id'])) {
{
Display::display_header(get_lang('UsersOnLineList')); Display::display_header(get_lang('UsersOnLineList'));
echo '<div class="actions-title">'; echo '<div class="actions-title">';
echo get_lang('UsersOnLineList'); echo get_lang('UsersOnLineList');
echo '</div>'; echo '</div>';
} }
} } else {
else
{
Display::display_header(get_lang('UsersOnLineList')); Display::display_header(get_lang('UsersOnLineList'));
Display::display_error_message(get_lang('AccessNotAllowed')); Display::display_error_message(get_lang('AccessNotAllowed'));
} }
$referer = empty($_GET['referer'])?'index.php':api_htmlentities(strip_tags($_GET['referer']),ENT_QUOTES,$charset);
$referer = empty($_GET['referer']) ? 'index.php' : api_htmlentities(strip_tags($_GET['referer']), ENT_QUOTES);
if (isset($_GET['id'])) { if (isset($_GET['id'])) {
echo '<a href="whoisonline.php" class="fake_button_back">'.get_lang('Back').'</a>'; echo '<a href="whoisonline.php" class="fake_button_back">'.get_lang('Back').'</a>';
@ -379,4 +372,3 @@ if (isset($_GET['id'])) {
*/ */
/*echo '<div align="center"><a href="http://main.svndokeos.net/main/upload/users/4/4_49aeb3bb8bba5.jpg" class="thickbox">hola</a></div>';*/ /*echo '<div align="center"><a href="http://main.svndokeos.net/main/upload/users/4/4_49aeb3bb8bba5.jpg" class="thickbox">hola</a></div>';*/
Display::display_footer(); Display::display_footer();
?>

@ -1,18 +1,12 @@
<?php <?php
/* For licensing terms, see /dokeos_license.txt */ /* For licensing terms, see /dokeos_license.txt */
/**
* @todo variables are sometimes in cammelcase, or even worse a mixture of CammelCase and udnerscoring: $a_userList
*
*/
// name of the language file that needs to be included // name of the language file that needs to be included
$language_file = array ('index', 'chat', 'tracking'); $language_file = array ('index', 'chat', 'tracking');
include_once("./main/inc/global.inc.php"); include_once './main/inc/global.inc.php';
api_block_anonymous_users(); api_block_anonymous_users();
$tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION); $tbl_session = Database :: get_main_table(TABLE_MAIN_SESSION);
$tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE); $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
@ -25,7 +19,7 @@ $tbl_session_course = Database :: get_main_table(TABLE_MAIN_SESSION_COURSE);
Display::display_header(get_lang('UserOnlineListSession')); Display::display_header(get_lang('UserOnlineListSession'));
?> ?>
<br/><br/> <br /><br />
<table class="data_table" width="60%"> <table class="data_table" width="60%">
<tr class="tableName"> <tr class="tableName">
<td colspan="4"> <td colspan="4">
@ -47,10 +41,10 @@ Display::display_header(get_lang('UserOnlineListSession'));
</th> </th>
</tr> </tr>
<?php <?php
$sessionIsCoach = array(); $session_is_coach = array();
if (isset($_user['user_id']) && $_user['user_id']!='') { if (isset($_user['user_id']) && $_user['user_id'] != '') {
$_user['user_id'] = intval($_user['user_id']); $_user['user_id'] = intval($_user['user_id']);
$result = api_sql_query("SELECT DISTINCT id, $result = Database::query("SELECT DISTINCT id,
name, name,
date_start, date_start,
date_end date_end
@ -61,10 +55,10 @@ Display::display_header(get_lang('UserOnlineListSession'));
ORDER BY date_start, date_end, name",__FILE__,__LINE__); ORDER BY date_start, date_end, name",__FILE__,__LINE__);
while ($session = Database:: fetch_array($result)) { while ($session = Database:: fetch_array($result)) {
$sessionIsCoach[$session['id']] = $session; $session_is_coach[$session['id']] = $session;
} }
$result = api_sql_query("SELECT DISTINCT id, $result = Database::query("SELECT DISTINCT id,
name, name,
date_start, date_start,
date_end date_end
@ -72,10 +66,11 @@ Display::display_header(get_lang('UserOnlineListSession'));
WHERE session.id_coach = ".$_user['user_id']." WHERE session.id_coach = ".$_user['user_id']."
ORDER BY date_start, date_end, name",__FILE__,__LINE__); ORDER BY date_start, date_end, name",__FILE__,__LINE__);
while ($session = Database:: fetch_array($result)) { while ($session = Database:: fetch_array($result)) {
$sessionIsCoach[$session['id']] = $session; $session_is_coach[$session['id']] = $session;
} }
foreach($sessionIsCoach as $session) { $students_online = array();
foreach ($session_is_coach as $session) {
$sql = "SELECT DISTINCT last_access.access_user_id, $sql = "SELECT DISTINCT last_access.access_user_id,
last_access.access_date, last_access.access_date,
last_access.access_cours_code, last_access.access_cours_code,
@ -88,38 +83,35 @@ Display::display_header(get_lang('UserOnlineListSession'));
WHERE access_session_id='".$session['id']."' WHERE access_session_id='".$session['id']."'
AND NOW()-access_date<1000 GROUP BY access_user_id"; AND NOW()-access_date<1000 GROUP BY access_user_id";
$result = api_sql_query($sql,__FILE__,__LINE__); $result = Database::query($sql, __FILE__, __LINE__);
while($a_userList = mysql_fetch_array($result)) { while($user_list = Database::fetch_array($result)) {
$a_onlineStudent[$a_userList['access_user_id']] = $a_userList; $students_online[$user_list['access_user_id']] = $user_list;
} }
} }
if(count($a_onlineStudent)>0) { if (count($students_online) > 0) {
foreach($a_onlineStudent as $onlineStudent) { foreach ($students_online as $student_online) {
echo "<tr> echo "<tr>
<td> <td>
"; ";
echo $onlineStudent['name']; echo $student_online['name'];
echo " </td> echo " </td>
<td align='center'> <td align='center'>
"; ";
echo $onlineStudent['access_cours_code']; echo $student_online['access_cours_code'];
echo " </td> echo " </td>
<td align='center'> <td align='center'>
"; ";
if(!empty($onlineStudent['email'])) if (!empty($student_online['email'])) {
{ echo $student_online['email'];
echo $onlineStudent['email']; } else {
}
else
{
echo get_lang('NoEmail'); echo get_lang('NoEmail');
} }
echo " </td> echo " </td>
<td align='center'> <td align='center'>
"; ";
echo '<a href="main/chat/chat.php?cidReq='.$onlineStudent['access_cours_code'].'&id_session='.$onlineStudent['access_session_id'].'"> -> </a>'; echo '<a href="main/chat/chat.php?cidReq='.$student_online['access_cours_code'].'&id_session='.$student_online['access_session_id'].'"> -> </a>';
echo " </td> echo " </td>
</tr> </tr>
"; ";
@ -136,11 +128,10 @@ Display::display_header(get_lang('UserOnlineListSession'));
?> ?>
</table> </table>
<?php <?php
/* /*
============================================================================== ==============================================================================
FOOTER FOOTER
============================================================================== ==============================================================================
*/ */
Display::display_footer(); Display::display_footer();
?>
Loading…
Cancel
Save