From 77934a77338ea5dcfe1ce81ba1ed5f58a1e4e279 Mon Sep 17 00:00:00 2001 From: Shish Date: Wed, 7 Apr 2010 13:38:44 +0100 Subject: [PATCH] Comment::get_owner() function, as an official way to access user data (eg User::get_avatar()) --- ext/comment/main.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/ext/comment/main.php b/ext/comment/main.php index bf6907ad..2835c79e 100644 --- a/ext/comment/main.php +++ b/ext/comment/main.php @@ -38,9 +38,10 @@ class CommentPostingException extends SCoreException {} class Comment { public function Comment($row) { + $this->owner = null; $this->owner_id = $row['user_id']; $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_id = $row['comment_id']; $this->image_id = $row['image_id']; @@ -52,6 +53,11 @@ class Comment { global $database; 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 {