Merge commit 'catalyst/MOODLE_19_STABLE' into mdl19-linuxchix
[moodle-linuxchix.git] / login / signup.php
blob1cac1cb109227c7464e7b504da69a98fa6e849ab
1 <?php // $Id$
3 require_once('../config.php');
5 /**
6 * Returns whether or not the captcha element is enabled, and the admin settings fulfil its requirements.
7 * @return bool
8 */
9 function signup_captcha_enabled() {
10 global $CFG;
11 return isset($CFG->recaptchapublickey) && isset($CFG->recaptchaprivatekey) && get_config('auth/email', 'recaptcha');
14 require_once('signup_form.php');
17 if (empty($CFG->registerauth)) {
18 error("Sorry, you may not use this page.");
20 $authplugin = get_auth_plugin($CFG->registerauth);
22 if (!$authplugin->can_signup()) {
23 error("Sorry, you may not use this page.");
26 //HTTPS is potentially required in this page
27 httpsrequired();
29 $mform_signup = new login_signup_form();
31 if ($mform_signup->is_cancelled()) {
32 redirect($CFG->httpswwwroot.'/login/index.php');
34 } else if ($user = $mform_signup->get_data()) {
35 $user->confirmed = 0;
36 $user->lang = current_language();
37 $user->firstaccess = time();
38 $user->mnethostid = $CFG->mnet_localhost_id;
39 $user->secret = random_string(15);
40 $user->auth = $CFG->registerauth;
42 $authplugin->user_signup($user, true); // prints notice and link to login/index.php
43 exit; //never reached
46 $newaccount = get_string('newaccount');
47 $login = get_string('login');
49 if (empty($CFG->langmenu)) {
50 $langmenu = '';
51 } else {
52 $currlang = current_language();
53 $langs = get_list_of_languages();
54 $langmenu = popup_form ("$CFG->wwwroot/login/signup.php?lang=", $langs, "chooselang", $currlang, "", "", "", true);
57 $navlinks = array();
58 $navlinks[] = array('name' => $login, 'link' => "index.php", 'type' => 'misc');
59 $navlinks[] = array('name' => $newaccount, 'link' => null, 'type' => 'misc');
60 $navigation = build_navigation($navlinks);
61 print_header($newaccount, $newaccount, $navigation, $mform_signup->focus(), "", true, "<div class=\"langmenu\">$langmenu</div>");
63 $mform_signup->display();
64 print_footer();