]> git.mjollnir.org Git - moodle.git/commitdiff
Changes to allow admin to control the "forgot password" function
authormoodler <moodler>
Fri, 22 Nov 2002 08:43:35 +0000 (08:43 +0000)
committermoodler <moodler>
Fri, 22 Nov 2002 08:43:35 +0000 (08:43 +0000)
and a bug fix for set_config

admin/auth.php
auth/imap/config.html
auth/pop3/config.html
doc/release.html
lang/en/auth.php
lang/en/moodle.php
lib/moodlelib.php
login/index_form.html

index d51cea1b9c5496aa1dd36f28e7391e5b5164164c..7d1e2fad9d9083eb1e164e17b59e2d7b483db1e1 100644 (file)
         if (count($err) == 0) {
             print_header();
             foreach ($config as $name => $value) {
-                unset($conf);
-                $conf->name  = $name;
-                $conf->value = $value;
-                if ($current = get_record("config", "name", $name)) {
-                    $conf->id = $current->id;
-                    if (! update_record("config", $conf)) {
-                        notify("Could not update $name to $value");
-                    }
-                } else {
-                    if (! insert_record("config", $conf)) {
-                        notify("Error: could not add new variable $name !");
-                    }
+                if (! set_config($name, $value)) {
+                    notify("Problem saving config $name as $value");
                 }
             }
             redirect("auth.php", get_string("changessaved"), 1);
 
     require("$CFG->dirroot/auth/$auth/config.html");
 
+    if ($auth != "email" and $auth != "none") {
+        echo "<tr valign=\"top\">";
+           echo "<td align=right nowrap><p>";
+        print_string("changepassword", "auth");
+        echo ":</p></td>";
+           echo "<td>";
+        echo "<INPUT TYPE=\"text\" NAME=\"changepassword\" SIZE=40 VALUE=\"$config->changepassword\">";
+        echo "</td>";
+        echo "<td>";
+        print_string("changepasswordhelp","auth");
+        echo "</td></tr>";
+
+    }
+
     echo "<tr valign=\"top\">";
        echo "<td align=right nowrap><p>";
     print_string("guestloginbutton", "auth");
     print_string("showguestlogin","auth");
     echo "</td></tr></table>";
 
+
     echo "<CENTER><P><INPUT TYPE=\"submit\" VALUE=\"";
     print_string("savechanges");
     echo "\"></P></CENTER></FORM>";
index 34b3975cc618cc391469594100cd6b923fdec9c2..79089256d4e8ffb7a4874430ecf5463519088d79 100644 (file)
        <TD ALIGN=RIGHT><P>auth_imaptype:</TD>
        <TD>
     <? $imaptypes = array("imap","imapssl", "imapcert", "imaptls");
-       choose_from_menu($imaptypes, "auth_imaptype", $config->auth_imaptype, "");
+       foreach($imaptypes as $imaptype) {
+           $imapoptions[$imaptype] = $imaptype;
+       }
+       choose_from_menu($imapoptions, "auth_imaptype", $config->auth_imaptype, "");
     ?>
     </TD>
     <TD>
index a219c13e413ade9f894afc7d6bb851c374acb6e6..19847cc55f6edb7c4991ab0fba17e5b7af5386bc 100644 (file)
        <TD ALIGN=RIGHT><P>auth_pop3type:</TD>
        <TD>
     <? $pop3types = array("pop3","pop3cert");
-       choose_from_menu($pop3types, "auth_pop3type", $config->auth_pop3type, "");
+       foreach($pop3types as $pop3type) {
+           $pop3options[$pop3type] = $pop3type;
+       }
+       choose_from_menu($pop3options, "auth_pop3type", $config->auth_pop3type, "");
     ?>
     <? formerr($err["auth_pop3type"]); ?>
     </TD>
index bd9acf09ff8f0bc4d96ede8f2887fe2bdbd9f253..ca9e3b15727532bef2e2931fccaafc88db20a3e4 100644 (file)
@@ -18,7 +18,7 @@
      authentication against user-specified fields in ANY 
      external database table.  In addition, Moodle now sports a cool 
      new admin GUI for configuring all of this, so it should be pretty 
-     easy to configure all of this.
+     easy to configure external authentication.
      Thanks to contributor Petri Asikainen for his work on the GUI.<BR><BR>
 
 <DT> Languages
@@ -39,7 +39,7 @@
      <LI> User pictures are now uploaded even if other fields have errors
      <LI> Submitted assignments were sometimes having their owner changed - fixed.
      <LI> Admin can always log in regardless of external authentication
-     <LI> User log graphs are now translatable
+     <LI> User log graphs are now faster, cleaner and translatable
      </UL>
 
 </DL></UL>
index 86994ee70f088811aec7730c3aa2dd7213305b0c..5995e22896721ae8711dc52c443945d5557d19f9 100644 (file)
@@ -48,6 +48,8 @@ $string['auth_pop3title'] = "Use a POP3 server";
 $string['auth_pop3type'] = "Server type. If your server uses certificate security, choose pop3cert.";
 $string['authenticationoptions'] = "Authentication options";
 $string['authinstructions'] = "Here you can provide instructions for your users, so they know which username and password they should be using.  The text you enter here will appear on the login page.  If you leave this blank then no instructions will be printed.";
+$string['changepassword'] = "Change password URL";
+$string['changepasswordhelp'] = "Here you can specify a location at which your users can recover or change their username/password if they've forgotten it.  This will be provided to users as a button on the login page.  if you leave this blank the button will not be printed.";
 $string['chooseauthmethod'] = "Choose an authentication method: ";
 $string['guestloginbutton'] = "Guest login button";
 $string['showguestlogin'] = "You can hide or show the guest login button on the login page.";
index 8912452cde59521033c176de79bb7510dce515aa..5b003eb9842043561cb1b49bf9b225d77ad3bb41 100644 (file)
@@ -384,6 +384,7 @@ $string['participants'] = "Participants";
 $string['password'] = "Password";
 $string['passwordchanged'] = "Password has been changed";
 $string['passwordsdiffer'] = "These passwords do not match";
+$string['passwordrecovery'] = "Yes, help me log in";
 $string['passwordsent'] = "Password has been sent";
 $string['passwordsenttext'] = "
    <P>An email has been sent to your address at \$a->email.
index d625052e6187878bfe257f59456a79e89c32aded..51ae6dd784e1e1a8b0192def14aff15b5c04f03f 100644 (file)
@@ -980,7 +980,7 @@ function set_field($table, $field, $newvalue, $selector, $value) {
 function set_config($name, $value) {
 // No need for get_config because they are usually always available in $CFG
 
-    if (get_field("config", "value", "name", $name)) {
+    if (get_field("config", "name", "name", $name)) {
         return set_field("config", "value", $value, "name", $name);
     } else {
         $config->name = $name;
@@ -1432,17 +1432,31 @@ function authenticate_user_login($username, $password) {
 
     global $CFG;
 
+    $md5password = md5($password);
+
     if (!isset($CFG->auth)) {
         $CFG->auth = "email";    // Default authentication module
     }
 
+    if ($username == "guest") {
+        $CFG->auth = "none";     // Guest account always internal
+    }
+
+    // If this is the admin, then just use internal methods
+    if ($user = get_record_sql("SELECT u.id FROM user u, user_admins a 
+                                WHERE u.id = a.user 
+                                  AND u.username = '$username' 
+                                  AND u.password = '$md5password'")) {
+        return get_user_info_from_db("username", $username);
+    }
+
     require_once("$CFG->dirroot/auth/$CFG->auth/lib.php");
 
     if (auth_user_login($username, $password)) {  // Successful authentication
 
         if ($user = get_user_info_from_db("username", $username)) {
-            if (md5($password) <> $user->password) {
-                set_field("user", "password", md5($password), "username", $username);
+            if ($md5password <> $user->password) {
+                set_field("user", "password", $md5password, "username", $username);
             }
             return $user;
 
@@ -1451,15 +1465,6 @@ function authenticate_user_login($username, $password) {
         }
     }
 
-    // It's possible that the user is the admin user, defined locally.
-    $password = md5($password);
-    if ($user = get_record_sql("SELECT u.id FROM user u, user_admins a 
-                                WHERE u.id = a.user 
-                                  AND u.username = '$username' 
-                                  AND u.password = '$password'")) {
-        return get_user_info_from_db("username", $username);
-    }
-
     return false;
 }
 
index 375850597f693826c4cb4862e57bc771406197d0..91d174e92c23ee4109b637958357ccf9b6a089de 100644 (file)
             </FORM>\r
             </CENTER>\r
     <? } ?>\r
-      <HR>\r
-        <P ALIGN=CENTER><? print_string("forgotten") ?></P> \r
-        <CENTER>\r
-        <FORM NAME="form3" ACTION="forgot_password.php" METHOD=post>\r
-        <INPUT type="submit" NAME="Submit" VALUE="<? print_string("senddetails") ?>">\r
-        </FORM>\r
-        </CENTER>\r
+    <? if ($CFG->changepassword or $CFG->auth == "email" or $CFG->auth == "none") {\r
+          if ($CFG->auth == "email" or $CFG->auth == "none") {\r
+              $changepassword = "forgot_password.php";\r
+              $changebuttonname = get_string("senddetails");\r
+          } else {\r
+              $changepassword = $CFG->changepassword;\r
+              $changebuttonname = get_string("passwordrecovery");\r
+          }\r
+    \r
+    ?>\r
+          <HR>\r
+            <P ALIGN=CENTER><? print_string("forgotten") ?></P> \r
+            <CENTER>\r
+            <FORM NAME="form3" ACTION="<?=$changepassword ?>" METHOD=post>\r
+            <INPUT type="submit" NAME="Submit" VALUE="<?=$changebuttonname?>">\r
+            </FORM>\r
+            </CENTER>\r
+    <? } ?>\r
         </BLOCKQUOTE>\r
       </FONT> </TD>\r
     <? if ($show_instructions) { ?>\r