You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

LuticateGroupsController.php 2.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 = 2000000000, $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. * @param string $query The filter query
  37. * @return \Luticate\Utils\LuMultipleDbo
  38. */
  39. public function getUsers($group_id, $page = 0, $perPage = 2000000000, $query = "")
  40. {
  41. return LuticateGroupsBusiness::getUsers($group_id, $page, $perPage, $query);
  42. }
  43. /**
  44. * Add a new group
  45. * @param $group_name string The group name
  46. * @return int
  47. */
  48. public function add($group_name)
  49. {
  50. return LuticateGroupsBusiness::add($group_name);
  51. }
  52. /**
  53. * Delete a group by its id
  54. * @param $group_id int The group id
  55. * @return bool
  56. */
  57. public function del($group_id)
  58. {
  59. return LuticateGroupsBusiness::deleteById($group_id);
  60. }
  61. /**
  62. * Edit a group name by its id
  63. * @param $group_id int The group id
  64. * @param $group_name string The new group name
  65. * @return bool
  66. */
  67. public function edit($group_id, $group_name)
  68. {
  69. return LuticateGroupsBusiness::edit($group_id, $group_name);
  70. }
  71. /**
  72. * Add a user to a group
  73. * @param $user_id int The user id
  74. * @param $group_id int The group id
  75. * @return bool
  76. */
  77. public function addUser($user_id, $group_id)
  78. {
  79. return LuticateGroupsBusiness::addUser($user_id, $group_id);
  80. }
  81. /**
  82. * Delete a user from a group
  83. * @param $user_id int The user id
  84. * @param $group_id int The group id
  85. * @return bool
  86. */
  87. public static function delUser($user_id, $group_id)
  88. {
  89. return LuticateGroupsBusiness::delUser($user_id, $group_id);
  90. }
  91. }