index.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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. * @author Christian Fasanando <christian1827@gmail.com>
  7. * @package chamilo.course_description
  8. */
  9. require_once '../inc/global.inc.php';
  10. $current_course_tool = TOOL_COURSE_DESCRIPTION;
  11. // defining constants
  12. define('ADD_BLOCK', 8);
  13. // current section
  14. $this_section = SECTION_COURSES;
  15. // protect a course script
  16. api_protect_course_script(true);
  17. // get actions
  18. $actions = array('listing', 'add', 'edit', 'delete', 'history');
  19. $action = 'listing';
  20. if (isset($_GET['action']) && in_array($_GET['action'],$actions)) {
  21. $action = $_GET['action'];
  22. }
  23. $description_type = '';
  24. if (isset($_GET['description_type'])) {
  25. $description_type = intval($_GET['description_type']);
  26. }
  27. $id = null;
  28. if (isset($_GET['id'])) {
  29. $id = intval($_GET['id']);
  30. }
  31. if (isset($_GET['isStudentView']) && $_GET['isStudentView'] == 'true') {
  32. $action = 'listing';
  33. }
  34. // interbreadcrumb
  35. $interbreadcrumb[] = array ("url" => "index.php", "name" => get_lang('CourseProgram'));
  36. if ($description_type == 1) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('GeneralDescription'));
  37. if ($description_type == 2) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Objectives'));
  38. if ($description_type == 3) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Topics'));
  39. if ($description_type == 4) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Methodology'));
  40. if ($description_type == 5) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('CourseMaterial'));
  41. if ($description_type == 6) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('HumanAndTechnicalResources'));
  42. if ($description_type == 7) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Assessment'));
  43. if ($description_type == 8) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('ThematicAdvance'));
  44. if ($description_type >= 9) $interbreadcrumb[] = array ("url" => "#", "name" => get_lang('Others'));
  45. // course description controller object
  46. $course_description_controller = new CourseDescriptionController();
  47. // distpacher actions to controller
  48. switch ($action) {
  49. case 'listing':
  50. $course_description_controller->listing();
  51. break;
  52. case 'history':
  53. $course_description_controller->listing(true);
  54. break;
  55. case 'add':
  56. if (api_is_allowed_to_edit(null, true)) {
  57. $course_description_controller->add();
  58. }
  59. break;
  60. case 'edit':
  61. if (api_is_allowed_to_edit(null, true)) {
  62. $course_description_controller->edit($id, $description_type);
  63. }
  64. break;
  65. case 'delete':
  66. if (api_is_allowed_to_edit(null, true)) {
  67. $course_description_controller->destroy($id);
  68. }
  69. break;
  70. default:
  71. $course_description_controller->listing();
  72. }