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.

LuticateUsersController.php 3.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace Luticate\Auth\Controller;
  3. use Luticate\Utils\LuController;
  4. use Luticate\Auth\Business\LuticateUsersBusiness;
  5. use Luticate\Auth\DBO\LuticateUsersDbo;
  6. class LuticateUsersController extends LuController {
  7. protected function getBusiness()
  8. {
  9. return new LuticateUsersBusiness();
  10. }
  11. /**
  12. * Login the user
  13. * @param $username string The user username
  14. * @param $password string The user password
  15. * @return LuticateUsersDbo
  16. */
  17. public function login($username, $password)
  18. {
  19. return LuticateUsersBusiness::login($username, $password);
  20. }
  21. /**
  22. * Logout the logged user
  23. * @param $_user LuticateUsersDbo The logged user
  24. * @return bool
  25. */
  26. public function logout($_user)
  27. {
  28. return LuticateUsersBusiness::logout($_user);
  29. }
  30. /**
  31. * Get a user by its id
  32. * @param $user_id int The user id
  33. * @return \Luticate\Utils\LuDbo
  34. */
  35. public function getLightById($user_id)
  36. {
  37. return LuticateUsersBusiness::getLightById($user_id);
  38. }
  39. /**
  40. * Get all users
  41. * @param int $page The page number, 0 based
  42. * @param int $perPage The number of items per page
  43. * @param string $query The filter query
  44. * @return array
  45. */
  46. public function getAllLight($page = 0, $perPage = PHP_INT_MAX, $query = "")
  47. {
  48. return LuticateUsersBusiness::getAllLight($page, $perPage, $query);
  49. }
  50. /**
  51. * Add a user
  52. * @param $username string The new user username
  53. * @param $email string The new user email
  54. * @param $firstname string The user firstname
  55. * @param $lastname string The user lastname
  56. * @param $password string The new user plain text password
  57. * @return int
  58. */
  59. public function add($username, $email, $firstname, $lastname, $password)
  60. {
  61. return LuticateUsersBusiness::add($username, $email, $firstname, $lastname, $password);
  62. }
  63. /**
  64. * Delete a user by its id
  65. * @param $user_id int The user id
  66. * @return bool
  67. */
  68. public function del($user_id)
  69. {
  70. return LuticateUsersBusiness::deleteById($user_id);
  71. }
  72. /**
  73. * Edit the user details
  74. * @param $email string The new user amil
  75. * @param $user_id int The user id
  76. * @param $firstname string The user firstname
  77. * @param $lastname string The user lastname
  78. * @return bool
  79. */
  80. public function edit($email, $firstname, $lastname, $user_id)
  81. {
  82. return LuticateUsersBusiness::edit($user_id, $firstname, $lastname, $email);
  83. }
  84. /**
  85. * Edit the logged user email
  86. * @param $email string The new user email
  87. * @param $firstname string The user firstname
  88. * @param $lastname string The user lastname
  89. * @param $_user LuticateUsersDbo The logged user
  90. * @return bool
  91. */
  92. public function editMe($email, $firstname, $lastname, $_user)
  93. {
  94. return LuticateUsersBusiness::edit($_user->getId(), $firstname, $lastname, $email);
  95. }
  96. /**
  97. * Edit the password for a user
  98. * @param $password string The new plain text password
  99. * @param $user_id int The user id
  100. * @return bool
  101. */
  102. public function setPassword($password, $user_id)
  103. {
  104. return LuticateUsersBusiness::setPassword($user_id, $password);
  105. }
  106. /**
  107. * Edit the password for the logged user
  108. * @param $password string The new plain text password
  109. * @param $oldPassword string The old plain text password
  110. * @param $_user LuticateUsersDbo The logged user
  111. * @return bool
  112. */
  113. public function setPasswordMe($password, $oldPassword, $_user)
  114. {
  115. return LuticateUsersBusiness::setPasswordMe($password, $oldPassword, $_user);
  116. }
  117. }