Streamlining GetUserByUID references
This commit is contained in:
parent
ef11a5269e
commit
6acd299979
@ -3,7 +3,7 @@ class DBUser extends Database
|
||||
{
|
||||
static function isUserActive($uid){
|
||||
$user = self::getUserByUID($uid);
|
||||
if($user['active']){
|
||||
if($user->active){
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
@ -15,7 +15,9 @@ class DBUser extends Database
|
||||
$query = $con->prepare("SELECT * FROM users WHERE ID = :uid");
|
||||
$query->bindParam(":uid", $uid);
|
||||
$query->execute();
|
||||
return $query->fetch(PDO::FETCH_BOTH);
|
||||
$result = $query->fetch(PDO::FETCH_BOTH);
|
||||
$user = new User($result['ID'], $result['username'], $result['email'], $result['password'], $result['reg_date'], $result['login_date'], $result['reg_ip'], $result['permissions']);
|
||||
return $user;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -9,7 +9,9 @@ class User {
|
||||
public $login_date;
|
||||
public $reg_ip;
|
||||
public $permissions;
|
||||
function User($id, $username, $email, $password, $reg_date, $login_date, $reg_ip, $permissions){
|
||||
public $active;
|
||||
function User($id, $username, $email, $password, $reg_date, $login_date, $reg_ip, $permissions, $active){
|
||||
parent->__construct();
|
||||
$this->id = $id;
|
||||
$this->username = $username;
|
||||
$this->email = $email;
|
||||
@ -18,6 +20,7 @@ class User {
|
||||
$this->login_date = $login_date;
|
||||
$this->reg_ip=$reg_ip;
|
||||
$this->permissions=$permissions;
|
||||
$this->active = $active;
|
||||
}
|
||||
/**
|
||||
* @return mixed
|
||||
@ -75,6 +78,13 @@ class User {
|
||||
return $this->permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed
|
||||
*/
|
||||
public function getActive() {
|
||||
return $this->active;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mixed $id
|
||||
*/
|
||||
@ -130,6 +140,12 @@ class User {
|
||||
public function setPermissions($permissions) {
|
||||
$this->permissions = $permissions;
|
||||
}
|
||||
/**
|
||||
* @param mixed $active
|
||||
*/
|
||||
public function setActive($active) {
|
||||
$this->active = $active;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@ -33,7 +33,7 @@ foreach($usersTable as $row){
|
||||
}
|
||||
}
|
||||
if(!$skipUser){
|
||||
array_push($users, new User($row['ID'], $row['username'], $row['email'], $row['password'], $row['reg_date'], $row['login_date'], $row['reg_ip'], $row['permissions']));
|
||||
array_push($users, $row);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -19,15 +19,12 @@ $replies = [ ];
|
||||
foreach ($replyData as $row) {
|
||||
$reply = new Reply($row['ID'], $row['thread_ID'], $row['users_ID'], $row['content'], $row['date_created']);
|
||||
array_push($replies, $reply);
|
||||
$replyOwnerData = DBUser::getUserByUID($reply->getUserID());
|
||||
$replyOwner = new User($replyOwnerData['ID'], $replyOwnerData['username'], $replyOwnerData['email'], $replyOwnerData['password'], $replyOwnerData['reg_date'], $replyOwnerData['login_date'], $replyOwnerData['reg_ip'], $replyOwnerData['permissions']);
|
||||
$replyOwner = DBUser::getUserByUID($reply->getUserID());
|
||||
$reply->setOwner($replyOwner);
|
||||
}
|
||||
|
||||
// get the person who started the thread
|
||||
$threadOwnerData = DBUser::getUserByUID($thread->getUserID());
|
||||
// create user object
|
||||
$threadOwner = new User($threadOwnerData['ID'], $threadOwnerData['username'], $threadOwnerData['email'], $threadOwnerData['password'], $threadOwnerData['reg_date'], $threadOwnerData['login_date'], $threadOwnerData['reg_ip'], $threadOwnerData['permissions']);
|
||||
$threadOwner = DBUser::getUserByUID($thread->getUserID());
|
||||
// assign owner and replies
|
||||
$thread->setReplies($replies);
|
||||
$thread->setOwner($threadOwner);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user