From 961e31c8833220e85b5c73651576642101a94b15 Mon Sep 17 00:00:00 2001 From: cash Date: Fri, 19 Nov 2010 11:45:38 +0000 Subject: Closes #617 core has get and set functions for user validation status git-svn-id: http://code.elgg.org/elgg/trunk@7344 36083f99-b078-4883-b0ff-0f9b5a30f544 --- engine/lib/users.php | 44 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 41 insertions(+), 3 deletions(-) (limited to 'engine') diff --git a/engine/lib/users.php b/engine/lib/users.php index b22e93ca2..62f2bdcc8 100644 --- a/engine/lib/users.php +++ b/engine/lib/users.php @@ -1226,11 +1226,13 @@ function generate_invite_code($username) { /** * Set the validation status for a user. * - * @param bool $status Validated (true) or false - * @param string $method Optional method to say how a user was validated + * @param int $user_guid The user's GUID + * @param bool $status Validated (true) or unvalidated (false) + * @param string $method Optional method to say how a user was validated * @return bool + * @since 1.8.0 */ -function set_user_validation_status($user_guid, $status, $method = '') { +function elgg_set_user_validation_status($user_guid, $status, $method = '') { $result1 = create_metadata($user_guid, 'validated', $status, '', 0, ACCESS_PUBLIC, false); $result2 = create_metadata($user_guid, 'validated_method', $method, '', 0, ACCESS_PUBLIC, false); if ($result1 && $result2) { @@ -1240,14 +1242,50 @@ function set_user_validation_status($user_guid, $status, $method = '') { } } +/** + * Gets the validation status of a user. + * + * @param int $user_guid The user's GUID + * @return bool|null Null means status was not set for this user. + * @since 1.8.0 + */ +function elgg_get_user_validation_status($user_guid) { + $md = get_metadata_byname($user_guid, 'validated'); + if ($md == false) { + return; + } + + if ($md->value) { + return true; + } + + return false; +} + +/** + * Set the validation status for a user. + * + * @param bool $status Validated (true) or false + * @param string $method Optional method to say how a user was validated + * @return bool + * @deprecated 1.8 + */ +function set_user_validation_status($user_guid, $status, $method = '') { + elgg_deprecated_notice("set_user_validation_status() is deprecated", 1.8); + return elgg_set_user_validation_status($user_guid, $status, $method); +} + /** * Trigger an event requesting that a user guid be validated somehow - either by email address or some other way. * * This function invalidates any existing validation value. * * @param int $user_guid User's GUID + * @deprecated 1.8 */ function request_user_validation($user_guid) { + elgg_deprecated_notice("request_user_validation() is deprecated. + Plugins should register for the 'register, user' plugin hook", 1.8); $user = get_entity($user_guid); if (($user) && ($user instanceof ElggUser)) { -- cgit v1.2.3