From 865a78681b89c330b659659c32eb462e4826715d Mon Sep 17 00:00:00 2001 From: Patrick Cool Date: Wed, 15 Nov 2006 14:27:45 +0100 Subject: [PATCH] [svn r9994] a little bit of cleanup and adding @todo information --- index.php | 40 ++++++---- myStudents.php | 1 + newsList.php | 53 ++++++++------ user_portal.php | 163 ++++++++++++++++++++++++----------------- webchatdeny.php | 10 ++- whoisonline.php | 21 ++++-- whoisonlinesession.php | 23 +++--- 7 files changed, 187 insertions(+), 124 deletions(-) diff --git a/index.php b/index.php index b723f82c4b..3ce2e8975f 100644 --- a/index.php +++ b/index.php @@ -39,6 +39,12 @@ * @package dokeos.main ============================================================================== */ + +/** + * @todo shouldn't the SCRIPTVAL_ and CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for? + * if these are really configuration settings then we can add those to the dokeos config settings + */ + /* ============================================================================== INIT SECTION @@ -64,18 +70,22 @@ $cidReset = true; /* Flag forcing the 'current course' reset, Included libraries ----------------------------------------------------------- */ -//this includes main_api too: include_once ('./main/inc/global.inc.php'); - -$this_section = SECTION_CAMPUS; - - 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).'events.lib.inc.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).'formvalidator/FormValidator.class.php'); + +// the section (for the tabs) +$this_section = SECTION_CAMPUS; + +/* +----------------------------------------------------------- + Action Handling +----------------------------------------------------------- +*/ if ($_GET['logout']) { $query_string=''; @@ -105,21 +115,21 @@ if ($_GET['logout']) header("Location: index.php$query_string"); exit(); } + /* ----------------------------------------------------------- Table definitions ----------------------------------------------------------- */ -//new table definitions, using database library -//these already have backticks around them! -$main_course_table = Database :: get_main_table(MAIN_COURSE_TABLE); -$main_category_table = Database :: get_main_table(MAIN_CATEGORY_TABLE); -$track_login_table = Database :: get_statistic_table(STATISTIC_TRACK_E_LOGIN_TABLE); +$main_course_table = Database :: get_main_table(MAIN_COURSE_TABLE); +$main_category_table = Database :: get_main_table(MAIN_CATEGORY_TABLE); +$track_login_table = Database :: get_statistic_table(STATISTIC_TRACK_E_LOGIN_TABLE); /* ----------------------------------------------------------- Constants and CONFIGURATION parameters ----------------------------------------------------------- */ +// @todo shouldn't these be moved to the config page or made into dokeos config settings? // ---- Category list options ---- /** defines wether or not anonymous visitors can see a list of the courses on the Dokeos homepage that are open to the world */ @@ -195,6 +205,7 @@ if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != "ke */ if ($_GET["submitAuth"] == 1) { + // nice lie!!! echo "Attempted breakin - sysadmins notified."; session_destroy(); die(); @@ -273,6 +284,7 @@ Display :: display_header('', $help); * login form, useful links, help section * Warning: function defines globals * @version 1.0.1 + * @todo does $_plugins need to be global? */ function display_anonymous_right_menu() { @@ -287,7 +299,9 @@ function display_anonymous_right_menu() display_login_form(); if ($loginFailed) + { handle_login_failed(); + } if (api_get_setting('allow_lostpassword') == 'true' OR api_get_setting('allow_registration') == 'true') { echo ''; if (api_get_user_id()) @@ -571,11 +585,11 @@ else { if(!file_exists('home/home_news_'.$user_selected_language.'.html')) { - include ('home/home_top.html'); + include ('home/home_top.html'); } else { - include('home/home_top_'.$user_selected_language.'.html'); + include('home/home_top_'.$user_selected_language.'.html'); } } diff --git a/myStudents.php b/myStudents.php index 34cc05be4f..5b0d70f8ea 100644 --- a/myStudents.php +++ b/myStudents.php @@ -7,6 +7,7 @@ * @todo use the correct database calls. example around line 480 : .$a_infosCours['db_name'].".".$tbl_course_lp_view_item." * @todo language variables are sometimes in french: get_lang('Annoter') * @todo other variables are sometimes in french: $pourcentageScore + * @todo variables are sometimes in cammelcase */ $langFile = array ('registration', 'index','trad4all', 'tracking'); diff --git a/newsList.php b/newsList.php index 3ffbf0b126..f825527e80 100644 --- a/newsList.php +++ b/newsList.php @@ -1,31 +1,36 @@ diff --git a/user_portal.php b/user_portal.php index 2e2ca753b7..4108bb9c38 100644 --- a/user_portal.php +++ b/user_portal.php @@ -41,6 +41,16 @@ * @package dokeos.main ============================================================================== */ + +/** + * @todo shouldn't the SCRIPTVAL_ and CONFVAL_ constant be moved to the config page? Has anybody any idea what the are used for? + * if these are really configuration settings then we can add those to the dokeos config settings + * @todo move get_personal_course_list and some other functions to a more appripriate place course.lib.php or user.lib.php + * @todo use api_get_path instead of $rootAdminWeb + * @todo check for duplication of functions with index.php (user_portal.php is orginally a copy of index.php) + * @todo display_digest, shouldn't this be removed and be made into an extension? + */ + /* ============================================================================== INIT SECTION @@ -65,17 +75,14 @@ $cidReset = true; /* Flag forcing the 'current course' reset, Included libraries ----------------------------------------------------------- */ -//this includes main_api too: include_once ('./main/inc/global.inc.php'); - - -api_block_anonymous_users(); // only users who are logged in can proceed - 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).'system_announcements.lib.php'); include_once (api_get_path(LIBRARY_PATH).'groupmanager.lib.php'); +api_block_anonymous_users(); // only users who are logged in can proceed + /* ----------------------------------------------------------- Table definitions @@ -190,10 +197,10 @@ Display :: display_header($nameTools); display_create_course_link() display_edit_course_list_links() display_digest($toolsList, $digest, $orderKey, $courses) - show_notification($mycours) + show_notification($my_course) get_personal_course_list($user_id) - get_logged_user_course_html($mycours) + get_logged_user_course_html($my_course) get_user_course_categories() ============================================================================== */ @@ -211,9 +218,12 @@ Display :: display_header($nameTools); */ function get_personal_course_list($user_id) { + // initialisation $personal_course_list = array(); - $main_user_table = Database :: get_main_table(MAIN_USER_TABLE); - $main_course_table = Database :: get_main_table(MAIN_COURSE_TABLE); + + // table definitions + $main_user_table = Database :: get_main_table(MAIN_USER_TABLE); + $main_course_table = Database :: get_main_table(MAIN_COURSE_TABLE); $main_course_user_table = Database :: get_main_table(MAIN_COURSE_USER_TABLE); $personal_course_list_sql = "SELECT course.code k, course.directory d, course.visual_code c, course.db_name db, course.title i, @@ -223,7 +233,6 @@ function get_personal_course_list($user_id) WHERE course.code = course_rel_user.course_code"." AND course_rel_user.user_id = '".$user_id."' ORDER BY course_rel_user.user_course_cat, course_rel_user.sort ASC,course.title,course.code"; - $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__); $personal_course_list = array (); @@ -478,59 +487,66 @@ function display_digest($toolsList, $digest, $orderKey, $courses) * Display code for one specific course a logged in user is subscribed to. * Shows a link to the course, what's new icons... * - * $mycours['d'] - course directory - * $mycours['i'] - course title - * $mycours['c'] - visual course code - * $mycours['k'] - system course code - * $mycours['db'] - course database + * $my_course['d'] - course directory + * $my_course['i'] - course title + * $my_course['c'] - visual course code + * $my_course['k'] - system course code + * $my_course['db'] - course database * * @version 1.0.3 * @todo refactor into different functions for database calls | logic | display - * @todo replace single-character $mycours['d'] indices + * @todo replace single-character $my_course['d'] indices * @todo move code for what's new icons to a separate function to clear things up + * @todo add a parameter user_id so that it is possible to show the courselist of other users (=generalisation). This will prevent having to write a new function for this. */ -function get_logged_user_course_html($mycours) +function get_logged_user_course_html($my_course) { global $nosession; - if(api_get_setting('use_session_mode')=='true' && !$nosession){ + + if(api_get_setting('use_session_mode')=='true' && !$nosession) + { global $now, $date_start, $date_end; } + //initialise $result = ''; + + // Table definitions //$statistic_database = Database::get_statistic_database(); + $course_tool_table = Database :: get_course_table(TOOL_LIST_TABLE, $course_database); + $tool_edit_table = Database :: get_course_table(LAST_TOOL_EDIT_TABLE, $course_database); + $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database); + $user_id = api_get_user_id(); - $course_database = $mycours['db']; - $course_tool_table = Database::get_course_table(TOOL_LIST_TABLE, $course_database); - $tool_edit_table = Database::get_course_table(LAST_TOOL_EDIT_TABLE, $course_database); - $course_group_user_table = Database :: get_course_table(TOOL_USER, $course_database); - $course_system_code = $mycours['k']; - $course_visual_code = $mycours['c']; - $course_title = $mycours['i']; - $course_directory = $mycours['d']; - $course_teacher = $mycours['t']; + $course_database = $my_course['db']; + $course_system_code = $my_course['k']; + $course_visual_code = $my_course['c']; + $course_title = $my_course['i']; + $course_directory = $my_course['d']; + $course_teacher = $my_course['t']; $course_info = Database :: get_course_info($course_system_code); $course_access_settings = CourseManager :: get_access_settings($course_system_code); $course_id = $course_info['course_id']; $course_visibility = $course_access_settings['visibility']; - $user_in_course_status = CourseManager :: get_user_in_course_status($user_id, $course_system_code); + $user_in_course_status = CourseManager :: get_user_in_course_status(api_get_user_id(), $course_system_code); //function logic - act on the data - $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($mycours['c']); + $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['c']); if ($is_virtual_course) { // If the current user is also subscribed in the real course to which this // virtual course is linked, we don't need to display the virtual course entry in // the course list - it is combined with the real course entry. $target_course_code = CourseManager :: get_target_of_linked_course($course_system_code); - $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course($user_id, $target_course_code); + $is_subscribed_in_target_course = CourseManager :: is_user_subscribed_in_course(api_get_user_id(), $target_course_code); if ($is_subscribed_in_target_course) { return; //do not display this course entry } } - $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, $user_id); + $has_virtual_courses = CourseManager :: has_virtual_courses_from_code($course_system_code, api_get_user_id()); if ($has_virtual_courses) { - $return_result = CourseManager :: determine_course_title_from_course_info($user_id, $course_info); + $return_result = CourseManager :: determine_course_title_from_course_info(api_get_user_id(), $course_info); $course_display_title = $return_result['title']; $course_display_code = $return_result['code']; } @@ -540,7 +556,7 @@ function get_logged_user_course_html($mycours) $course_display_code = $course_visual_code; } - $s_course_status=$mycours["s"]; + $s_course_status=$my_course["s"]; $s_htlm_status_icon=""; @@ -560,15 +576,19 @@ function get_logged_user_course_html($mycours) //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(api_get_setting('use_session_mode')=='true' && !$nosession){ - if(empty($mycours['id_session'])) - $mycours['id_session'] = 0; + if(api_get_setting('use_session_mode')=='true' && !$nosession) + { + if(empty($my_course['id_session'])) + { + $my_course['id_session'] = 0; + } if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') { - $result .= ''.$course_display_title.''; + $result .= ''.$course_display_title.''; } } - else { + else + { $result .= ''.$course_display_title.''; } } @@ -594,12 +614,12 @@ function get_logged_user_course_html($mycours) $result .= $course_teacher; } // display the what's new icons - $result .= show_notification($mycours); + $result .= show_notification($my_course); /* // get the user's last access dates to all tools of this course $sqlLastTrackInCourse = "SELECT * FROM $statistic_database.track_e_lastaccess" ." WHERE access_user_id = ".$user_id - ." AND access_cours_code = '".$mycours['k']."'"; + ." AND access_cours_code = '".$my_course['k']."'"; $resLastTrackInCourse = api_sql_query($sqlLastTrackInCourse,__FILE__,__LINE__); while($lastTrackInCourse = mysql_fetch_array($resLastTrackInCourse)) { @@ -631,7 +651,7 @@ function get_logged_user_course_html($mycours) $lastDate = date("d/m/Y H:i", convert_mysql_date($lastToolEdit["last_date"])); $type = ($lastToolEdit["type"]=="" || $lastToolEdit["type"]==NULL) ? get_lang('_new_item') : $lastToolEdit["type"]; - $result.= ''. + $result.= ''. ''.$lastToolEdit['image'].''; @@ -689,22 +709,27 @@ function get_logged_user_course_html($mycours) $result .= ""; - if(api_get_setting('use_session_mode')=='true' && !$nosession){ - if(!empty($mycours['session_name'])){ - $session = $mycours['session_name']; - if($date_start=='0000-00-00'){ + if(api_get_setting('use_session_mode')=='true' && !$nosession) + { + if(!empty($my_course['session_name'])) + { + $session = $my_course['session_name']; + if($date_start=='0000-00-00') + { $session .= ' - '.get_lang('Without time limits'); $active = true; } - else { - $session .= ' - '.get_lang('From').' '.$mycours['date_start'].' '.get_lang('To').' '.$mycours['date_end']; + else + { + $session .= ' - '.get_lang('From').' '.$my_course['date_start'].' '.get_lang('To').' '.$my_course['date_end']; $active = ($date_start <= $now && $date_end >= $now)?true:false; } } - $output = array ($mycours['user_course_cat'], $result, $mycours['id_session'], $session, 'active'=>$active); + $output = array ($my_course['user_course_cat'], $result, $my_course['id_session'], $session, 'active'=>$active); } - else { - $output = array ($mycours['user_course_cat'], $result); + else + { + $output = array ($my_course['user_course_cat'], $result); } return $output; } @@ -713,18 +738,18 @@ function get_logged_user_course_html($mycours) * Returns the "what's new" icon notifications * @version */ -function show_notification($mycours) +function show_notification($my_course) { $statistic_database = Database :: get_statistic_database(); $user_id = api_get_user_id(); - $course_database = $mycours['db']; + $course_database = $my_course['db']; $course_tool_table = Database::get_course_table(TOOL_LIST_TABLE, $course_database); $tool_edit_table = Database::get_course_table(LAST_TOOL_EDIT_TABLE, $course_database); $course_group_user_table = Database :: get_course_table(GROUP_USER_TABLE, $course_database); // get the user's last access dates to all tools of this course $sqlLastTrackInCourse = "SELECT * FROM $statistic_database.track_e_lastaccess USE INDEX (access_cours_code, access_user_id) - WHERE access_cours_code = '".$mycours['k']."' + WHERE access_cours_code = '".$my_course['k']."' AND access_user_id = '$user_id'"; $resLastTrackInCourse = api_sql_query($sqlLastTrackInCourse, __FILE__, __LINE__); $oldestTrackDate = "3000-01-01 00:00:00"; @@ -751,7 +776,7 @@ function show_notification($mycours) //filter all selected items while ($res && ($item_property = mysql_fetch_array($res))) { - if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $groups_ids) || $item_property['to_user_id'] == $user_id) && ($item_property['visibility'] == '1' || ($mycours['s'] == '1' && $item_property['visibility'] == '0') || !isset ($item_property['visibility']))) + if ((!isset ($lastTrackInCourseDate[$item_property['tool']]) || $lastTrackInCourseDate[$item_property['tool']] < $item_property['lastedit_date']) && (in_array($item_property['to_group_id'], $groups_ids) || $item_property['to_user_id'] == $user_id) && ($item_property['visibility'] == '1' || ($my_course['s'] == '1' && $item_property['visibility'] == '0') || !isset ($item_property['visibility']))) { $notifications[$item_property['tool']] = $item_property; } @@ -766,7 +791,7 @@ function show_notification($mycours) $type = $notification['lastedit_type']; //$notification[image]=str_replace(".png","gif",$notification[image]); //$notification[image]=str_replace(".gif","_s.gif",$notification[image]); - $retvalue .= ''.' '; + $retvalue .= ''.' '; } } return $retvalue; @@ -802,11 +827,17 @@ function get_user_course_categories() ============================================================================== */ if (!isset ($maxValvas)) +{ $maxValvas = CONFVAL_maxValvasByCourse; // Maximum number of entries +} if (!isset ($maxAgenda)) +{ $maxAgenda = CONFVAL_maxAgendaByCourse; // collected from each course +} if (!isset ($maxCourse)) +{ $maxCourse = CONFVAL_maxTotalByCourse; // and displayed in summary. +} $maxValvas = (int) $maxValvas; $maxAgenda = (int) $maxAgenda; $maxCourse = (int) $maxCourse; // 0 if invalid @@ -869,26 +900,26 @@ else { $personal_course_list = get_personal_course_list($_user['user_id']); } - foreach ($personal_course_list as $mycours) + foreach ($personal_course_list as $my_course) { - $thisCourseDbName = $mycours['db']; - $thisCourseSysCode = $mycours['k']; - $thisCoursePublicCode = $mycours['c']; - $thisCoursePath = $mycours['d']; + $thisCourseDbName = $my_course['db']; + $thisCourseSysCode = $my_course['k']; + $thisCoursePublicCode = $my_course['c']; + $thisCoursePath = $my_course['d']; $sys_course_path = api_get_path(SYS_COURSE_PATH); /* currently disabled functionality, should return $thisCoursePath = $sys_course_path . $thisCoursePath; if(! file_exists($thisCoursePath)) { - echo "
  • ".$mycours['i']."
    "; + echo "
  • ".$my_course['i']."
    "; echo "".get_lang("CourseDoesntExist")." ("; echo "".get_lang("GetCourseFromOldPortal").")
  • "; continue; }*/ - $dbname = $mycours['k']; - $status[$dbname] = $mycours['s']; + $dbname = $my_course['k']; + $status[$dbname] = $my_course['s']; $nbDigestEntries = 0; // number of entries already collected if ($maxCourse < $maxValvas) @@ -903,7 +934,7 @@ else Announcements ----------------------------------------------------------- */ - $course_database = $mycours['db']; + $course_database = $my_course['db']; $course_tool_table = Database::get_course_table(TOOL_LIST_TABLE, $course_database); $query = "SELECT visibility FROM $course_tool_table WHERE link = 'announcements/announcements.php' AND visibility = 1"; $result = api_sql_query($query); @@ -946,7 +977,7 @@ else Agenda ----------------------------------------------------------- */ - $course_database = $mycours['db']; + $course_database = $my_course['db']; $course_tool_table = Database :: get_course_table(TOOL_LIST_TABLE,$course_database); $query = "SELECT visibility FROM $course_tool_table WHERE link = 'calendar/agenda.php' AND visibility = 1"; $result = api_sql_query($query); @@ -981,7 +1012,7 @@ else take collected data and display it ----------------------------------------------------------- */ - $list[] = get_logged_user_course_html($mycours); + $list[] = get_logged_user_course_html($my_course); } //end while mycourse... } diff --git a/webchatdeny.php b/webchatdeny.php index 822c8fc95d..ab5486d230 100644 --- a/webchatdeny.php +++ b/webchatdeny.php @@ -19,17 +19,23 @@ Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com ============================================================================== */ + +/** + * @todo can't this be moved to a different file so that we can delete this file? + * Is this still in use? If not, then it should be removed or maybe offered as an extension + */ /** ============================================================================== * Deletes the web-chat request form the user table -* ============================================================================== */ - +// language files $langFile = "index"; +// including necessary files include_once('./main/inc/global.inc.php'); +// table definitions $track_user_table = Database::get_main_table(MAIN_USER_TABLE); $sql="update $track_user_table set chatcall_user_id = '', chatcall_date = '', chatcall_text='DENIED' where (user_id = ".$_user['user_id'].")"; diff --git a/whoisonline.php b/whoisonline.php index 36827698b1..a0129ee80a 100644 --- a/whoisonline.php +++ b/whoisonline.php @@ -1,4 +1,4 @@ -& FOOTER ============================================================================== */ - Display::display_footer(); ?> \ No newline at end of file diff --git a/whoisonlinesession.php b/whoisonlinesession.php index 2afef03b2b..8107656692 100644 --- a/whoisonlinesession.php +++ b/whoisonlinesession.php @@ -1,11 +1,14 @@ - - ".$online." + echo ' + + '.get_lang('NoOnlineStudents').' - "; + '; } - ?>