Comment::get_owner() function, as an official way to access user data (eg User::get_avatar())
This commit is contained in:
parent
ec5b08f659
commit
77934a7733
@ -38,9 +38,10 @@ class CommentPostingException extends SCoreException {}
|
|||||||
|
|
||||||
class Comment {
|
class Comment {
|
||||||
public function Comment($row) {
|
public function Comment($row) {
|
||||||
|
$this->owner = null;
|
||||||
$this->owner_id = $row['user_id'];
|
$this->owner_id = $row['user_id'];
|
||||||
$this->owner_name = $row['user_name'];
|
$this->owner_name = $row['user_name'];
|
||||||
$this->owner_email = $row['user_email'];
|
$this->owner_email = $row['user_email']; // deprecated
|
||||||
$this->comment = $row['comment'];
|
$this->comment = $row['comment'];
|
||||||
$this->comment_id = $row['comment_id'];
|
$this->comment_id = $row['comment_id'];
|
||||||
$this->image_id = $row['image_id'];
|
$this->image_id = $row['image_id'];
|
||||||
@ -52,6 +53,11 @@ class Comment {
|
|||||||
global $database;
|
global $database;
|
||||||
return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($user->id));
|
return $database->db->GetOne("SELECT COUNT(*) AS count FROM comments WHERE owner_id=?", array($user->id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_owner() {
|
||||||
|
if(empty($this->owner)) $this->owner = User::by_id($this->owner_id);
|
||||||
|
return $this->owner;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class CommentList extends SimpleExtension {
|
class CommentList extends SimpleExtension {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user