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().
This commit is contained in:
+8
-9
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user