Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

LuticateGroupsController.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <?php
  2. namespace Luticate\Auth\Controller;
  3. use Luticate\Utils\LuController;
  4. use Luticate\Auth\Business\LuticateGroupsBusiness;
  5. use Luticate\Auth\DBO\LuticateGroupsDbo;
  6. class LuticateGroupsController extends LuController {
  7. protected function getBusiness()
  8. {
  9. return new LuticateGroupsBusiness();
  10. }
  11. /**
  12. * Get a group by its id
  13. * @param $group_id int The group id
  14. * @return \Luticate\Utils\LuDbo
  15. */
  16. public function getById($group_id)
  17. {
  18. return LuticateGroupsBusiness::getById($group_id);
  19. }
  20. /**
  21. * Get all groups
  22. * @param int $page The page number, 0 based
  23. * @param int $perPage The number of items per page
  24. * @param string $query The filter query
  25. * @return \Luticate\Utils\LuMultipleDbo
  26. */
  27. public function getAll($page = 0, $perPage = PHP_INT_MAX, $query = "")
  28. {
  29. return LuticateGroupsBusiness::getAll($page, $perPage, $query);
  30. }
  31. /**
  32. * Get all users in group
  33. * @param $group_id int The group id
  34. * @param int $page The page number, 0 based
  35. * @param int $perPage The number of items per page
  36. * @return \Luticate\Utils\LuMultipleDbo
  37. */
  38. public function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX)
  39. {
  40. return LuticateGroupsBusiness::getUsers($group_id, $page, $perPage);
  41. }
  42. /**
  43. * Add a new group
  44. * @param $group_name string The group name
  45. * @return int
  46. */
  47. public function add($group_name)
  48. {
  49. return LuticateGroupsBusiness::add($group_name);
  50. }
  51. /**
  52. * Delete a group by its id
  53. * @param $group_id int The group id
  54. * @return bool
  55. */
  56. public function del($group_id)
  57. {
  58. return LuticateGroupsBusiness::deleteById($group_id);
  59. }
  60. /**
  61. * Edit a group name by its id
  62. * @param $group_id int The group id
  63. * @param $group_name string The new group name
  64. * @return bool
  65. */
  66. public function edit($group_id, $group_name)
  67. {
  68. return LuticateGroupsBusiness::edit($group_id, $group_name);
  69. }
  70. /**
  71. * Add a user to a group
  72. * @param $user_id int The user id
  73. * @param $group_id int The group id
  74. * @return bool
  75. */
  76. public function addUser($user_id, $group_id)
  77. {
  78. return LuticateGroupsBusiness::addUser($user_id, $group_id);
  79. }
  80. /**
  81. * Delete a user from a group
  82. * @param $user_id int The user id
  83. * @param $group_id int The group id
  84. * @return bool
  85. */
  86. public static function delUser($user_id, $group_id)
  87. {
  88. return LuticateGroupsBusiness::delUser($user_id, $group_id);
  89. }
  90. }