From a8bbe1c6c7bc3eb97044c7430cb1daab8683e3ab Mon Sep 17 00:00:00 2001 From: Isaac Flores Date: Wed, 26 Nov 2008 00:37:07 +0100 Subject: [PATCH] [svn r16922] Added general option to prevent course creation --- user_portal.php | 319 ++++++++++++++++-------------------------------- 1 file changed, 108 insertions(+), 211 deletions(-) diff --git a/user_portal.php b/user_portal.php index 6eb98ff4f2..d411e55e40 100644 --- a/user_portal.php +++ b/user_portal.php @@ -138,12 +138,10 @@ else { $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 = false; - } - else { + } else { $display_actives = true; } } @@ -156,10 +154,9 @@ $this_section = SECTION_COURSES; Check configuration parameters integrity ----------------------------------------------------------- */ -if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != "keyCourse") -{ +if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != "keyCourse") { // CONFVAL_showExtractInfo must be SCRIPTVAL_UnderCourseList to accept $orderKey[0] !="keyCourse" - if (DEBUG || api_is_platform_admin()) // Show bug if admin. Else force a new order + if (DEBUG || api_is_platform_admin()){ // Show bug if admin. Else force a new order die(' config error:'.__FILE__.'
set @@ -176,8 +173,7 @@ if (CONFVAL_showExtractInfo != SCRIPTVAL_UnderCourseList and $orderKey[0] != "ke (actually : '.$orderKey[0].') '); - else - { + }else { $orderKey = array ('keyCourse', 'keyTools', 'keyTime'); } } @@ -218,8 +214,7 @@ Display :: display_header($nameTools); * @param $user_id, the id of the user * @return an array with courses */ -function get_personal_course_list($user_id) -{ +function get_personal_course_list($user_id) { // initialisation $personal_course_list = array(); @@ -244,8 +239,7 @@ function get_personal_course_list($user_id) $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__); - while ($result_row = mysql_fetch_array($course_list_sql_result)) - { + while ($result_row = Database::fetch_array($course_list_sql_result)) { $personal_course_list[] = $result_row; } @@ -257,8 +251,7 @@ function get_personal_course_list($user_id) $course_list_sql_result = api_sql_query($personal_course_list_sql, __FILE__, __LINE__); - while ($result_row = mysql_fetch_array($course_list_sql_result)) - { + while ($result_row = Database::fetch_array($course_list_sql_result)) { $personal_course_list[] = $result_row; } @@ -272,8 +265,7 @@ function get_personal_course_list($user_id) //$personal_course_list = array_merge($personal_course_list, $course_list_sql_result); - while ($result_row = mysql_fetch_array($course_list_sql_result)) - { + while ($result_row = Database::fetch_array($course_list_sql_result)) { $personal_course_list[] = $result_row; } return $personal_course_list; @@ -290,8 +282,7 @@ function get_personal_course_list($user_id) * Warning: this function defines a global. * @todo use the correct get_path function */ -function display_admin_links() -{ +function display_admin_links() { global $rootAdminWeb; echo "
  • ".get_lang('PlatformAdmin')."
  • "; } @@ -299,16 +290,14 @@ function display_admin_links() * Enter description here... * */ -function display_create_course_link() -{ +function display_create_course_link() { echo "
  • ".get_lang('CourseCreate')."
  • "; } /** * Enter description here... * */ -function display_edit_course_list_links() -{ +function display_edit_course_list_links() { echo "
  • ".get_lang('CourseManagement')."
  • "; } @@ -320,53 +309,38 @@ function display_edit_course_list_links() * * @version 1.0 */ -function display_digest($toolsList, $digest, $orderKey, $courses) -{ - if (is_array($digest) && (CONFVAL_showExtractInfo == SCRIPTVAL_UnderCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both)) - { +function display_digest($toolsList, $digest, $orderKey, $courses) { + if (is_array($digest) && (CONFVAL_showExtractInfo == SCRIPTVAL_UnderCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both)) { // // // LEVEL 1 // // // reset($digest); echo "

    \n"; - while (list ($key1) = each($digest)) - { - if (is_array($digest[$key1])) - { + while (list ($key1) = each($digest)) { + if (is_array($digest[$key1])) { // // // Title of LEVEL 1 // // // echo "\n"; - if ($orderKey[0] == 'keyTools') - { + if ($orderKey[0] == 'keyTools') { $tools = $key1; echo $toolsList[$key1]['name']; - } - elseif ($orderKey[0] == 'keyCourse') - { + } elseif ($orderKey[0] == 'keyCourse') { $courseSysCode = $key1; echo "", $courses[$key1]['courseCode'], "\n"; - } - elseif ($orderKey[0] == 'keyTime') - { + } elseif ($orderKey[0] == 'keyTime') { echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($digest[$key1])); } echo "\n"; // // // End Of Title of LEVEL 1 // // // // // // LEVEL 2 // // // reset($digest[$key1]); - while (list ($key2) = each($digest[$key1])) - { + while (list ($key2) = each($digest[$key1])) { // // // Title of LEVEL 2 // // // echo "

    \n", "\n"; - if ($orderKey[1] == 'keyTools') - { + if ($orderKey[1] == 'keyTools') { $tools = $key2; echo $toolsList[$key2][name]; - } - elseif ($orderKey[1] == 'keyCourse') - { + } elseif ($orderKey[1] == 'keyCourse') { $courseSysCode = $key2; echo "", $courses[$key2]['courseCode'], "\n"; - } - elseif ($orderKey[1] == 'keyTime') - { + } elseif ($orderKey[1] == 'keyTime') { echo format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key2)); } echo "\n"; @@ -374,30 +348,22 @@ function display_digest($toolsList, $digest, $orderKey, $courses) // // // End Of Title of LEVEL 2 // // // // // // LEVEL 3 // // // reset($digest[$key1][$key2]); - while (list ($key3, $dataFromCourse) = each($digest[$key1][$key2])) - { + while (list ($key3, $dataFromCourse) = each($digest[$key1][$key2])) { // // // Title of LEVEL 3 // // // - if ($orderKey[2] == 'keyTools') - { + if ($orderKey[2] == 'keyTools') { $level3title = "".$toolsList[$key3]['name'].""; - } - elseif ($orderKey[2] == 'keyCourse') - { + } elseif ($orderKey[2] == 'keyCourse') { $level3title = "• ".$courses[$key3]['courseCode']."\n"; - } - elseif ($orderKey[2] == 'keyTime') - { + } elseif ($orderKey[2] == 'keyTime') { $level3title = "• ".format_locale_date(CONFVAL_dateFormatForInfosFromCourses, strtotime($key3)).""; } // // // End Of Title of LEVEL 3 // // // // // // LEVEL 4 (data) // // // reset($digest[$key1][$key2][$key3]); - while (list ($key4, $dataFromCourse) = each($digest[$key1][$key2][$key3])) - { + while (list ($key4, $dataFromCourse) = each($digest[$key1][$key2][$key3])) { echo $level3title, ' – ', substr(strip_tags($dataFromCourse), 0, CONFVAL_NB_CHAR_FROM_CONTENT); //adding ... (three dots) if the texts are too large and they are shortened - if (strlen($dataFromCourse) >= CONFVAL_NB_CHAR_FROM_CONTENT) - { + if (strlen($dataFromCourse) >= CONFVAL_NB_CHAR_FROM_CONTENT) { echo '...'; } } @@ -425,12 +391,10 @@ function display_digest($toolsList, $digest, $orderKey, $courses) * @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($my_course) -{ +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; } @@ -462,27 +426,22 @@ function get_logged_user_course_html($my_course) //function logic - act on the data $is_virtual_course = CourseManager :: is_virtual_course_from_system_code($my_course['k']); - if ($is_virtual_course) - { + 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(api_get_user_id(), $target_course_code); - if ($is_subscribed_in_target_course) - { + 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, api_get_user_id()); - if ($has_virtual_courses) - { + if ($has_virtual_courses) { $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']; - } - else - { + } else { $course_display_title = $course_title; $course_display_code = $course_visual_code; } @@ -491,16 +450,13 @@ function get_logged_user_course_html($my_course) $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')); } - if($s_course_status==2) - { + if ($s_course_status==2) { $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')); } @@ -508,46 +464,33 @@ function get_logged_user_course_html($my_course) $result.="\n\t"; $result .= '

  • '.$s_htlm_status_icon.'
    '; //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($my_course['id_session'])) - { + if ($course_visibility != COURSE_VISIBILITY_CLOSED || $user_in_course_status == COURSEMANAGER) { + 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') - { + if($user_in_course_status == COURSEMANAGER || ($date_start <= $now && $date_end >= $now) || $date_start=='0000-00-00') { $result .= ''.$course_display_title.''; } - } - else - { + } else { $result .= ''.$course_display_title.''; } - } - else - { + } else { $result .= $course_display_title." "." ".get_lang('CourseClosed').""; } // show the course_code and teacher if chosen to display this - if (get_setting('display_coursecode_in_courselist') == 'true' OR get_setting('display_teacher_in_courselist') == 'true') - { + if (get_setting('display_coursecode_in_courselist') == 'true' OR get_setting('display_teacher_in_courselist') == 'true') { $result .= '
    '; } - if (get_setting('display_coursecode_in_courselist') == 'true') - { + if (get_setting('display_coursecode_in_courselist') == 'true') { $result .= $course_display_code; } - if (get_setting('display_coursecode_in_courselist') == 'true' AND get_setting('display_teacher_in_courselist') == 'true') - { + if (get_setting('display_coursecode_in_courselist') == 'true' AND get_setting('display_teacher_in_courselist') == 'true') { $result .= ' – '; } - if (get_setting('display_teacher_in_courselist') == 'true') - { + if (get_setting('display_teacher_in_courselist') == 'true') { $result .= $course_teacher; - if(!empty($course_teacher_email)) - { + if(!empty($course_teacher_email)) { $result .= ' ('.$course_teacher_email.')'; } } @@ -558,42 +501,32 @@ function get_logged_user_course_html($my_course) // display the what's new icons $result .= show_notification($my_course); - if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) - { + if ((CONFVAL_showExtractInfo == SCRIPTVAL_InCourseList || CONFVAL_showExtractInfo == SCRIPTVAL_Both) && $nbDigestEntries > 0) { reset($digest); $result .= '