From a7feeb576f491f285cb76cba0b99e01e7a3ae390 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Sat, 10 Jan 2009 00:34:23 +0000 Subject: Big set of changes to comments, with related changes to akismet and user modules. * Don't delete vars when we delete a module. This makes reinstalling a module a lot easier. * Add user::lookup() as the preferred way to load a user, so that other modules don't delve into the user module (that'd be a problem when we swap out user modules) * Notify site admins if Akismet is not fully configured * Bundle all server variables into the comment so that if/when we re-check the comment, we are not using the server info from the site admin's request. * Update Akismet to grab request context data from the comment * Pre-seed comment fields if we have a logged in user. Update comment::create() API to clarify it for this. * Delete comment::update(), that's a controller function. * Add url to User_Model * Add author_name() author_email() and author_url() to Comment_Model. It'll return the appropriate values depending on whether the comment was left by a logged in user or a guest. * Use resetForm() instead of clearForm() when we reload the comment form after ajax submit, this way we preserve the pre-seeded values. * In the user profile page, ignore blank passwords. --- modules/comment/models/comment.php | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) (limited to 'modules/comment/models') diff --git a/modules/comment/models/comment.php b/modules/comment/models/comment.php index cd7a5d07..c83b2721 100644 --- a/modules/comment/models/comment.php +++ b/modules/comment/models/comment.php @@ -18,13 +18,38 @@ * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ class Comment_Model extends ORM { - var $rules = array( - "author" => "required", - "email" => "valid_email", - "url" => "valid_url", - "text" => "required"); - function item() { return ORM::factory("item", $this->item_id); } + + function author() { + return user::lookup($this->author_id); + } + + function author_name() { + $author = $this->author(); + if ($author->guest) { + return $this->guest_name; + } else { + return $author->full_name; + } + } + + function author_email() { + $author = $this->author(); + if ($author->guest) { + return $this->guest_email; + } else { + return $author->email; + } + } + + function author_url() { + $author = $this->author(); + if ($author->guest) { + return $this->guest_url; + } else { + return $author->url; + } + } } -- cgit v1.2.3