From 57d38adc585ddc6b245454c78bc9c5fd0d296ea5 Mon Sep 17 00:00:00 2001 From: Michael Aherne Date: Wed, 1 Aug 2012 15:23:05 +0100 Subject: [PATCH] MDL-34685 auth Allow auth plugins to override user signup form --- auth/upgrade.txt | 2 ++ lib/authlib.php | 12 ++++++++++++ login/signup.php | 4 +--- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/auth/upgrade.txt b/auth/upgrade.txt index f25d0eab87e..4618dd53e9f 100644 --- a/auth/upgrade.txt +++ b/auth/upgrade.txt @@ -8,6 +8,8 @@ required changes in code: * use role_get_name() or role_fix_names() if you need any role names, using role.name directly from database is not correct any more +optional - no changes needed: +* add support for custom user signup form - see auth_plugin_base::signup_form() function === 2.2 === diff --git a/lib/authlib.php b/lib/authlib.php index 7bb1d17324f..690228e7f95 100644 --- a/lib/authlib.php +++ b/lib/authlib.php @@ -278,6 +278,18 @@ class auth_plugin_base { //override when can signup print_error('mustbeoveride', 'debug', '', 'user_signup()' ); } + + /** + * Return a form to capture user details for account creation. + * This is used in /login/signup.php. + * @return moodle_form A form which edits a record from the user table. + */ + function signup_form() { + global $CFG; + + require_once($CFG->dirroot.'/login/signup_form.php'); + return new login_signup_form(null, null, 'post', '', array('autocomplete'=>'on')); + } /** * Returns true if plugin allows confirming of new users. diff --git a/login/signup.php b/login/signup.php index e622aba21e8..331f9ef4691 100644 --- a/login/signup.php +++ b/login/signup.php @@ -25,8 +25,6 @@ */ require('../config.php'); -require_once('signup_form.php'); - if (empty($CFG->registerauth)) { print_error('notlocalisederrormessage', 'error', '', 'Sorry, you may not use this page.'); @@ -43,7 +41,7 @@ $PAGE->https_required(); $PAGE->set_url('/login/signup.php'); $PAGE->set_context(context_system::instance()); -$mform_signup = new login_signup_form(null, null, 'post', '', array('autocomplete'=>'on')); +$mform_signup = $authplugin->signup_form(); if ($mform_signup->is_cancelled()) { redirect(get_login_url());