course_request_rejected.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * A list containig the rejected course requests
  5. * @package chamilo.admin
  6. * @author José Manuel Abuin Mosquera <chema@cesga.es>, 2010
  7. * @author Bruno Rubio Gayo <brubio@cesga.es>, 2010
  8. * Centro de Supercomputacion de Galicia (CESGA)
  9. *
  10. * @author Ivan Tcholakov <ivantcholakov@gmail.com> (technical adaptation for Chamilo 1.8.8), 2010
  11. */
  12. /* INIT SECTION */
  13. // Language files that need to be included.
  14. $language_file = array('admin', 'create_course');
  15. $cidReset = true;
  16. require '../inc/global.inc.php';
  17. $this_section = SECTION_PLATFORM_ADMIN;
  18. api_protect_admin_script();
  19. require_once api_get_path(LIBRARY_PATH).'add_course.lib.inc.php';
  20. require_once api_get_path(CONFIGURATION_PATH).'course_info.conf.php';
  21. require_once api_get_path(LIBRARY_PATH).'course.lib.php';
  22. require_once api_get_path(LIBRARY_PATH).'course_request.lib.php';
  23. require_once api_get_path(LIBRARY_PATH).'mail.lib.inc.php';
  24. require_once api_get_path(LIBRARY_PATH).'formvalidator/FormValidator.class.php';
  25. require_once api_get_path(LIBRARY_PATH).'sortabletable.class.php';
  26. // Including a configuration file.
  27. require api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
  28. // Including additional libraries.
  29. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  30. // Filltering passed to this page parameters.
  31. $accept_course_request = intval($_GET['accept_course_request']);
  32. $request_info = intval($_GET['request_info']);
  33. /**
  34. * Acceptance and creation of the requested course.
  35. */
  36. if (!empty($accept_course_request)) {
  37. $course_id = CourseRequestManager::accept_course_request($accept_course_request);
  38. if ($course_id) {
  39. // TODO: Prepare a confirmation message.
  40. } else {
  41. // Prepare an error message.
  42. }
  43. }
  44. /**
  45. * Sending to the teacher a request for additional information about the proposed course.
  46. */
  47. if (!empty($request_info)) {
  48. CourseRequestManager::ask_for_additional_info($request_info);
  49. }
  50. /**
  51. * Get the number of courses which will be displayed.
  52. */
  53. function get_number_of_courses() {
  54. return CourseRequestManager::count_course_requests(COURSE_REQUEST_REJECTED);
  55. }
  56. /**
  57. * Get course data to display
  58. */
  59. function get_course_data($from, $number_of_items, $column, $direction) {
  60. $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
  61. $users_table = Database :: get_main_table(TABLE_MAIN_USER);
  62. $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  63. $sql = "SELECT code AS col0,
  64. title AS col1,
  65. category_code AS col2,
  66. tutor_name AS col3,
  67. request_date AS col4,
  68. id AS col5
  69. FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED;
  70. $sql .= " ORDER BY col$column $direction ";
  71. $sql .= " LIMIT $from,$number_of_items";
  72. $res = Database :: query($sql);
  73. $courses = array();
  74. while ($course = Database :: fetch_row($res)) {
  75. $courses[] = $course;
  76. }
  77. return $courses;
  78. }
  79. /**
  80. * Actions in the list: edit.
  81. */
  82. function modify_filter($id) {
  83. return
  84. '<a href="editar_curso.php?id='.$id.'"><img src="../img/edit.gif" border="0" style="vertical-align: middle" title="'.get_lang('Edit').'" alt="'.get_lang('Edit').'"/></a>&nbsp;'.' '.
  85. '<a href="?accept_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('cesga_AdminAlertCrear'), ENT_QUOTES))."'".')) return false;"><img src="../img/right.gif" border="0" style="vertical-align: middle" title="'.get_lang('cesga_AdminValidar').'" alt="'.get_lang('cesga_AdminValidar').'"/></a>';
  86. }
  87. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  88. $tool_name = get_lang('RejectedCourseRequests');
  89. Display :: display_header($tool_name);
  90. //api_display_tool_title($tool_name);
  91. if (isset($_GET['delete_course'])) {
  92. CourseManager :: delete_course($_GET['delete_course']);
  93. }
  94. // Create a sortable table with the course data
  95. $table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
  96. $table->set_additional_parameters($parameters);
  97. //$table->set_header(0, '', false);
  98. $table->set_header(0, get_lang('Code'));
  99. $table->set_header(1, get_lang('Title'));
  100. $table->set_header(2, get_lang('Category'));
  101. //$table->set_header(3, get_lang('Teacher'), false);
  102. //$table->set_header(4, get_lang('CourseRequestDate'), false);
  103. $table->set_header(3, get_lang('Teacher'));
  104. $table->set_header(4, get_lang('CourseRequestDate'));
  105. $table->set_header(5, '', false);
  106. $table->set_column_filter(5, 'modify_filter');
  107. //$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
  108. $table->display();
  109. /* FOOTER */
  110. Display :: display_footer();