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.

ProfileManager.php 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace SCF\Core;
  3. class ProfileManager {
  4. private $_db;
  5. private $userList = [];
  6. private $userId;
  7. private $profile;
  8. public function __construct(Database $db)
  9. {
  10. $this->_db = $db;
  11. }
  12. private function collectProfileList()
  13. {
  14. $this->_db->query("SELECT userid, username, userRegDate, userLastActivity FROM users ORDER BY userId");
  15. $list = $this->_db->fetchArray();
  16. return $list;
  17. }
  18. /**
  19. * @return array
  20. */
  21. public function getUserList(): array
  22. {
  23. return $this->userList;
  24. }
  25. /**
  26. *
  27. */
  28. public function setUserList()
  29. {
  30. $this->userList = $this->collectProfileList();
  31. }
  32. /**
  33. * @param mixed $userId
  34. */
  35. public function setUserId($userId)
  36. {
  37. $this->userId = $userId;
  38. }
  39. private function singleProfile($userId)
  40. {
  41. $this->_db->query("SELECT * FROM users WHERE userId = :userId");
  42. $this->_db->bind(':userId', $userId);
  43. $user = $this->_db->single();
  44. return $user;
  45. }
  46. /**
  47. * @return mixed
  48. */
  49. public function getUserId()
  50. {
  51. return $this->userId;
  52. }
  53. /**
  54. * @param $userId
  55. */
  56. public function setProfile($userId)
  57. {
  58. $this->setUserId($userId);
  59. $this->profile = $this->singleProfile($this->userId);
  60. }
  61. /**
  62. * @return mixed
  63. */
  64. public function getProfile()
  65. {
  66. return $this->profile;
  67. }
  68. }