]> git.mjollnir.org Git - moodle.git/commitdiff
Moved creation of guest user to login page - this means it can be
authormartin <martin>
Mon, 10 Jun 2002 04:24:50 +0000 (04:24 +0000)
committermartin <martin>
Mon, 10 Jun 2002 04:24:50 +0000 (04:24 +0000)
trashed any time and it will recreate itself as necessary.

admin/user.php
login/index.php

index de77af40337d8f04c9e368cd2e1ac6421c3ecc8d..eabbf8ebc5c9c6ce75714841b10144dbc9e7db87 100644 (file)
         $USER->admin = true;
         $USER->teacher["$course->id"] = true;
 
-        // This is also a good time to make the Guest User
-
-        $user = NULL;
-        $user->firstname = "Guest";
-        $user->lastname  = "User";
-        $user->username  = "guest";          // This user is identified by this
-        $user->password  = md5("guest");
-        $user->email     = "root@localhost";
-        $user->confirmed = 1;
-        $user->timemodified = time();
-
-        if (! $guest->user = insert_record("user", $user)) {
-            notify("Could not create guest user record !!!");
-        }
     }
 
     require_login();
index 04a432b22f540ee53d650e7810ed6ade8ce49cef..fb493959158629552dcb35454789ef0056b775f4 100644 (file)
@@ -2,6 +2,23 @@
     require("../config.php");
 
 
+    // Check if the guest user exists.  If not, create one.
+    if (! record_exists("user", "username", "guest")) {
+        $guest->username    = "guest"; 
+        $guest->password    = md5("guest");
+        $guest->firstname   = "Guest";
+        $guest->lastname    = "User";
+        $guest->email       = "root@localhost";
+        $guest->description = "This user is a special user that allows read-only access to some courses.";
+        $guest->confirmed   = 1;
+        $guest->timemodified= time();
+
+        if (! $guest->id = insert_record("user", $guest)) {
+            notify("Could not create guest user record !!!");
+        }
+    }
+
+
     if (match_referer() && isset($HTTP_POST_VARS)) {    // form submitted
 
         $frm = (object)$HTTP_POST_VARS;