From 04f82f56695aaab4a8ba74df288d4b35533a3e31 Mon Sep 17 00:00:00 2001 From: Damyon Wiese Date: Mon, 8 May 2017 16:14:01 +0800 Subject: [PATCH] MDL-58836 auth: Improve backwards compatibility Auth plugins with custom signup forms may not be using renderables / renderers - or even if they are they may return a renderable that can only be rendered with the renderer from the auth plugin. This change checks if the signup form is a renderable - if so try the plugin renderer or fall back on the general renderer. Otherwise call display() from the mform which is the previous way of rendering an mform. --- auth/classes/output/login.php | 2 +- login/signup.php | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/auth/classes/output/login.php b/auth/classes/output/login.php index 5b924bb467b..2a507bd3af2 100644 --- a/auth/classes/output/login.php +++ b/auth/classes/output/login.php @@ -143,7 +143,7 @@ class login implements renderable, templatable { $data->error = $this->error; $data->forgotpasswordurl = $this->forgotpasswordurl->out(false); $data->hasidentityproviders = !empty($this->identityproviders); - $data->hasinstructions = !empty($this->instructions); + $data->hasinstructions = !empty($this->instructions) || $this->cansignup; $data->identityproviders = $identityproviders; list($data->instructions, $data->instructionsformat) = external_format_text($this->instructions, FORMAT_MOODLE, context_system::instance()->id); diff --git a/login/signup.php b/login/signup.php index e14518006cd..dc6774dd0ee 100644 --- a/login/signup.php +++ b/login/signup.php @@ -97,5 +97,17 @@ $PAGE->set_heading($SITE->fullname); echo $OUTPUT->header(); -echo $OUTPUT->render($mform_signup); +if ($mform_signup instanceof renderable) { + // Try and use the renderer from the auth plugin if it exists. + try { + $renderer = $PAGE->get_renderer('auth_' . $authplugin->authtype); + } catch (coding_exception $ce) { + // Fall back on the general renderer. + $renderer = $OUTPUT; + } + echo $renderer->render($mform_signup); +} else { + // Fall back for auth plugins not using renderables. + $mform_signup->display(); +} echo $OUTPUT->footer();