Selaa lähdekoodia

[svn r11792] correct display messages
correct redirect after creating course
code cleanup

Patrick Cool 18 vuotta sitten
vanhempi
commit
86826fd04a
1 muutettua tiedostoa jossa 20 lisäystä ja 31 poistoa
  1. 20 31
      main/create_course/add_course.php

+ 20 - 31
main/create_course/add_course.php

@@ -1,5 +1,5 @@
 <?php
 <?php
-// $Id: add_course.php 11733 2007-03-27 14:57:47Z fvauthier $
+// $Id: add_course.php 11792 2007-03-30 07:17:11Z pcool $
 /*
 /*
 ==============================================================================
 ==============================================================================
 	Dokeos - elearning and course management software
 	Dokeos - elearning and course management software
@@ -26,53 +26,47 @@
 /**
 /**
 ==============================================================================
 ==============================================================================
 * This script allows professors and administrative staff to create course sites.
 * This script allows professors and administrative staff to create course sites.
-* @author X X main author
+* @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
 * @author Roan Embrechts, refactoring
 * @author Roan Embrechts, refactoring
 * @package dokeos.create_course
 * @package dokeos.create_course
 ==============================================================================
 ==============================================================================
 */
 */
-/*
-==============================================================================
-		INIT SECTION
-==============================================================================
-*/
+
 // name of the language file that needs to be included 
 // name of the language file that needs to be included 
 $language_file = "create_course";
 $language_file = "create_course";
+
+// including the global file
 include ('../inc/global.inc.php');
 include ('../inc/global.inc.php');
 
 
+// section for the tabs
 $this_section=SECTION_COURSES;
 $this_section=SECTION_COURSES;
 
 
+// include configuration file
 include (api_get_path(CONFIGURATION_PATH).'add_course.conf.php');
 include (api_get_path(CONFIGURATION_PATH).'add_course.conf.php');
-/*
------------------------------------------------------------
-	Libraries
------------------------------------------------------------
-*/
 
 
+// include additional libraries
 include_once (api_get_path(LIBRARY_PATH).'add_course.lib.inc.php');
 include_once (api_get_path(LIBRARY_PATH).'add_course.lib.inc.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).'fileManage.lib.php');
 include_once (api_get_path(LIBRARY_PATH).'fileManage.lib.php');
 include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
 include_once (api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php');
 include_once (api_get_path(CONFIGURATION_PATH).'course_info.conf.php');
 include_once (api_get_path(CONFIGURATION_PATH).'course_info.conf.php');
 
 
-/*
-==============================================================================
-		MAIN CODE
-==============================================================================
-*/
+// Displaying the header
 $tool_name = get_lang('CreateSite');
 $tool_name = get_lang('CreateSite');
 Display :: display_header($tool_name);
 Display :: display_header($tool_name);
+
+// Displaying the tool title
 api_display_tool_title($tool_name);
 api_display_tool_title($tool_name);
 // Check access rights
 // Check access rights
 if (!api_is_allowed_to_create_course())
 if (!api_is_allowed_to_create_course())
 {
 {
-	Display :: display_normal_message(get_lang("NotAllowed"));
+	Display :: display_error_message(get_lang("NotAllowed"));
 	Display::display_footer();
 	Display::display_footer();
 	exit;
 	exit;
 }
 }
 // Get all course categories
 // Get all course categories
-$table_course_category = Database :: get_main_table(TABLE_MAIN_CATEGORY);
-$table_course = Database :: get_main_table(TABLE_MAIN_COURSE);
+$table_course_category 	= Database :: get_main_table(TABLE_MAIN_CATEGORY);
+$table_course 			= Database :: get_main_table(TABLE_MAIN_COURSE);
 
 
 $sql = "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE' ORDER BY tree_pos";
 $sql = "SELECT code,name FROM ".$table_course_category." WHERE auth_course_child ='TRUE' ORDER BY tree_pos";
 $res = api_sql_query($sql, __FILE__, __LINE__);
 $res = api_sql_query($sql, __FILE__, __LINE__);
@@ -94,10 +88,12 @@ $form->addElement('submit', null, get_lang('Ok'));
 $form->add_progress_bar();
 $form->add_progress_bar();
 
 
 // Set default values
 // Set default values
-if(isset($_user["language"]) && $_user["language"]!=""){
+if(isset($_user["language"]) && $_user["language"]!="")
+{
 	$values['course_language'] = $_user["language"];
 	$values['course_language'] = $_user["language"];
 }
 }
-else{
+else
+{
 	$values['course_language'] = get_setting('platformLanguage');
 	$values['course_language'] = get_setting('platformLanguage');
 }
 }
 
 
@@ -134,15 +130,8 @@ if($form->validate())
 		$message = get_lang('JustCreated');
 		$message = get_lang('JustCreated');
 		$message .= " <strong>".$course_values['wanted_code']."</strong>";
 		$message .= " <strong>".$course_values['wanted_code']."</strong>";
 		$message .= "<br/><br/>";
 		$message .= "<br/><br/>";
-		$message .= '<a href="'.api_get_path(WEB_PATH).'user_portal.php">'.get_lang('Enter').'</a>';
-		Display :: display_normal_message($message,false);
-	}
-	else{
-				Display :: display_error_message(get_lang('CourseCodeAlreadyExist'),false);
-		$form->display();
-		echo '<p>'.get_lang('CourseCodeAlreadyExistExplained').'</p>';
-	}
-		
+	$message .= '<a href="'.api_get_path(WEB_PATH).api_get_setting('page_after_login').'">'.get_lang('Enter').'</a>';
+	Display :: display_confirmation_message($message,false);
 }
 }
 else
 else
 {
 {