소스 검색

Feature #2099 - Coding the page for editition training requests (3).

Ivan Tcholakov 14 년 전
부모
커밋
787b51f40f
4개의 변경된 파일51개의 추가작업 그리고 15개의 파일을 삭제
  1. 47 11
      main/admin/course_request_edit.php
  2. 2 4
      main/create_course/add_course.php
  3. 1 0
      main/lang/bulgarian/create_course.inc.php
  4. 1 0
      main/lang/english/create_course.inc.php

+ 47 - 11
main/admin/course_request_edit.php

@@ -7,7 +7,7 @@
  * @author Ivan Tcholakov <ivantcholakov@gmail.com>, 2010
  */
 
-/* INIT SECTION */
+// Initialization section.
 
 // Language files that need to be included.
 $language_file = array('admin', 'create_course');
@@ -40,19 +40,22 @@ $course_validation_feature = api_get_setting('course_validation') == 'true';
 $id = intval($_GET['id']);
 $caller = intval($_GET['caller']);
 
-// Code for testing purposes, to be removed.
-$message = 'id = '.$id.';<br />caller = "'.get_caller_name($caller).'";';
-$is_error_message = false;
-
 if ($course_validation_feature) {
 
-    // Actions, if any.
+    // Retrieve request's data from the corresponding database record.
+    $course_request_info = CourseRequestManager::get_course_request_info($id);
+    if (!is_array($course_request_info)) {
+        // Prepare an error message notifying that the course request has not been found or does not exist.
+        $message = get_lang('CourseRequestHasNotBeenFound');
+        $is_error_message = true;
+    }
 
 } else {
 
-   $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
-   $message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation')));
-   $is_error_message = true;
+    // Prepare an error message notifying that the course validation feature has not been enabled.
+    $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
+    $message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation')));
+    $is_error_message = true;
 
 }
 
@@ -84,6 +87,7 @@ if (!empty($message)) {
 }
 
 if (!$course_validation_feature) {
+    // Disabled course validation feature - show nothing after the error message.
     Display :: display_footer();
     exit;
 }
@@ -96,10 +100,42 @@ echo '<a href="course_request_accepted.php">'.Display::return_icon('course_reque
 echo '<a href="course_request_rejected.php">'.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').'</a>';
 echo '</div>';
 
-// The form.
+if (!is_array($course_request_info)) {
+    // Not accessible database record - show the error message and the action bar.
+    Display :: display_footer();
+    exit;
+}
+
+// Build the form.
+$form = new FormValidator('add_course');
+
+// Form title.
+$form->addElement('header', '', $tool_name);
+
+// Title
+$form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title'));
+$form->applyFilter('title', 'html_filter');
+$form->addElement('static', null, null, get_lang('Ex'));
+
+$categories_select = $form->addElement('select', 'category_code', get_lang('Fac'), array());
+$form->applyFilter('category_code', 'html_filter');
+CourseManager::select_and_sort_categories($categories_select);
+$form->addElement('static', null, null, get_lang('TargetFac'));
+
+// Other form's elements...
 
 //...
 
+// Set the default values based on the corresponding database record.
+
+//...
+
+// Validate the form and perform the ordered actions.
+
+//...
+
+// Display the form.
+$form->display();
+
 // The footer.
 Display :: display_footer();
-

+ 2 - 4
main/create_course/add_course.php

@@ -76,7 +76,6 @@ $dbnamelength = strlen($_configuration['db_prefix']);
 $maxlength = 40 - $dbnamelength;
 
 // Build the form.
-$categories = array();
 $form = new FormValidator('add_course');
 
 // Form title
@@ -85,11 +84,10 @@ $form->addElement('header', '', $tool_name);
 // Title
 $form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title'));
 $form->applyFilter('title', 'html_filter');
-
 $form->addElement('static', null, null, get_lang('Ex'));
-$categories_select = $form->addElement('select', 'category_code', get_lang('Fac'), $categories);
-$form->applyFilter('category_code', 'html_filter');
 
+$categories_select = $form->addElement('select', 'category_code', get_lang('Fac'), array());
+$form->applyFilter('category_code', 'html_filter');
 CourseManager::select_and_sort_categories($categories_select);
 $form->addElement('static', null, null, get_lang('TargetFac'));
 

+ 1 - 0
main/lang/bulgarian/create_course.inc.php

@@ -145,4 +145,5 @@ $CourseRequestRejectedEmailText = "За съжаление Вашата заяв
 $CourseCreationFailed = "Курсът не е създаден поради появила се грешка.";
 $CourseRequestCreationFailed = "Заявката за нов курс не е създадена поради появила се грешка.";
 $CourseRequestEdit = "Редактиране на заявка за нов курс";
+$CourseRequestHasNotBeenFound = "Заявката за нов курс, до която искате достъп не е намерена или не съществува.";
 ?>

+ 1 - 0
main/lang/english/create_course.inc.php

@@ -145,4 +145,5 @@ $CourseRequestRejectedEmailText = "To our regret we have to inform you that the
 $CourseCreationFailed = "The training has not been created due to internal error.";
 $CourseRequestCreationFailed = "The training request has not been created due to internal error.";
 $CourseRequestEdit = "Edit a training request";
+$CourseRequestHasNotBeenFound = "The training request you wanted to access has not been found or it does not exist.";
 ?>