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/user/helpers/user.php | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'modules/user/helpers/user.php') diff --git a/modules/user/helpers/user.php b/modules/user/helpers/user.php index cc70d874..377a1036 100644 --- a/modules/user/helpers/user.php +++ b/modules/user/helpers/user.php @@ -31,6 +31,7 @@ class user_Core { $group->input("full_name")->label(t("Full Name"))->id("gFullName")->value($user->full_name); $group->password("password")->label(t("Password"))->id("gPassword"); $group->input("email")->label(t("Email"))->id("gEmail")->value($user->email); + $group->input("url")->label(t("URL"))->id("gUrl")->value($user->url); $group->submit(t("Save")); $form->add_rules_from($user); return $form; @@ -45,6 +46,7 @@ class user_Core { $group->input("full_name")->label(t("Full Name"))->id("gFullName")->value($user->full_name); $group->password("password")->label(t("Password"))->id("gPassword"); $group->input("email")->label(t("Email"))->id("gEmail")->value($user->email); + $group->input("url")->label(t("URL"))->id("gUrl")->value($user->url); $group->submit(t("Modify User")); $form->add_rules_from($user); return $form; @@ -59,6 +61,7 @@ class user_Core { $group->input("full_name")->label(t("Full Name"))->id("gFullName"); $group->password("password")->label(t("Password"))->id("gPassword"); $group->input("email")->label(t("Email"))->id("gEmail"); + $group->input("url")->label(t("URL"))->id("gUrl")->value($user->url); $group->submit(t("Add User")); $user = ORM::factory("user"); $form->add_rules_from($user); @@ -213,7 +216,7 @@ class user_Core { } /** - * Perform the post authentication processing + * Log in as a given user. * @param object $user the user object. */ public static function login($user) { @@ -225,6 +228,10 @@ class user_Core { module::event("user_login", $user); } + /** + * Log out the active user and destroy the session. + * @param object $user the user object. + */ public static function logout() { $user = user::active(); if (!$user->guest) { @@ -237,6 +244,19 @@ class user_Core { } } + /** + * Look up a user by id. + * @param integer $id the user id + * @return User_Model the user object, or null if the id was invalid. + */ + public static function lookup($id) { + $user = model_cache::get("user", $id); + if ($user->loaded) { + return $user; + } + return null; + } + /** * Create a hashed password using md5 plus salt. * @param string $password plaintext password -- cgit v1.2.3