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. --- core/controllers/welcome.php | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'core/controllers') diff --git a/core/controllers/welcome.php b/core/controllers/welcome.php index ac0925b9..019bb609 100644 --- a/core/controllers/welcome.php +++ b/core/controllers/welcome.php @@ -293,6 +293,7 @@ class Welcome_Controller extends Template_Controller { function add_comments($count) { srand(time()); $photos = ORM::factory("item")->where("type", "photo")->find_all()->as_array(); + $users = ORM::factory("user")->find_all()->as_array(); if (empty($photos)) { url::redirect("welcome"); @@ -303,10 +304,12 @@ class Welcome_Controller extends Template_Controller { } for ($i = 0; $i < $count; $i++) { $photo = $photos[array_rand($photos)]; - comment::create( - ucfirst($this->random_phrase(rand(1, 3))), - "johndoe@example.com", - $this->random_phrase(rand(8, 500)), $photo->id); + $author = $users[array_rand($users)]; + $guest_name = ucfirst($this->random_phrase(rand(1, 3))); + $guest_email = sprintf("%s@%s.com", $this->random_phrase(1), $this->random_phrase(1)); + $guest_url = sprintf("http://www.%s.com", $this->random_phrase(1)); + comment::create($photo, $author, $this->random_phrase(rand(8, 500)), + $guest_name, $guest_email, $guest_url); } url::redirect("welcome"); -- cgit v1.2.3