MDL-39434 Bump main version to observe all deps
[moodle.git] / login / signup.php
blob331f9ef469110babb6b9a631c6cda000b14c297c
1 <?php
3 // This file is part of Moodle - http://moodle.org/
4 //
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.
9 //
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/>.
18 /**
19 * user signup page.
21 * @package core
22 * @subpackage auth
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');
29 if (empty($CFG->registerauth)) {
30 print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
32 $authplugin = get_auth_plugin($CFG->registerauth);
34 if (!$authplugin->can_signup()) {
35 print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
38 //HTTPS is required in this page when $CFG->loginhttps enabled
39 $PAGE->https_required();
41 $PAGE->set_url('/login/signup.php');
42 $PAGE->set_context(context_system::instance());
44 $mform_signup = $authplugin->signup_form();
46 if ($mform_signup->is_cancelled()) {
47 redirect(get_login_url());
49 } else if ($user = $mform_signup->get_data()) {
50 $user->confirmed = 0;
51 $user->lang = current_language();
52 $user->firstaccess = time();
53 $user->timecreated = time();
54 $user->mnethostid = $CFG->mnet_localhost_id;
55 $user->secret = random_string(15);
56 $user->auth = $CFG->registerauth;
58 $authplugin->user_signup($user, true); // prints notice and link to login/index.php
59 exit; //never reached
62 // make sure we really are on the https page when https login required
63 $PAGE->verify_https_required();
66 $newaccount = get_string('newaccount');
67 $login = get_string('login');
69 $PAGE->navbar->add($login);
70 $PAGE->navbar->add($newaccount);
72 $PAGE->set_title($newaccount);
73 $PAGE->set_heading($SITE->fullname);
75 echo $OUTPUT->header();
76 $mform_signup->display();
77 echo $OUTPUT->footer();