mirror of
https://github.com/moodle/moodle.git
synced 2025-01-18 22:08:20 +01:00
MDL-23747 fixed multiple PAGE->context issues, improved coding style and added license headers
This commit is contained in:
parent
e2a8447777
commit
c30949a93a
@ -16,14 +16,15 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file is part of the login section Moodle
|
||||
* Change password page.
|
||||
*
|
||||
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package login
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
require('../config.php');
|
||||
require_once('change_password_form.php');
|
||||
|
||||
$id = optional_param('id', SITEID, PARAM_INT); // current course
|
||||
@ -33,6 +34,7 @@ if ($id !== SITEID) {
|
||||
$url->param('id', $id);
|
||||
}
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$strparticipants = get_string('participants');
|
||||
|
||||
|
@ -1,8 +1,30 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Change password form definition.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 2006 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
@ -11,7 +33,7 @@ class login_change_password_form extends moodleform {
|
||||
function definition() {
|
||||
global $USER, $CFG;
|
||||
|
||||
$mform =& $this->_form;
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', '', get_string('changepassword'), '');
|
||||
|
||||
|
@ -1,6 +1,30 @@
|
||||
<?php
|
||||
|
||||
require_once("../config.php");
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Confirm self registered user.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
|
||||
$data = optional_param('data', '', PARAM_CLEAN); // Formatted as: secret/username
|
||||
|
||||
@ -8,6 +32,7 @@ $p = optional_param('p', '', PARAM_ALPHANUM); // Old parameter: secret
|
||||
$s = optional_param('s', '', PARAM_CLEAN); // Old parameter: username
|
||||
|
||||
$PAGE->set_url('/login/confirm.php');
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
if (empty($CFG->registerauth)) {
|
||||
print_error('cannotusepage2');
|
||||
|
@ -1,28 +1,27 @@
|
||||
<?php
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// //
|
||||
// This file is part of Moodle - http://moodle.org/ //
|
||||
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
|
||||
// //
|
||||
// Moodle is free software: you can redistribute it and/or modify //
|
||||
// it under the terms of the GNU General Public License as published by //
|
||||
// the Free Software Foundation, either version 3 of the License, or //
|
||||
// (at your option) any later version. //
|
||||
// //
|
||||
// Moodle is distributed in the hope that it will be useful, //
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
|
||||
// GNU General Public License for more details. //
|
||||
// //
|
||||
// You should have received a copy of the GNU General Public License //
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>. //
|
||||
// //
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
/*
|
||||
/**
|
||||
* This script can set environment variables in the current session
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 2009 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
|
@ -1,10 +1,32 @@
|
||||
<?php
|
||||
|
||||
// forgot password routine.
|
||||
// find the user and call the appropriate routine for their authentication
|
||||
// type.
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
require_once('../config.php');
|
||||
/**
|
||||
* Forgot password routine.
|
||||
*
|
||||
* Finds the user and calls the appropriate routine for their authentication type.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require('../config.php');
|
||||
require_once('forgot_password_form.php');
|
||||
|
||||
$p_secret = optional_param('p', false, PARAM_RAW);
|
||||
@ -13,14 +35,17 @@ $p_username = optional_param('s', false, PARAM_RAW);
|
||||
httpsrequired();
|
||||
|
||||
$systemcontext = get_context_instance(CONTEXT_SYSTEM);
|
||||
$PAGE->set_url('/login/forgot_password.php');
|
||||
$PAGE->set_context($syscontext);
|
||||
|
||||
// setup text strings
|
||||
$strforgotten = get_string('passwordforgotten');
|
||||
$strlogin = get_string('login');
|
||||
|
||||
$PAGE->set_url('/login/forgot_password.php');
|
||||
$PAGE->navbar->add($strlogin, get_login_url());
|
||||
$PAGE->navbar->add($strforgotten);
|
||||
$PAGE->set_title($strforgotten);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
|
||||
// if alternatepasswordurl is defined, then we'll just head there
|
||||
if (!empty($CFG->forgottenpasswordurl)) {
|
||||
@ -39,9 +64,6 @@ if ($p_secret !== false) {
|
||||
|
||||
update_login_count();
|
||||
|
||||
$PAGE->set_title($strforgotten);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
|
||||
$user = get_complete_user_data('username', $p_username);
|
||||
if (!empty($user) and $user->secret === '') {
|
||||
echo $OUTPUT->header();
|
||||
@ -132,8 +154,6 @@ if ($mform->is_cancelled()) {
|
||||
}
|
||||
}
|
||||
|
||||
$PAGE->set_title($strforgotten);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
|
||||
if (empty($user->email) or !empty($CFG->protectusernames)) {
|
||||
@ -152,8 +172,6 @@ if ($mform->is_cancelled()) {
|
||||
|
||||
|
||||
/// DISPLAY FORM
|
||||
$PAGE->set_title($strforgotten);
|
||||
$PAGE->set_heading($COURSE->fullname);
|
||||
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->box(get_string('passwordforgotteninstructions2'), 'generalbox boxwidthnormal boxaligncenter');
|
||||
|
@ -1,16 +1,37 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Reset forgotten password form definition.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 2006 Petr Skoda {@link http://skodak.org}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class login_forgot_password_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$renderer =& $mform->defaultRenderer();
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', '', get_string('searchbyusername'), '');
|
||||
|
||||
|
@ -16,22 +16,27 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file is part of the login section Moodle
|
||||
* Main login page.
|
||||
*
|
||||
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package login
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once("../config.php");
|
||||
require('../config.php');
|
||||
|
||||
redirect_if_major_upgrade_required();
|
||||
|
||||
$loginguest = optional_param('loginguest', 0, PARAM_BOOL); // determines whether visitors are logged in as guest automatically
|
||||
$testcookies = optional_param('testcookies', 0, PARAM_BOOL); // request cookie test
|
||||
|
||||
//HTTPS is potentially required in this page
|
||||
httpsrequired();
|
||||
|
||||
$context = get_context_instance(CONTEXT_SYSTEM);
|
||||
$PAGE->set_course($SITE);
|
||||
$PAGE->set_url("$CFG->httpswwwroot/login/index.php");
|
||||
$PAGE->set_context($context);
|
||||
$PAGE->set_pagelayout('login');
|
||||
|
||||
/// Initialize variables
|
||||
@ -56,11 +61,6 @@ foreach($authsequence as $authname) {
|
||||
$authplugin->loginpage_hook();
|
||||
}
|
||||
|
||||
//HTTPS is potentially required in this page
|
||||
httpsrequired();
|
||||
|
||||
$PAGE->set_url("$CFG->httpswwwroot/login/index.php");
|
||||
|
||||
|
||||
/// Define variables used in page
|
||||
$site = get_site();
|
||||
|
@ -18,14 +18,18 @@
|
||||
/**
|
||||
* Logs the user out and sends them to the home page
|
||||
*
|
||||
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package login
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once("../config.php");
|
||||
require_once('../config.php');
|
||||
|
||||
// can be overriden by auth plugins
|
||||
$PAGE->set_url('/login/logout.php');
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
// can be overridden by auth plugins
|
||||
$redirect = $CFG->wwwroot.'/';
|
||||
|
||||
$sesskey = optional_param('sesskey', '__notpresent__', PARAM_RAW); // we want not null default to prevent required sesskey warning
|
||||
@ -36,13 +40,10 @@ if (!isloggedin()) {
|
||||
redirect($redirect);
|
||||
|
||||
} else if (!confirm_sesskey($sesskey)) {
|
||||
$url = new moodle_url('/login/logout.php');
|
||||
if ($sesskey !== '__notpresent__') $url->param('sesskey', $sesskey);
|
||||
$PAGE->set_url($url);
|
||||
$PAGE->set_title($SITE->fullname);
|
||||
$PAGE->set_heading($SITE->fullname);
|
||||
echo $OUTPUT->header();
|
||||
echo $OUTPUT->confirm(get_string('logoutconfirm'), 'logout.php', $CFG->wwwroot.'/');
|
||||
echo $OUTPUT->confirm(get_string('logoutconfirm'), new moodle_url($PAGE->url, array('sesskey'=>sesskey())), $CFG->wwwroot.'/');
|
||||
echo $OUTPUT->footer();
|
||||
die;
|
||||
}
|
||||
|
@ -1,5 +1,29 @@
|
||||
<?php
|
||||
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* Magic that deals restored users without passwords.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com}
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
// This is one "supplanter" form that generates
|
||||
// one correct forgot_password.php request in
|
||||
// order to get the mailout for 'restored' users
|
||||
@ -11,16 +35,14 @@
|
||||
// part of each plugin, but now now. See MDL-20846
|
||||
// for the rationale for this implementation.
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once $CFG->libdir.'/formslib.php';
|
||||
|
||||
class login_forgot_password_form extends moodleform {
|
||||
|
||||
function definition() {
|
||||
$mform =& $this->_form;
|
||||
$mform = $this->_form;
|
||||
|
||||
$username = $this->_customdata['username'];
|
||||
|
||||
|
@ -16,39 +16,32 @@
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* This file is part of the login section Moodle
|
||||
* user signup page.
|
||||
*
|
||||
* @copyright 1999 Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
* @package login
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
require_once('../config.php');
|
||||
|
||||
/**
|
||||
* Returns whether or not the captcha element is enabled, and the admin settings fulfil its requirements.
|
||||
* @return bool
|
||||
*/
|
||||
function signup_captcha_enabled() {
|
||||
global $CFG;
|
||||
return !empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey) && get_config('auth/email', 'recaptcha');
|
||||
}
|
||||
|
||||
require('../config.php');
|
||||
require_once('signup_form.php');
|
||||
|
||||
|
||||
if (empty($CFG->registerauth)) {
|
||||
print_error("Sorry, you may not use this page.");
|
||||
print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
|
||||
}
|
||||
$authplugin = get_auth_plugin($CFG->registerauth);
|
||||
|
||||
if (!$authplugin->can_signup()) {
|
||||
print_error("Sorry, you may not use this page.");
|
||||
print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.');
|
||||
}
|
||||
|
||||
//HTTPS is potentially required in this page
|
||||
httpsrequired();
|
||||
$PAGE->set_url('/login/signup.php');
|
||||
$PAGE->set_context(get_context_instance(CONTEXT_SYSTEM));
|
||||
|
||||
$mform_signup = new login_signup_form();
|
||||
|
||||
if ($mform_signup->is_cancelled()) {
|
||||
@ -62,8 +55,8 @@ if ($mform_signup->is_cancelled()) {
|
||||
$user->mnethostid = $CFG->mnet_localhost_id;
|
||||
$user->secret = random_string(15);
|
||||
$user->auth = $CFG->registerauth;
|
||||
|
||||
$authplugin->user_signup($user, true); // prints notice and link to login/index.php
|
||||
|
||||
$authplugin->user_signup($user, true); // prints notice and link to login/index.php
|
||||
exit; //never reached
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,30 @@
|
||||
<?php
|
||||
|
||||
if (!defined('MOODLE_INTERNAL')) {
|
||||
die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page
|
||||
}
|
||||
// This file is part of Moodle - http://moodle.org/
|
||||
//
|
||||
// Moodle is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU General Public License as published by
|
||||
// the Free Software Foundation, either version 3 of the License, or
|
||||
// (at your option) any later version.
|
||||
//
|
||||
// Moodle is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
// GNU General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
/**
|
||||
* User sign-up form.
|
||||
*
|
||||
* @package core
|
||||
* @subpackage auth
|
||||
* @copyright 1999 onwards Martin Dougiamas http://dougiamas.com
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
|
||||
defined('MOODLE_INTERNAL') || die();
|
||||
|
||||
require_once($CFG->libdir.'/formslib.php');
|
||||
require_once($CFG->dirroot.'/user/profile/lib.php');
|
||||
@ -11,7 +33,7 @@ class login_signup_form extends moodleform {
|
||||
function definition() {
|
||||
global $USER, $CFG;
|
||||
|
||||
$mform =& $this->_form;
|
||||
$mform = $this->_form;
|
||||
|
||||
$mform->addElement('header', '', get_string('createuserandpass'), '');
|
||||
|
||||
@ -70,7 +92,7 @@ class login_signup_form extends moodleform {
|
||||
$mform->setDefault('country', '');
|
||||
}
|
||||
|
||||
if (signup_captcha_enabled()) {
|
||||
if ($this->signup_captcha_enabled()) {
|
||||
$mform->addElement('recaptcha', 'recaptcha_element', get_string('recaptcha', 'auth'), array('https' => $CFG->loginhttps));
|
||||
$mform->addHelpButton('recaptcha_element', 'recaptcha', 'auth');
|
||||
}
|
||||
@ -90,7 +112,7 @@ class login_signup_form extends moodleform {
|
||||
}
|
||||
|
||||
function definition_after_data(){
|
||||
$mform =& $this->_form;
|
||||
$mform = $this->_form;
|
||||
$mform->applyFilter('username', 'trim');
|
||||
}
|
||||
|
||||
@ -145,7 +167,7 @@ class login_signup_form extends moodleform {
|
||||
$errors['password'] = $errmsg;
|
||||
}
|
||||
|
||||
if (signup_captcha_enabled()) {
|
||||
if ($this->signup_captcha_enabled()) {
|
||||
$recaptcha_element = $this->_form->getElement('recaptcha_element');
|
||||
if (!empty($this->_form->_submitValues['recaptcha_challenge_field'])) {
|
||||
$challenge_field = $this->_form->_submitValues['recaptcha_challenge_field'];
|
||||
@ -160,6 +182,15 @@ class login_signup_form extends moodleform {
|
||||
|
||||
return $errors;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns whether or not the captcha element is enabled, and the admin settings fulfil its requirements.
|
||||
* @return bool
|
||||
*/
|
||||
function signup_captcha_enabled() {
|
||||
global $CFG;
|
||||
return !empty($CFG->recaptchapublickey) && !empty($CFG->recaptchaprivatekey) && get_config('auth/email', 'recaptcha');
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user