course_request_edit.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * A page for detailed preview or edition of a given course request.
  5. * @package chamilo.admin
  6. * @author Ivan Tcholakov <ivantcholakov@gmail.com>, 2010
  7. */
  8. // Initialization section.
  9. // Language files that need to be included.
  10. $language_file = array('admin', 'create_course');
  11. $cidReset = true;
  12. require '../inc/global.inc.php';
  13. $this_section = SECTION_PLATFORM_ADMIN;
  14. api_protect_admin_script();
  15. require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
  16. require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php';
  17. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  18. require_once api_get_path(LIBRARY_PATH).'course_request.lib.php';
  19. require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  20. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  21. require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
  22. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  23. // Including a configuration file.
  24. require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
  25. // Including additional libraries.
  26. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  27. // A check whether the course validation feature is enabled.
  28. $course_validation_feature = api_get_setting('course_validation') == 'true';
  29. // Filltering passed to this page parameters.
  30. $id = intval($_GET['id']);
  31. $caller = intval($_GET['caller']);
  32. if ($course_validation_feature) {
  33. // Retrieve request's data from the corresponding database record.
  34. $course_request_info = CourseRequestManager::get_course_request_info($id);
  35. if (!is_array($course_request_info)) {
  36. // Prepare an error message notifying that the course request has not been found or does not exist.
  37. $message = get_lang('CourseRequestHasNotBeenFound');
  38. $is_error_message = true;
  39. }
  40. } else {
  41. // Prepare an error message notifying that the course validation feature has not been enabled.
  42. $link_to_setting = api_get_path(WEB_CODE_PATH).'admin/settings.php?category=Platform#course_validation';
  43. $message = sprintf(get_lang('PleaseActivateCourseValidationFeature'), sprintf('<strong><a href="%s">%s</a></strong>', $link_to_setting, get_lang('EnableCourseValidation')));
  44. $is_error_message = true;
  45. }
  46. // Functions.
  47. // Converts the given numerical id to the name of the page that opened this editor.
  48. function get_caller_name($caller_id) {
  49. switch ($caller_id) {
  50. case 1:
  51. return 'course_request_accepted.php';
  52. case 2:
  53. return 'course_request_rejected.php';
  54. }
  55. return 'course_request_review.php';
  56. }
  57. // The header.
  58. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  59. $tool_name = get_lang('CourseRequestEdit');
  60. Display :: display_header($tool_name);
  61. // Display confirmation or error message.
  62. if (!empty($message)) {
  63. if ($is_error_message) {
  64. Display::display_error_message($message, false);
  65. } else {
  66. Display::display_normal_message($message, false);
  67. }
  68. }
  69. if (!$course_validation_feature) {
  70. // Disabled course validation feature - show nothing after the error message.
  71. Display :: display_footer();
  72. exit;
  73. }
  74. // The action bar.
  75. echo '<div class="actions">';
  76. echo '<a href="course_list.php">'.Display::return_icon('courses.gif', get_lang('CourseList')).get_lang('CourseList').'</a>';
  77. echo '<a href="course_request_review.php">'.Display::return_icon('course_request_pending.png', get_lang('ReviewCourseRequests')).get_lang('ReviewCourseRequests').'</a>';
  78. echo '<a href="course_request_accepted.php">'.Display::return_icon('course_request_accepted.gif', get_lang('AcceptedCourseRequests')).get_lang('AcceptedCourseRequests').'</a>';
  79. echo '<a href="course_request_rejected.php">'.Display::return_icon('course_request_rejected.gif', get_lang('RejectedCourseRequests')).get_lang('RejectedCourseRequests').'</a>';
  80. echo '</div>';
  81. if (!is_array($course_request_info)) {
  82. // Not accessible database record - show the error message and the action bar.
  83. Display :: display_footer();
  84. exit;
  85. }
  86. // Build the form.
  87. $form = new FormValidator('add_course');
  88. // Form title.
  89. $form->addElement('header', '', $tool_name);
  90. // Title
  91. $form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title'));
  92. $form->applyFilter('title', 'html_filter');
  93. $form->addElement('static', null, null, get_lang('Ex'));
  94. $categories_select = $form->addElement('select', 'category_code', get_lang('Fac'), array());
  95. $form->applyFilter('category_code', 'html_filter');
  96. CourseManager::select_and_sort_categories($categories_select);
  97. $form->addElement('static', null, null, get_lang('TargetFac'));
  98. // Other form's elements...
  99. //...
  100. // Set the default values based on the corresponding database record.
  101. //...
  102. // Validate the form and perform the ordered actions.
  103. //...
  104. // Display the form.
  105. $form->display();
  106. // The footer.
  107. Display :: display_footer();