index.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Template (front controller in MVC pattern) used for distpaching
  5. * to the controllers depend on the current action.
  6. *
  7. * @author Christian Fasanando <christian1827@gmail.com>
  8. *
  9. * @package chamilo.course_description
  10. */
  11. require_once __DIR__.'/../inc/global.inc.php';
  12. $current_course_tool = TOOL_COURSE_DESCRIPTION;
  13. // defining constants
  14. define('ADD_BLOCK', 8);
  15. // current section
  16. $this_section = SECTION_COURSES;
  17. $action = !empty($_GET['action']) ? Security::remove_XSS($_GET['action']) : 'listing';
  18. $logInfo = [
  19. 'tool' => TOOL_COURSE_DESCRIPTION,
  20. 'tool_id' => 0,
  21. 'tool_id_detail' => 0,
  22. 'action' => $action,
  23. 'info' => '',
  24. ];
  25. Event::registerLog($logInfo);
  26. // protect a course script
  27. api_protect_course_script(true);
  28. $description_type = '';
  29. if (isset($_GET['description_type'])) {
  30. $description_type = intval($_GET['description_type']);
  31. }
  32. $id = null;
  33. if (isset($_GET['id'])) {
  34. $id = intval($_GET['id']);
  35. }
  36. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  37. $action = 'listing';
  38. }
  39. // interbreadcrumb
  40. $interbreadcrumb[] = ["url" => "index.php?".api_get_cidreq(), "name" => get_lang('Description')];
  41. if ($description_type == 1) {
  42. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Description')];
  43. }
  44. if ($description_type == 2) {
  45. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Objectives')];
  46. }
  47. if ($description_type == 3) {
  48. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Topics')];
  49. }
  50. if ($description_type == 4) {
  51. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Methodology')];
  52. }
  53. if ($description_type == 5) {
  54. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Course material')];
  55. }
  56. if ($description_type == 6) {
  57. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Resources')];
  58. }
  59. if ($description_type == 7) {
  60. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Assessment')];
  61. }
  62. if ($description_type == 8) {
  63. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Thematic advance')];
  64. }
  65. if ($description_type >= 9) {
  66. $interbreadcrumb[] = ["url" => "#", "name" => get_lang('Others')];
  67. }
  68. // course description controller object
  69. $descriptionController = new CourseDescriptionController();
  70. // block access
  71. if (in_array($action, ['add', 'edit', 'delete']) &&
  72. !api_is_allowed_to_edit(null, true)
  73. ) {
  74. api_not_allowed(true);
  75. }
  76. // Actions to controller
  77. switch ($action) {
  78. case 'history':
  79. $descriptionController->listing(true);
  80. break;
  81. case 'add':
  82. $descriptionController->add();
  83. break;
  84. case 'edit':
  85. $descriptionController->edit($id, $description_type);
  86. break;
  87. case 'delete':
  88. $descriptionController->destroy($id);
  89. break;
  90. case 'listing':
  91. default:
  92. $descriptionController->listing();
  93. }