From 1590773b1c6c2edfa9935ee992271569874f98e1 Mon Sep 17 00:00:00 2001 From: martinlanghoff Date: Tue, 18 Jul 2006 01:36:06 +0000 Subject: [PATCH] auth: extend API to support auth_validate_form() Now Auth plugins can register auth_validate_form to get a chance to validate config form input. Needed on MOODLE_16_STABLE to fix a bug with auth/db. The auth API must follow suit with the enrol API, where we can safely do method_exists(). --- admin/auth.php | 17 ++++++++--------- auth/README | 8 ++++++++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/admin/auth.php b/admin/auth.php index a64baff8cf..80af18c75e 100644 --- a/admin/auth.php +++ b/admin/auth.php @@ -26,7 +26,6 @@ if ($config = data_submitted()) { $config = (array)$config; - validate_form($config, $err); // extract and sanitize the auth key explicitly $modules = get_list_of_plugins("auth"); @@ -36,6 +35,14 @@ notify("Error defining the authentication method"); } + // load the auth plugin library + require_once("{$CFG->dirroot}/auth/$auth/lib.php"); + + $err = array(); + if (function_exists('auth_validate_form')) { + auth_validate_form($config, $err); + } + if (count($err) == 0) { foreach ($config as $name => $value) { if (preg_match('/^pluginconfig_(.+?)$/', $name, $matches)) { @@ -233,14 +240,6 @@ /// Functions ///////////////////////////////////////////////////////////////// -function validate_form(&$form, &$err) { - - // if (empty($form->fullname)) - // $err["fullname"] = get_string("missingsitename"); - - return; -} - // // Good enough for most auth plugins // but some may want a custom one if they are offering diff --git a/auth/README b/auth/README index fb71829ad7..251d28ddbf 100644 --- a/auth/README +++ b/auth/README @@ -121,6 +121,14 @@ Optional: Userinformation in array ( name => value, .... or false in case of error + auth_validate_form(&$form, &$err) + + Validate form data. + + Returns: + Bool. Manipulates $form and $err arrays in place + + COURSE CREATING auth_iscreator($username) -- 2.39.5