]> git.mjollnir.org Git - moodle.git/commitdiff
Makes it possible to confirm users using manual auth system.
authorscyrma <scyrma>
Tue, 20 Nov 2007 05:28:33 +0000 (05:28 +0000)
committerscyrma <scyrma>
Tue, 20 Nov 2007 05:28:33 +0000 (05:28 +0000)
auth/manual/auth.php

index 6f1e7ca620198e19945f7193d10c30724abe1cd4..a8c469722f7bfb0e85563dc96d4c2696f26a7723 100644 (file)
@@ -119,6 +119,31 @@ class auth_plugin_manual extends auth_plugin_base {
         return true;
     }
 
+   /**
+     * Confirm the new user as registered. This should normally not be used,
+     * but it may be necessary if the user auth_method is changed to manual 
+     * before the user is confirmed.
+     */
+    function user_confirm($username, $confirmsecret = null) {        
+        $user = get_complete_user_data('username', $username);
+
+        if (!empty($user)) {
+            if ($user->confirmed) {
+                return AUTH_CONFIRM_ALREADY;
+            } else { 
+                if (!set_field("user", "confirmed", 1, "id", $user->id)) {
+                    return AUTH_CONFIRM_FAIL;
+                }
+                if (!set_field("user", "firstaccess", time(), "id", $user->id)) {
+                    return AUTH_CONFIRM_FAIL;
+                }
+                return AUTH_CONFIRM_OK;
+            }
+        } else  {
+            return AUTH_CONFIRM_ERROR;
+        }
+    }
+
 }
 
 ?>