diff --git a/index.php b/index.php index 8b4748c385..feb3184af0 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ , Ghent University */ -function logout() +function logout() { global $_configuration, $extAuthSource; // variable initialisation @@ -288,19 +288,19 @@ function logout() if (Database::num_rows($q_last_connection)>0) { $i_id_last_connection=Database::result($q_last_connection,0,"login_id"); } - + if (!isset($_SESSION['login_as'])) { $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'"; api_sql_query($s_sql_update_logout_date); } LoginDelete($uid, $_configuration['statistics_database']); //from inc/lib/online.inc.php - removes the "online" status - + //the following code enables the use of an external logout function. //example: define a $extAuthSource['ldap']['logout']="file.php" in configuration.php - // then a function called ldap_logout() inside that file - // (using *authent_name*_logout as the function name) and the following code - // will find and execute it + // then a function called ldap_logout() inside that file + // (using *authent_name*_logout as the function name) and the following code + // will find and execute it $uinfo = api_get_user_info($uid); if (($uinfo['auth_source'] != PLATFORM_AUTH_SOURCE) && is_array($extAuthSource)) { if (is_array($extAuthSource[$uinfo['auth_source']])) { @@ -328,14 +328,14 @@ function logout() */ function category_has_open_courses($category) { global $setting_show_also_closed_courses; - + $user_identified = (api_get_user_id()>0 && !api_is_anonymous()); $main_course_table = Database :: get_main_table(TABLE_MAIN_COURSE); $sql_query = "SELECT * FROM $main_course_table WHERE category_code='$category'"; $sql_result = api_sql_query($sql_query, __FILE__, __LINE__); while ($course = Database::fetch_array($sql_result)) { if ($setting_show_also_closed_courses == false) { - if ((api_get_user_id()>0 + if ((api_get_user_id()>0 and $course['visibility'] == COURSE_VISIBILITY_OPEN_PLATFORM) or ($course['visibility'] == COURSE_VISIBILITY_OPEN_WORLD)) { return true; //at least one open course @@ -343,7 +343,7 @@ function category_has_open_courses($category) { } else { 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 false; @@ -403,26 +403,26 @@ function display_anonymous_right_menu() { $show_menu=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"); - + if ($display_add_course_link) { //display_create_course_link(); $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()) { $show_menu=true; - $show_course_link=true; - } else { - if (api_get_setting('allow_students_to_browse_courses')=='true') { + $show_course_link=true; + } else { + if (api_get_setting('allow_students_to_browse_courses')=='true') { $show_menu=true; - $show_course_link=true; - } + $show_course_link=true; + } } - + if ($show_menu){ echo "
"; echo "".get_lang("MenuUser").""; @@ -430,11 +430,11 @@ function display_anonymous_right_menu() { if ($show_create_link) display_create_course_link(); if ($show_course_link) - display_edit_course_list_links(); + display_edit_course_list_links(); echo ""; - echo "
"; + echo ""; } - + if (!empty($menu_navigation)) { echo "
"; echo "".get_lang("MainNavigation").""; @@ -450,16 +450,16 @@ function display_anonymous_right_menu() { echo '
'; } } - + // help section /*** hide right menu "general" and other parts on anonymous right menu *****/ - + $user_selected_language = api_get_interface_language(); global $home, $home_old; if (!isset ($user_selected_language)) { $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')!='') { @@ -475,22 +475,22 @@ function display_anonymous_right_menu() { } elseif(file_exists($home.'home_menu_'.$user_selected_language.'.html') && file_get_contents($home.'home_menu_'.$user_selected_language.'.html')!='') - { + { echo "
", "".get_lang("MenuGeneral").""; echo "'; echo '
'; - } - + } + if ($_user['user_id'] && api_number_of_plugins('campushomepage_menu') > 0) { echo '
'; api_plugin('campushomepage_menu'); echo '
'; } - + // 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')!='') { echo '
'; if (file_exists($home.'home_notice.html')) @@ -501,9 +501,9 @@ function display_anonymous_right_menu() { echo '
'; } elseif(file_exists($home.'home_notice_'.$user_selected_language.'.html') && file_get_contents($home.'home_notice_'.$user_selected_language.'.html')!='') { echo '
'; - include($home.'home_notice_'.$user_selected_language.'.html'); + include($home.'home_notice_'.$user_selected_language.'.html'); echo '
'; - } + } } /** @@ -548,7 +548,7 @@ function handle_login_failed() { * Adds a form to let users login * @version 1.1 */ -function display_login_form() +function display_login_form() { $form = new FormValidator('formLogin'); $form->addElement('text','login',get_lang('UserName'),array('size'=>17)); @@ -578,8 +578,8 @@ function display_lost_password_info() { */ function display_anonymous_course_list() { $ctok = $_SESSION['sec_token']; - $stok = Security::get_token(); - + $stok = Security::get_token(); + //init $user_identified = (api_get_user_id()>0 && !api_is_anonymous()); $web_course_path = api_get_path(WEB_COURSE_PATH); @@ -596,19 +596,19 @@ function display_anonymous_course_list() { $sql_get_course_list = "SELECT * FROM $main_course_table cours WHERE category_code = '".Database::escape_string($_GET["category"])."' ORDER BY title, UPPER(visual_code)"; - - //showing only the courses of the current access_url_id + + //showing only the courses of the current access_url_id global $_configuration; if ($_configuration['multiple_access_urls']==true) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id !=-1) { - $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); - $sql_get_course_list="SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course + $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $sql_get_course_list="SELECT * FROM $main_course_table as course INNER JOIN $tbl_url_rel_course as url_rel_course ON (url_rel_course.course_code=course.code) WHERE access_url_id = $url_access_id AND category_code = '".Database::escape_string($_GET["category"])."' ORDER BY title, UPPER(visual_code)"; } } - + //removed: AND cours.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' $sql_result_courses = api_sql_query($sql_get_course_list, __FILE__, __LINE__); @@ -622,14 +622,14 @@ function display_anonymous_course_list() { if ($setting_show_also_closed_courses) { $platform_visible_courses = ''; } else { - $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )"; + $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' OR t3.visibility='".COURSE_VISIBILITY_OPEN_PLATFORM."' )"; } } else { if ($setting_show_also_closed_courses) { $platform_visible_courses = ''; } else { - $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )"; - } + $platform_visible_courses = " AND (t3.visibility='".COURSE_VISIBILITY_OPEN_WORLD."' )"; + } } $sqlGetSubCatList = " SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse @@ -638,26 +638,26 @@ function display_anonymous_course_list() { LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) WHERE t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; - - - //showing only the category of courses of the current access_url_id + + + //showing only the category of courses of the current access_url_id global $_configuration; if ($_configuration['multiple_access_urls']==true) { $url_access_id = api_get_current_access_url_id(); if ($url_access_id !=-1) { - $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); + $tbl_url_rel_course = Database::get_main_table(TABLE_MAIN_ACCESS_URL_REL_COURSE); $sqlGetSubCatList = " SELECT t1.name,t1.code,t1.parent_id,t1.children_count,COUNT(DISTINCT t3.code) AS nbCourse FROM $main_category_table t1 LEFT JOIN $main_category_table t2 ON t1.code=t2.parent_id LEFT JOIN $main_course_table t3 ON (t3.category_code=t1.code $platform_visible_courses) - INNER JOIN $tbl_url_rel_course as url_rel_course + INNER JOIN $tbl_url_rel_course as url_rel_course ON (url_rel_course.course_code=t3.code) - WHERE access_url_id = $url_access_id AND t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." + WHERE access_url_id = $url_access_id AND t1.parent_id ". (empty ($category) ? "IS NULL" : "='$category'")." GROUP BY t1.name,t1.code,t1.parent_id,t1.children_count ORDER BY t1.tree_pos, t1.name"; } } - + $resCats = api_sql_query($sqlGetSubCatList, __FILE__, __LINE__); $thereIsSubCat = false; if (Database::num_rows($resCats) > 0) { @@ -724,16 +724,16 @@ function display_anonymous_course_list() { $courses_list_string .= "
\n"; } $courses_list_string .= "

".get_lang("CourseList")."

\n"."'; echo ''; -} +} // Main navigation section // tabs that are deactivated are added here @@ -972,15 +972,15 @@ if (isset($_plugins['mycourses_menu']) && is_array($_plugins['mycourses_menu'])) echo ''; } -if (api_get_setting('allow_reservation')=='true' && api_is_allowed_to_create_course() ){ - //include_once('main/reservation/rsys.php'); +if (api_get_setting('allow_reservation')=='true' && api_is_allowed_to_create_course() ){ + //include_once('main/reservation/rsys.php'); echo '
'; echo '
'; 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']; $webdir_array = UserManager::get_user_picture_path_by_id($safe_user_id,'web'); $webdir = $webdir_array['dir']; @@ -217,25 +217,25 @@ function display_individual_user($user_id) $resizing = (($height > 200) ? 'height="200"' : ''); $height += 30; $width += 30; - $window_name = 'window'.uniqid(''); - // get the path,width and height from original picture + $window_name = 'window'.uniqid(''); + // get the path,width and height from original picture $big_image = $webdir.'big_'.$user_object->picture_uri; $big_image_size = api_getimagesize($big_image); $big_image_width= $big_image_size[0]; $big_image_height= $big_image_size[1]; - $url_big_image = $big_image.'?rnd='.time(); + $url_big_image = $big_image.'?rnd='.time(); echo '
'; 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 '
'; - echo ''.get_lang('ViewSharedProfile').''; + echo ''.get_lang('ViewSharedProfile').''; echo '
'; - } - } else { + } + } else { echo Display::return_icon('unknown.jpg',get_lang('Unknown')); echo '
'; } - + if (api_get_setting("show_email_addresses") == "true") { echo Display::encrypted_mailto_link($user_object->email,$user_object->email).'
'; @@ -274,10 +274,10 @@ function display_individual_user($user_id) * @todo use the correct api_get_path instead of $clarolineRepositoryWeb */ function display_productions($user_id) -{ +{ $sysdir_array = UserManager::get_user_picture_path_by_id($user_id,'system'); $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.'/'; if( !is_dir($sysdir)) { mkpath($sysdir); @@ -304,7 +304,7 @@ function display_productions($user_id) foreach($subs as $my => $sub) { if(substr($sub,0,1) != '.' && is_file($sysdir.$file.'/'.$sub)) { - echo '
  • '.$sub.'
  • '; + echo '
  • '.$sub.'
  • '; } } } @@ -367,10 +367,10 @@ else $referer = empty($_GET['referer'])?'index.php':api_htmlentities(strip_tags($_GET['referer']),ENT_QUOTES,$charset); if (isset($_GET['id'])) { - echo ''.get_lang('Back').''; + echo ''.get_lang('Back').''; } else { - echo ''.get_lang('BackHome').''; -} + echo ''.get_lang('BackHome').''; +} /* ============================================================================== diff --git a/whoisonlinesession.php b/whoisonlinesession.php index 597304d436..fc803b3ff8 100644 --- a/whoisonlinesession.php +++ b/whoisonlinesession.php @@ -3,10 +3,10 @@ /** * @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'); include_once("./main/inc/global.inc.php"); @@ -50,34 +50,34 @@ Display::display_header(get_lang('UserOnlineListSession')); $sessionIsCoach = array(); if (isset($_user['user_id']) && $_user['user_id']!='') { $_user['user_id'] = intval($_user['user_id']); - $result = api_sql_query("SELECT DISTINCT id, - name, - date_start, - date_end - FROM $tbl_session as session + $result = api_sql_query("SELECT DISTINCT id, + name, + date_start, + date_end + FROM $tbl_session as session INNER JOIN $tbl_session_course as session_rel_course ON session_rel_course.id_coach = ".$_user['user_id']." AND session.id = session_rel_course.id_session ORDER BY date_start, date_end, name",__FILE__,__LINE__); - + while ($session = Database:: fetch_array($result)) { $sessionIsCoach[$session['id']] = $session; } - - $result = api_sql_query("SELECT DISTINCT id, - name, - date_start, - date_end - FROM $tbl_session as session + + $result = api_sql_query("SELECT DISTINCT id, + name, + date_start, + date_end + FROM $tbl_session as session WHERE session.id_coach = ".$_user['user_id']." ORDER BY date_start, date_end, name",__FILE__,__LINE__); while ($session = Database:: fetch_array($result)) { $sessionIsCoach[$session['id']] = $session; } - + foreach($sessionIsCoach as $session) { - $sql = "SELECT DISTINCT last_access.access_user_id, - last_access.access_date, + $sql = "SELECT DISTINCT last_access.access_user_id, + last_access.access_date, last_access.access_cours_code, last_access.access_session_id, ".(api_is_western_name_order() ? "CONCAT(user.firstname,' ',user.lastname)" : "CONCAT(user.lastname,' ',user.firstname)")." as name, @@ -85,16 +85,16 @@ Display::display_header(get_lang('UserOnlineListSession')); FROM ".Database::get_statistic_table(TABLE_STATISTIC_TRACK_E_LASTACCESS)." AS last_access INNER JOIN ".Database::get_main_table(TABLE_MAIN_USER)." AS user ON user.user_id = last_access.access_user_id - WHERE access_session_id='".$session['id']."' + WHERE access_session_id='".$session['id']."' AND NOW()-access_date<1000 GROUP BY access_user_id"; - + $result = api_sql_query($sql,__FILE__,__LINE__); - + while($a_userList = mysql_fetch_array($result)) { $a_onlineStudent[$a_userList['access_user_id']] = $a_userList; } } - + if(count($a_onlineStudent)>0) { foreach($a_onlineStudent as $onlineStudent) { echo " @@ -115,7 +115,7 @@ Display::display_header(get_lang('UserOnlineListSession')); else { echo get_lang('NoEmail'); - } + } echo " ";