course_request_rejected.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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. /**
  31. * Acceptance and creation of the requested course.
  32. */
  33. if (isset($_GET['accept_course']) && $_GET['accept_course'] != '') { // TODO: Secure $_GET['accept_course'].
  34. //Constulta de los datos del curso
  35. $sql = "SELECT * FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id LIKE '".$_GET['accept_course']."'"; // TODO: Why "SELECT ... id LIKE x"? Why not "SELECT ... id = x"?
  36. $result = Database :: query($sql);
  37. $curso_alta = Database :: fetch_array($result);
  38. //Creación del curso
  39. $wanted_code = $curso_alta['code'];
  40. $tutor_name = $curso_alta['tutor_name'];
  41. $category_code = $curso_alta['category_code'];
  42. $title = $curso_alta['title'];
  43. $course_language = $curso_alta['course_language'];
  44. $keys = define_course_keys($wanted_code, '', $_configuration['db_prefix']);
  45. if (sizeof($keys)) {
  46. $visual_code = $keys['currentCourseCode'];
  47. $code = $keys['currentCourseId'];
  48. $db_name = $keys['currentCourseDbName'];
  49. $directory = $keys['currentCourseRepository'];
  50. $expiration_date = time() + $firstExpirationDelay;
  51. prepare_course_repository($directory, $code);
  52. update_Db_course($db_name);
  53. $pictures_array = fill_course_repository($directory);
  54. fill_Db_course($db_name, $directory, $course_language,$pictures_array);
  55. register_course($code, $visual_code, $directory, $db_name, $tutor_name, $category_code, $title, $course_language, $curso_alta['user_id'], $expiration_date);
  56. }
  57. // TODO: Sent the e-mail.
  58. //Una vez creado el curso, cambiamos su estado en la tabla temporal
  59. $sql_temp = "UPDATE ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." SET status = 1 WHERE id LIKE '".$_GET['accept_course']."'";
  60. //$sql_temp = "DELETE FROM ".Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST)." WHERE id LIKE '".$_GET['accept_course']."'";
  61. $result = api_sql_query($sql_temp);
  62. unset ($_GET['accept_course']);
  63. }
  64. /**
  65. * Get the number of courses which will be displayed
  66. */
  67. function get_number_of_courses() {
  68. $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
  69. $sql = "SELECT COUNT(code) AS total_number_of_items FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED;
  70. $res = Database :: query($sql);
  71. $obj = Database :: fetch_object($res);
  72. return $obj->total_number_of_items;
  73. }
  74. /**
  75. * Get course data to display
  76. */
  77. function get_course_data($from, $number_of_items, $column, $direction) {
  78. $course_table = Database :: get_main_table(TABLE_MAIN_COURSE_REQUEST);
  79. $users_table = Database :: get_main_table(TABLE_MAIN_USER);
  80. $course_users_table = Database :: get_main_table(TABLE_MAIN_COURSE_USER);
  81. $sql = "SELECT code AS col0,
  82. title AS col1,
  83. category_code AS col2,
  84. tutor_name AS col3,
  85. request_date AS col4,
  86. id AS col5
  87. FROM $course_table WHERE status = ".COURSE_REQUEST_REJECTED;
  88. $sql .= " ORDER BY col$column $direction ";
  89. $sql .= " LIMIT $from,$number_of_items";
  90. $res = Database :: query($sql);
  91. $courses = array();
  92. while ($course = Database :: fetch_row($res)) {
  93. $courses[] = $course;
  94. }
  95. return $courses;
  96. }
  97. /**
  98. * Actions in the list: edit.
  99. */
  100. function modify_filter($id) {
  101. return
  102. '<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;'.' '.
  103. '<a href="?accept_course='.$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>';
  104. }
  105. $interbreadcrumb[] = array('url' => 'index.php', 'name' => get_lang('PlatformAdmin'));
  106. $tool_name = get_lang('cesga_AdminCursosRexeit'); //nombre que aparece en la barra de navegación
  107. Display :: display_header($tool_name);
  108. //api_display_tool_title($tool_name);
  109. if (isset($_GET['delete_course'])) {
  110. CourseManager :: delete_course($_GET['delete_course']);
  111. }
  112. // Create a sortable table with the course data
  113. $table = new SortableTable('courses', 'get_number_of_courses', 'get_course_data', 2);
  114. $table->set_additional_parameters($parameters);
  115. //$table->set_header(0, '', false);
  116. $table->set_header(0, get_lang('Code'));
  117. $table->set_header(1, get_lang('Title'));
  118. $table->set_header(2, get_lang('Category'));
  119. //$table->set_header(3, get_lang('Teacher'), false);
  120. //$table->set_header(4, get_lang('cesga_AdminFechaSolic'), false);
  121. $table->set_header(3, get_lang('Teacher'));
  122. $table->set_header(4, get_lang('cesga_AdminFechaSolic'));
  123. $table->set_header(5, '', false);
  124. $table->set_column_filter(5, 'modify_filter');
  125. //$table->set_form_actions(array('delete_courses' => get_lang('DeleteCourse')), 'course');
  126. $table->display();
  127. /* FOOTER */
  128. Display :: display_footer();