Adding new, central, create_guest_record() function. MDL-10375

This commit is contained in:
stronk7 2007-07-06 17:37:43 +00:00
parent 3b5d49f20c
commit 0183e41239

View file

@ -2456,6 +2456,34 @@ function get_user_fieldnames() {
return $fieldarray; return $fieldarray;
} }
/**
* Creates the default "guest" user. Used both from
* admin/index.php and login/index.php
* @return mixed user object created or boolean false if the creation has failed
*/
function create_guest_record() {
global $CFG;
$guest->auth = 'manual';
$guest->username = 'guest';
$guest->password = hash_internal_user_password('guest');
$guest->firstname = addslashes(get_string('guestuser'));
$guest->lastname = ' ';
$guest->email = 'root@localhost';
$guest->description = addslashes(get_string('guestuserinfo'));
$guest->mnethostid = $CFG->mnet_localhost_id;
$guest->confirmed = 1;
$guest->lang = $CFG->lang;
$guest->timemodified= time();
if (! $guest->id = insert_record("user", $guest)) {
return false;
}
return $guest;
}
/** /**
* Creates a bare-bones user record * Creates a bare-bones user record
* *