request.class.php 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * Link request class definition
  5. * @package chamilo.link
  6. */
  7. /**
  8. * Init
  9. */
  10. namespace Link;
  11. /**
  12. * Html request for Link.
  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_SECURITY_TOKEN = 'sec_token';
  25. const PARAM_IS_STUDENT_VIEW = 'isStudentView';
  26. const PARAM_GROUP_ID = 'toolgroup';
  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 session id.
  91. *
  92. * @return int
  93. */
  94. public static function get_group_id()
  95. {
  96. $result = Request::get(self::PARAM_GROUP_ID, 0);
  97. $result = intval($result);
  98. return $result;
  99. }
  100. /**
  101. * Returns the security token.
  102. *
  103. * @return string
  104. */
  105. public static function get_security_token()
  106. {
  107. $result = Request::get(self::PARAM_SEC_TOKEN, 0);
  108. return $result;
  109. }
  110. /**
  111. * Returns true if the user is in "student view". False otherwise.
  112. *
  113. * @return bool
  114. */
  115. public static function is_student_view()
  116. {
  117. return Request::get(self::PARAM_IS_STUDENT_VIEW, false) == 'true';
  118. }
  119. }