course_request_review.php 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Con este archivo se editan, se validan, se rechazan o se solicita mas informacion de los cursos que se solicitaron por parte de los profesores y que estan añadidos en la tabla temporal.
  5. * A list containig the pending course requests
  6. * @package chamilo.admin
  7. * @author José Manuel Abuin Mosquera <chema@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. require_once api_get_path(LIBRARY_PATH).'usermanager.lib.php';
  27. // Including a configuration file.
  28. require_once api_get_path(CONFIGURATION_PATH).'add_course.conf.php';
  29. // Including additional libraries.
  30. require_once api_get_path(LIBRARY_PATH).'fileManage.lib.php';
  31. // Filltering passed to this page parameters.
  32. $accept_course_request = intval($_GET['accept_course_request']);
  33. $reject_course_request = intval($_GET['reject_course_request']);
  34. $request_info = intval($_GET['request_info']);
  35. /**
  36. * Coutse acceptance and creation.
  37. */
  38. if (!empty($accept_course_request)) {
  39. $course_id = CourseRequestManager::accept_course_request($accept_course_request);
  40. if ($course_id) {
  41. // TODO: Prepare a confirmation message.
  42. } else {
  43. // Prepare an error message.
  44. }
  45. }
  46. /**
  47. * Course rejection
  48. */
  49. if (isset($_GET['reject_course_request']) && $_GET['reject_course_request'] != '') {
  50. $result = CourseRequestManager::reject_course_request($reject_course_request);
  51. if ($result) {
  52. // TODO: Prepare a confirmation message.
  53. } else {
  54. // Prepare an error message.
  55. }
  56. }
  57. /**
  58. * Sending to the teacher a request for additional information about the proposed course.
  59. */
  60. if (!empty($request_info)) {
  61. CourseRequestManager::ask_for_additional_info($request_info);
  62. }
  63. /**
  64. * Get the number of courses which will be displayed.
  65. */
  66. function get_number_of_courses() {
  67. return CourseRequestManager::count_course_requests(COURSE_REQUEST_PENDING);
  68. }
  69. /**
  70. * Get course data to display
  71. */
  72. function get_course_data($from, $number_of_items, $column, $direction) {
  73. $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
  74. $users_table = Database :: get_main_table(TABLE_MAIN_USER);
  75. $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  76. $sql = "SELECT code AS col0,
  77. code AS col1,
  78. title AS col2,
  79. category_code AS col3,
  80. tutor_name AS col4,
  81. request_date AS col5,
  82. id AS col6
  83. FROM $course_table WHERE status = ".COURSE_REQUEST_PENDING;
  84. $sql .= " ORDER BY col$column $direction ";
  85. $sql .= " LIMIT $from,$number_of_items";
  86. $res = Database::query($sql);
  87. $courses = array();
  88. while ($course = Database::fetch_row($res)) {
  89. $courses[] = $course;
  90. }
  91. return $courses;
  92. }
  93. /**
  94. * Enlace a la ficha del profesor
  95. */
  96. function email_filter($teacher) {
  97. $sql = "SELECT user_id FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE tutor_name LIKE '".$teacher."'";
  98. $res = Database::query($sql);
  99. $info = Database::fetch_array($res);
  100. return '<a href="./user_information.php?user_id='.$info[0].'">'.$teacher.'</a>';
  101. }
  102. /**
  103. * Actions in the list: edit, accept, reject, request additional information.
  104. */
  105. function modify_filter($id) {
  106. /*
  107. return
  108. '<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;'.' '.'<a href="?reject_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.' '.'<a href="?request_info='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('cesga_AdminAlertInfo'), ENT_QUOTES))."'".')) return false;"><img src="../img/cesga_question.gif" border="0" style="vertical-align: middle" title="'.get_lang('cesga_AdminPedirInfo').'" alt="'.get_lang('cesga_AdminPedirInfo').'"/></a>&nbsp;'.' '.'<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>&nbsp;';
  109. */
  110. $sql_request_info = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE (id = ".$id." AND info = 1)";
  111. $res_request_info = Database::query($sql_request_info);
  112. if (Database::num_rows($res_request_info) > 0) { //Si ya se le ha pedido información, no se muestra esa opción
  113. return
  114. '<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;'.' '.'<a href="?reject_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.' '.'<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>&nbsp;';
  115. } else {
  116. return
  117. '<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;'.' '.'<a href="?reject_course_request='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('ConfirmYourChoice'), ENT_QUOTES))."'".')) return false;"><img src="../img/delete.gif" border="0" style="vertical-align: middle" title="'.get_lang('Delete').'" alt="'.get_lang('Delete').'"/></a>'.' '.'<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>'.' '.'<a href="?request_info='.$id.'" onclick="javascript:if(!confirm('."'".addslashes(api_htmlentities(get_lang('cesga_AdminAlertInfo'), ENT_QUOTES))."'".')) return false;"><img src="../img/cesga_question.gif" border="0" style="vertical-align: middle" title="'.get_lang('cesga_AdminPedirInfo').'" alt="'.get_lang('cesga_AdminPedirInfo').'"/></a>&nbsp;&nbsp;';
  118. }
  119. }
  120. if (isset ($_POST['action'])) {
  121. switch ($_POST['action']) {
  122. // Delete selected courses
  123. case 'delete_courses' :
  124. $course_codes = $_POST['course'];
  125. if (count($course_codes) > 0) {
  126. foreach ($course_codes as $index => $course_code) {
  127. //CourseManager :: delete_course($course_code);
  128. $sql = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE code LIKE '".$course_code."'";
  129. //echo $sql;
  130. $result = Database::query($sql);
  131. }
  132. }
  133. break;
  134. }
  135. }
  136. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  137. $tool_name = get_lang('ReviewCourseRequests');
  138. Display :: display_header($tool_name);
  139. //api_display_tool_title($tool_name);
  140. if (isset ($_GET['delete_course'])) {
  141. //CourseManager :: delete_course($_GET['delete_course']);
  142. }
  143. // Create a sortable table with the course data
  144. $table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
  145. $table->set_additional_parameters($parameters);
  146. $table->set_header(0, '', false);
  147. $table->set_header(1, get_lang('Code'));
  148. $table->set_header(2, get_lang('Title'));
  149. $table->set_header(3, get_lang('Category'));
  150. //$table->set_header(4, get_lang('Teacher'), false);
  151. //$table->set_header(5, get_lang('CourseRequestDate'), false);
  152. $table->set_header(4, get_lang('Teacher'));
  153. $table->set_header(5, get_lang('CourseRequestDate'));
  154. $table->set_header(6, '', false);
  155. $table->set_column_filter(4,'email_filter');
  156. $table->set_column_filter(6,'modify_filter');
  157. $table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
  158. $table->display();
  159. /* FOOTER */
  160. Display :: display_footer();