]> git.mjollnir.org Git - moodle.git/commitdiff
auth: extend API to support auth_validate_form()
authormartinlanghoff <martinlanghoff>
Tue, 18 Jul 2006 01:36:06 +0000 (01:36 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 18 Jul 2006 01:36:06 +0000 (01:36 +0000)
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
auth/README

index a64baff8cf2f4892a74f91eabb8a33493f05e33a..80af18c75efe57d579d059b860b9592af8dfb7df 100644 (file)
@@ -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");
             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)) {
 
 /// 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
index fb71829ad74d4810c3424e95df1522df7bf25212..251d28ddbf94f5e861299372271be0bc45c36d53 100644 (file)
@@ -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)