request.class.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Course description's request class definition
  5. * @package chamilo.course_description
  6. */
  7. /**
  8. * Init
  9. */
  10. namespace CourseDescription;
  11. /**
  12. * Html request for course description.
  13. *
  14. * @author Laurent Opprecht <laurent@opprecht.info> for the Univesity of Genevas
  15. * @license /license.txt
  16. */
  17. class Request extends \Request
  18. {
  19. const PARAM_ID = 'id';
  20. const PARAM_IDS = 'ids';
  21. const PARAM_C_ID = 'c_id';
  22. const PARAM_SESSION_ID = 'id_session';
  23. const PARAM_ACTION = 'action';
  24. const PARAM_SEC_TOKEN = 'sec_token';
  25. const PARAM_IS_STUDENT_VIEW = 'isStudentView';
  26. const PARAM_DESCRIPTION_TYPE = 'description_type';
  27. /**
  28. * Action to perform. *
  29. * @return string
  30. */
  31. public static function get_action()
  32. {
  33. $result = Request::get(self::PARAM_ACTION, '');
  34. return $result;
  35. }
  36. /**
  37. * Returns the object id.
  38. *
  39. * @return int
  40. */
  41. public static function get_id()
  42. {
  43. $result = \Request::get(self::PARAM_ID, 0);
  44. $result = intval($result);
  45. return $result;
  46. }
  47. /**
  48. * List of objet ids
  49. *
  50. * @return array
  51. */
  52. public static function get_ids()
  53. {
  54. $result = Request::get(self::PARAM_IDS, array());
  55. if (is_array($result)) {
  56. return $result;
  57. }
  58. $result = trim($result);
  59. if (empty($result)) {
  60. return array();
  61. }
  62. $result = explode(',', $result);
  63. return $result;
  64. }
  65. /**
  66. * Returns the course id.
  67. *
  68. * @return int
  69. */
  70. public static function get_c_id()
  71. {
  72. $result = Request::get(self::PARAM_C_ID, 0);
  73. $result = intval($result);
  74. $result = $result ? $result : api_get_real_course_id();
  75. $result = $result ? $result : 0;
  76. return $result;
  77. }
  78. /**
  79. * Returns the session id.
  80. *
  81. * @return int
  82. */
  83. public static function get_session_id()
  84. {
  85. $result = Request::get(self::PARAM_SESSION_ID, 0);
  86. $result = intval($result);
  87. return $result;
  88. }
  89. /**
  90. * Returns the security token.
  91. *
  92. * @return string
  93. */
  94. public static function get_security_token()
  95. {
  96. $result = Request::get(self::PARAM_SEC_TOKEN, 0);
  97. return $result;
  98. }
  99. /**
  100. * Returns true if the user is in "student view". False otherwise.
  101. *
  102. * @return bool
  103. */
  104. public static function is_student_view()
  105. {
  106. return Request::get(self::PARAM_IS_STUDENT_VIEW, false) == 'true';
  107. }
  108. /**
  109. * Returns the description type
  110. *
  111. * @return string
  112. */
  113. public static function get_description_type()
  114. {
  115. $result = Request::get(self::PARAM_DESCRIPTION_TYPE, '');
  116. return $result;
  117. }
  118. }