]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
Refs #2573 fixes validation issue for users registered with validation turned off...
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 15 Nov 2010 12:41:26 +0000 (12:41 +0000)
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 15 Nov 2010 12:41:26 +0000 (12:41 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@7320 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/uservalidationbyemail/lib/functions.php
mod/uservalidationbyemail/start.php

index b7ca30bcce27434cd8cde34843d1b55c63c128fa..38822595a0707daff03a6a0bcae7f01c4963b096 100644 (file)
@@ -9,7 +9,7 @@
 /**
  * Generate an email activation code.
  *
- * @param int $user_guid The guid of the user
+ * @param int    $user_guid     The guid of the user
  * @param string $email_address Email address
  * @return string
  */
@@ -24,7 +24,7 @@ function uservalidationbyemail_generate_code($user_guid, $email_address) {
  * Request user validation email.
  * Send email out to the address and request a confirmation.
  *
- * @param int $user_guid The user
+ * @param int $user_guid The user's GUID
  * @return mixed
  */
 function uservalidationbyemail_request_validation($user_guid) {
@@ -57,9 +57,9 @@ function uservalidationbyemail_request_validation($user_guid) {
 /**
  * Validate a user
  *
- * @param unknown_type $user_guid
- * @param unknown_type $code
- * @return unknown
+ * @param int    $user_guid
+ * @param string $code
+ * @return bool
  */
 function uservalidationbyemail_validate_email($user_guid, $code) {
        $user = get_entity($user_guid);
@@ -74,43 +74,27 @@ function uservalidationbyemail_validate_email($user_guid, $code) {
 /**
  * Set the validation status for a user.
  *
- * @param bool $status Validated (true) or false
+ * @param int    $user_guid The user's GUID
+ * @param bool   $status Validated (true) or false
  * @param string $method Optional method to say how a user was validated
  * @return bool
  */
 function uservalidationbyemail_set_user_validation_status($user_guid, $status, $method = '') {
-       if (!$status) {
-               $method = '';
-       }
 
-       if ($status) {
-               if (
-                       (create_metadata($user_guid, 'validated', $status,'', 0, ACCESS_PUBLIC)) &&
-                       (create_metadata($user_guid, 'validated_method', $method,'', 0, ACCESS_PUBLIC))
-               ) {
-                       return TRUE;
-               }
+       $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) {
+               return true;
        } else {
-               $validated = get_metadata_byname($user_guid,  'validated');
-               $validated_method = get_metadata_byname($user_guid,  'validated_method');
-
-               if (
-                       ($validated) &&
-                       ($validated_method) &&
-                       (delete_metadata($validated->id)) &&
-                       (delete_metadata($validated_method->id))
-               )
-                       return TRUE;
+               return false;
        }
-
-       return FALSE;
 }
 
 /**
  * Returns the validation status of a user.
  *
- * @param unknown_type $user_guid
- * @return int|null
+ * @param int $user_guid The user's GUID
+ * @return bool
  */
 function uservalidationbyemail_get_user_validation_status($user_guid) {
        $md = get_metadata_byname($user_guid, 'validated');
index 8c91c5a1f1b676c6c383874fef0c516da5b45f92..8f5888679e50e3b70a6405ae15aa3cc122f76933 100644 (file)
@@ -51,21 +51,22 @@ function uservalidationbyemail_init() {
 /**
  * Disables a user upon registration.
  *
- * @param unknown_type $hook
- * @param unknown_type $type
- * @param unknown_type $value
- * @param unknown_type $params
+ * @param string $hook
+ * @param string $type
+ * @param bool   $value
+ * @param array  $params
+ * @return bool
  */
 function uservalidationbyemail_disable_new_user($hook, $type, $value, $params) {
        $user = elgg_get_array_value('user', $params);
 
        // no clue what's going on, so don't react.
        if (!$user instanceof ElggUser) {
-               return NULL;
+               return;
        }
 
        // disable user to prevent showing up on the site
-       // set context to our canEdit() override works
+       // set context so our canEdit() override works
        elgg_push_context('uservalidationbyemail_new_user');
        $hidden_entities = access_get_show_hidden_status();
        access_show_hidden_entities(TRUE);
@@ -83,7 +84,7 @@ function uservalidationbyemail_disable_new_user($hook, $type, $value, $params) {
        elgg_pop_context();
        access_show_hidden_entities($hidden_entities);
 
-       return TRUE;
+       return $value;
 }
 
 /**
@@ -123,7 +124,7 @@ function uservalidationbyemail_check_auth_attempt($credentials) {
        access_show_hidden_entities(TRUE);
 
        $user = get_user_by_username($username);
-       if ($user && !$user->validated) {
+       if ($user && isset($user->validated) && !$user->validated) {
                // show an error and resend validation email
                uservalidationbyemail_request_validation($user->guid);
                access_show_hidden_entities($access_status);