3 // This file is part of Moodle - http://moodle.org/
5 // Moodle is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // Moodle is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
23 * @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
24 * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
27 require('../config.php');
28 require_once('signup_form.php');
31 if (empty($CFG->registerauth
)) {
32 print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
34 $authplugin = get_auth_plugin($CFG->registerauth
);
36 if (!$authplugin->can_signup()) {
37 print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
40 //HTTPS is required in this page when $CFG->loginhttps enabled
41 $PAGE->https_required();
43 $PAGE->set_url('/login/signup.php');
44 $PAGE->set_context(get_context_instance(CONTEXT_SYSTEM
));
46 $mform_signup = new login_signup_form(null, null, 'post', '', array('autocomplete'=>'on'));
48 if ($mform_signup->is_cancelled()) {
49 redirect(get_login_url());
51 } else if ($user = $mform_signup->get_data()) {
53 $user->lang
= current_language();
54 $user->firstaccess
= time();
55 $user->timecreated
= time();
56 $user->mnethostid
= $CFG->mnet_localhost_id
;
57 $user->secret
= random_string(15);
58 $user->auth
= $CFG->registerauth
;
60 $authplugin->user_signup($user, true); // prints notice and link to login/index.php
64 // make sure we really are on the https page when https login required
65 $PAGE->verify_https_required();
68 $newaccount = get_string('newaccount');
69 $login = get_string('login');
71 $PAGE->navbar
->add($login);
72 $PAGE->navbar
->add($newaccount);
74 $PAGE->set_title($newaccount);
75 $PAGE->set_heading($SITE->fullname
);
77 echo $OUTPUT->header();
78 $mform_signup->display();
79 echo $OUTPUT->footer();