mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
Adding new, central, create_guest_record() function. MDL-10375
This commit is contained in:
parent
3b5d49f20c
commit
0183e41239
1 changed files with 28 additions and 0 deletions
|
@ -2456,6 +2456,34 @@ function get_user_fieldnames() {
|
|||
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
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue