12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
-
- namespace SCF\Core;
-
-
- class ProfileManager {
-
- private $_db;
-
- private $userList = [];
-
- private $userId;
-
- private $profile;
-
-
- public function __construct(Database $db)
- {
- $this->_db = $db;
- }
-
- private function collectProfileList()
- {
- $this->_db->query("SELECT userid, username, userRegDate, userLastActivity FROM users ORDER BY userId");
- $list = $this->_db->fetchArray();
-
- return $list;
- }
-
- /**
- * @return array
- */
- public function getUserList(): array
- {
- return $this->userList;
- }
-
- /**
- *
- */
- public function setUserList()
- {
- $this->userList = $this->collectProfileList();
- }
-
- /**
- * @param mixed $userId
- */
- public function setUserId($userId)
- {
- $this->userId = $userId;
- }
-
- private function singleProfile($userId)
- {
- $this->_db->query("SELECT * FROM users WHERE userId = :userId");
- $this->_db->bind(':userId', $userId);
- $user = $this->_db->single();
-
- return $user;
-
- }
-
- /**
- * @return mixed
- */
- public function getUserId()
- {
- return $this->userId;
- }
-
- /**
- * @param $userId
- */
- public function setProfile($userId)
- {
- $this->setUserId($userId);
- $this->profile = $this->singleProfile($this->userId);
- }
-
- /**
- * @return mixed
- */
- public function getProfile()
- {
- return $this->profile;
- }
- }
|