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.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. * @return \Luticate\Utils\LuMultipleDbo
  25. */
  26. public function getAll($page = 0, $perPage = PHP_INT_MAX)
  27. {
  28. return LuticateGroupsBusiness::getAll($page, $perPage);
  29. }
  30. /**
  31. * Get all users in group
  32. * @param $group_id int The group id
  33. * @param int $page The page number, 0 based
  34. * @param int $perPage The number of items per page
  35. * @return \Luticate\Utils\LuMultipleDbo
  36. */
  37. public function getUsers($group_id, $page = 0, $perPage = PHP_INT_MAX)
  38. {
  39. return LuticateGroupsBusiness::getUsers($group_id, $page, $perPage);
  40. }
  41. /**
  42. * Add a new group
  43. * @param $group_name string The group name
  44. * @return int
  45. */
  46. public function add($group_name)
  47. {
  48. return LuticateGroupsBusiness::add($group_name);
  49. }
  50. /**
  51. * Delete a group by its id
  52. * @param $group_id int The group id
  53. * @return bool
  54. */
  55. public function del($group_id)
  56. {
  57. return LuticateGroupsBusiness::deleteById($group_id);
  58. }
  59. /**
  60. * Edit a group name by its id
  61. * @param $group_id int The group id
  62. * @param $group_name string The new group name
  63. * @return bool
  64. */
  65. public function edit($group_id, $group_name)
  66. {
  67. return LuticateGroupsBusiness::edit($group_id, $group_name);
  68. }
  69. /**
  70. * Add a user to a group
  71. * @param $user_id int The user id
  72. * @param $group_id int The group id
  73. * @return bool
  74. */
  75. public function addUser($user_id, $group_id)
  76. {
  77. return LuticateGroupsBusiness::addUser($user_id, $group_id);
  78. }
  79. /**
  80. * Delete a user from a group
  81. * @param $user_id int The user id
  82. * @param $group_id int The group id
  83. * @return bool
  84. */
  85. public static function delUser($user_id, $group_id)
  86. {
  87. return LuticateGroupsBusiness::delUser($user_id, $group_id);
  88. }
  89. }