From: martin Date: Mon, 10 Jun 2002 04:24:50 +0000 (+0000) Subject: Moved creation of guest user to login page - this means it can be X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=a9b07c52880d74c23902cc381ff46946f6dd95ff;p=moodle.git Moved creation of guest user to login page - this means it can be trashed any time and it will recreate itself as necessary. --- diff --git a/admin/user.php b/admin/user.php index de77af4033..eabbf8ebc5 100644 --- a/admin/user.php +++ b/admin/user.php @@ -44,20 +44,6 @@ $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(); diff --git a/login/index.php b/login/index.php index 04a432b22f..fb49395915 100644 --- a/login/index.php +++ b/login/index.php @@ -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;