]> git.mjollnir.org Git - moodle.git/commitdiff
auth/db: use auth_validate_form() to set auth_db_stdchangepassword when passtype...
authormartinlanghoff <martinlanghoff>
Tue, 18 Jul 2006 01:36:24 +0000 (01:36 +0000)
committermartinlanghoff <martinlanghoff>
Tue, 18 Jul 2006 01:36:24 +0000 (01:36 +0000)
When using the 'internal' password handling, set auth_db_stdchangepassword
so we allow users to change their password normally.

auth/db/lib.php

index c50b486575b1441a830f343e477d87d4359c26c5..9cc1228c3f4c6cd498d724c1ace71f4cd6c17e31 100644 (file)
@@ -409,4 +409,43 @@ function auth_db_update_user_record($username, $updatekeys=false) {
     return get_record_select("user", "username = '$username' AND deleted <> '1'");
 }
 
-?>
+// A chance to validate form data, and last chance to 
+// do stuff before it is inserted in config_plugin
+function auth_validate_form(&$form, &$err) {
+    
+    // compat until we rework auth a bit
+    if ($form['auth_dbpasstype'] === 'internal') {
+        $CFG->auth_db_stdchangepassword = true;
+        if ($conf = get_record('config', 'name', 'auth_db_stdchangepassword')) {
+            $conf->value = 1;
+            if (! update_record('config', $conf)) {
+                notify("Could not update $name to $value");
+            }
+        } else {
+            $conf = new StdClass;
+            $conf->name = 'auth_db_stdchangepassword';
+            $conf->value = 1;
+            if (! insert_record('config', $conf)) {
+                notify("Error: could not add new variable $name !");
+            }
+        }
+    } else {
+        $CFG->auth_db_stdchangepassword = false;
+        if ($conf = get_record('config', 'name', 'auth_db_stdchangepassword')) {
+            $conf->value = 0;
+            if (! update_record('config', $conf)) {
+                notify("Could not update $name to $value");
+            }
+        } else {
+            $conf = new StdClass;
+            $conf->name = 'auth_db_stdchangepassword';
+            $conf->value = 0;
+            if (! insert_record('config', $conf)) {
+                notify("Error: could not add new variable $name !");
+            }
+        }
+    }
+    return true;
+}
+
+?>
\ No newline at end of file