Differences Between: [Versions 310 and 401] [Versions 310 and 402] [Versions 310 and 403]
1 <?php 2 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. 14 // 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/>. 17 18 /** 19 * user signup page. 20 * 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 25 */ 26 27 require('../config.php'); 28 require_once($CFG->dirroot . '/user/editlib.php'); 29 require_once($CFG->libdir . '/authlib.php'); 30 require_once ('lib.php'); 31 32 if (!$authplugin = signup_is_enabled()) { 33 print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.'); 34 } 35 36 $PAGE->set_url('/login/signup.php'); 37 $PAGE->set_context(context_system::instance()); 38 39 // If wantsurl is empty or /login/signup.php, override wanted URL. 40 // We do not want to end up here again if user clicks "Login". 41 if (empty($SESSION->wantsurl)) { 42 $SESSION->wantsurl = $CFG->wwwroot . '/'; 43 } else { 44 $wantsurl = new moodle_url($SESSION->wantsurl); 45 if ($PAGE->url->compare($wantsurl, URL_MATCH_BASE)) { 46 $SESSION->wantsurl = $CFG->wwwroot . '/'; 47 } 48 } 49 50 if (isloggedin() and !isguestuser()) { 51 // Prevent signing up when already logged in. 52 echo $OUTPUT->header(); 53 echo $OUTPUT->box_start(); 54 $logout = new single_button(new moodle_url('/login/logout.php', 55 array('sesskey' => sesskey(), 'loginpage' => 1)), get_string('logout'), 'post'); 56 $continue = new single_button(new moodle_url('/'), get_string('cancel'), 'get'); 57 echo $OUTPUT->confirm(get_string('cannotsignup', 'error', fullname($USER)), $logout, $continue); 58 echo $OUTPUT->box_end(); 59 echo $OUTPUT->footer(); 60 exit; 61 } 62 63 // If verification of age and location (digital minor check) is enabled. 64 if (\core_auth\digital_consent::is_age_digital_consent_verification_enabled()) { 65 $cache = cache::make('core', 'presignup'); 66 $isminor = $cache->get('isminor'); 67 if ($isminor === false) { 68 // The verification of age and location (minor) has not been done. 69 redirect(new moodle_url('/login/verify_age_location.php')); 70 } else if ($isminor === 'yes') { 71 // The user that attempts to sign up is a digital minor. 72 redirect(new moodle_url('/login/digital_minor.php')); 73 } 74 } 75 76 // Plugins can create pre sign up requests. 77 // Can be used to force additional actions before sign up such as acceptance of policies, validations, etc. 78 core_login_pre_signup_requests(); 79 80 $mform_signup = $authplugin->signup_form(); 81 82 if ($mform_signup->is_cancelled()) { 83 redirect(get_login_url()); 84 85 } else if ($user = $mform_signup->get_data()) { 86 // Add missing required fields. 87 $user = signup_setup_new_user($user); 88 89 // Plugins can perform post sign up actions once data has been validated. 90 core_login_post_signup_requests($user); 91 92 $authplugin->user_signup($user, true); // prints notice and link to login/index.php 93 exit; //never reached 94 } 95 96 97 $newaccount = get_string('newaccount'); 98 $login = get_string('login'); 99 100 $PAGE->navbar->add($login); 101 $PAGE->navbar->add($newaccount); 102 103 $PAGE->set_pagelayout('login'); 104 $PAGE->set_title($newaccount); 105 $PAGE->set_heading($SITE->fullname); 106 107 echo $OUTPUT->header(); 108 109 if ($mform_signup instanceof renderable) { 110 // Try and use the renderer from the auth plugin if it exists. 111 try { 112 $renderer = $PAGE->get_renderer('auth_' . $authplugin->authtype); 113 } catch (coding_exception $ce) { 114 // Fall back on the general renderer. 115 $renderer = $OUTPUT; 116 } 117 echo $renderer->render($mform_signup); 118 } else { 119 // Fall back for auth plugins not using renderables. 120 $mform_signup->display(); 121 } 122 echo $OUTPUT->footer();
title
Description
Body
title
Description
Body
title
Description
Body
title
Body