course_request_edit.php 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. global $_configuration;
  87. $dbnamelength = strlen($_configuration['db_prefix']);
  88. // Ensure the database prefix + database name do not get over 40 characters.
  89. $maxlength = 40 - $dbnamelength;
  90. // Build the form.
  91. $form = new FormValidator('add_course');
  92. // Form title.
  93. $form->addElement('header', '', $tool_name);
  94. // Title.
  95. $form->addElement('text', 'title', get_lang('CourseName'), array('size' => '60', 'id' => 'title'));
  96. $form->applyFilter('title', 'html_filter');
  97. // Course category.
  98. $categories_select = $form->addElement('select', 'category_code', get_lang('Fac'), array());
  99. $form->applyFilter('category_code', 'html_filter');
  100. CourseManager::select_and_sort_categories($categories_select);
  101. // Course code.
  102. $form->add_textfield('wanted_code', get_lang('Code'), false, array('size' => '$maxlength', 'maxlength' => $maxlength));
  103. $form->applyFilter('wanted_code', 'html_filter');
  104. $form->addRule('wanted_code', get_lang('Max'), 'maxlength', $maxlength);
  105. // The teacher.
  106. $titular = & $form->add_textfield('tutor_name', get_lang('Professor'), null, array('size' => '60', 'disabled' => 'disabled'));
  107. //$form->applyFilter('tutor_name', 'html_filter');
  108. // Description of the requested course.
  109. $form->addElement('textarea', 'description', get_lang('Description'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
  110. $form->addRule('description', get_lang('ThisFieldIsRequired'), 'required', '', '');
  111. // Objectives of the requested course.
  112. $form->addElement('textarea', 'objetives', get_lang('Objectives'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
  113. $form->addRule('objetives', get_lang('ThisFieldIsRequired'), 'required', '', '');
  114. // Target audience of the requested course.
  115. $form->addElement('textarea', 'target_audience', get_lang('TargetAudience'), array('style' => 'border:#A5ACB2 solid 1px; font-family:arial,verdana,helvetica,sans-serif; font-size:12px', 'rows' => '3', 'cols' => '116'));
  116. $form->addRule('target_audience', get_lang('ThisFieldIsRequired'), 'required', '', '');
  117. // Course language.
  118. $form->addElement('select_language', 'course_language', get_lang('Ln'));
  119. $form->applyFilter('select_language', 'html_filter');
  120. // Submit buttons.
  121. $submit_buttons[] = FormValidator::createElement('style_submit_button', 'save_button', get_lang('Save'), array('class' => 'save'));
  122. $submit_buttons[] = FormValidator::createElement('style_submit_button', 'accept_button', get_lang('Accept'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'action_accept.gif);'));
  123. $submit_buttons[] = FormValidator::createElement('style_submit_button', 'reject_button', get_lang('Reject'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'action_reject.gif);'));
  124. $submit_buttons[] = FormValidator::createElement('style_submit_button', 'ask_info_button', get_lang('AskAdditionalInfo'), array('class' => 'save', 'style' => 'background-image: url('.api_get_path(WEB_IMG_PATH).'request_info.gif);'));
  125. $form->addGroup($submit_buttons);
  126. // Set the default values based on the corresponding database record.
  127. //...
  128. // Validate the form and perform the ordered actions.
  129. //...
  130. // Display the form.
  131. $form->display();
  132. // The footer.
  133. Display :: display_footer();