]> git.mjollnir.org Git - moodle.git/commitdiff
A significant new system for authentication configuration that
authormoodler <moodler>
Tue, 19 Nov 2002 08:51:33 +0000 (08:51 +0000)
committermoodler <moodler>
Tue, 19 Nov 2002 08:51:33 +0000 (08:51 +0000)
exposes the wide array of authentication possibilities.

Authentication now has it's own page separate from other variables.

Most of this work was done by Petri Asikainen <paca@sci.fi>, who started
these changes off.

I've done some cleanups and additions which is why I'm checking it in.

It's all working pretty well at the moment but could use some testing.

Thanks, Petri!  :-)

18 files changed:
admin/auth.php [new file with mode: 0644]
admin/config.html
admin/index.php
auth/db/config.html [new file with mode: 0644]
auth/db/lib.php
auth/email/config.html [new file with mode: 0644]
auth/imap/config.html [new file with mode: 0644]
auth/imap/lib.php
auth/ldap/config.html [new file with mode: 0644]
auth/nntp/config.html [new file with mode: 0644]
auth/nntp/lib.php
auth/none/config.html [new file with mode: 0644]
auth/pop3/config.html [new file with mode: 0644]
auth/pop3/lib.php
lang/en/auth.php [new file with mode: 0644]
lang/en/moodle.php
login/index.php
login/index_form.html

diff --git a/admin/auth.php b/admin/auth.php
new file mode 100644 (file)
index 0000000..fcb657c
--- /dev/null
@@ -0,0 +1,135 @@
+<?PHP  // $Id$
+       // config.php - allows admin to edit all configuration variables
+
+    include("../config.php");
+
+    require_login();
+
+    if (!$site = get_site()) {
+        redirect("index.php");
+    }
+
+    if (!isadmin()) {
+        error("Only the admin can use this page");
+    }
+
+
+/// If data submitted, then process and store.
+
+       if (match_referer() && isset($HTTP_POST_VARS)) {
+
+        $config = (object)$HTTP_POST_VARS;
+
+        validate_form($config, $err);
+
+        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 !");
+                    }
+                }
+            }
+            redirect("auth.php", get_string("changessaved"), 1);
+            exit;
+
+        } else {
+            foreach ($err as $key => $value) {
+                $focus = "form.$key";
+            }
+        }
+       }
+
+/// Otherwise fill and print the form.
+
+    if (!isset($config)) {
+        $config = $CFG;
+    }
+
+    $modules = get_list_of_plugins("auth");
+    foreach ($modules as $module) {
+        $options[$module] = get_string("auth_$module"."title", "auth");
+    }
+    asort($options);
+       if (isset($_GET['auth'])) {
+           $auth = $_GET['auth'];
+       } else {
+        $auth = $config->auth;
+       } 
+
+    if (! isset($config->guestloginbutton)) {
+        $config->guestloginbutton = 1;
+    }
+    $guestoptions[0] = get_string("hide");
+    $guestoptions[1] = get_string("show");
+
+    $stradministration        = get_string("administration");
+    $strauthentication        = get_string("authentication");
+    $strauthenticationoptions = get_string("authenticationoptions","auth");
+    $strsettings = get_string("settings");
+
+    print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
+                  "<A HREF=\"index.php\">$stradministration</A> -> $strauthenticationoptions", "$focus");
+
+    echo "<CENTER><P><B>";
+    echo "<form TARGET=\"_top\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
+    print_string("chooseauthmethod","auth");
+
+       choose_from_menu ($options, "auth", $auth, "","top.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
+
+    echo "</B></P></CENTER>";
+        
+    print_simple_box_start("center", "100%", "$THEME->cellheading");
+    print_heading($options[$auth]);
+
+    echo "<CENTER><P>";
+    print_string("auth_$auth"."description", "auth");
+    echo "</P></CENTER>";
+
+    echo "<HR>";
+
+    print_heading($strsettings);
+
+    echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
+
+    require("$CFG->dirroot/auth/$auth/config.html");
+
+    echo "<tr valign=\"top\">";
+       echo "<td align=right><p>guestloginbutton:</p></td>";
+       echo "<td>";
+    choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
+    echo "</td>";
+    echo "<td>";
+    print_string("showguestlogin","auth");
+    echo "</td></tr></table>";
+
+    echo "<CENTER><P><INPUT TYPE=\"submit\" VALUE=\"";
+    print_string("savechanges");
+    echo "\"></P></CENTER></FORM>";
+
+    print_simple_box_end(); 
+
+    print_footer();
+    exit; 
+
+/// Functions /////////////////////////////////////////////////////////////////
+
+function validate_form(&$form, &$err) {
+
+   // if (empty($form->fullname))
+   //     $err["fullname"] = get_string("missingsitename");
+
+    return;
+}
+
+
+?>
index 9b1642c04c45512de0885fb89d225327658f0120..4a4dfd5f158dfee9762794930ff0b4973caa7f6e 100644 (file)
@@ -1,22 +1,6 @@
 <FORM METHOD="post" action="config.php" NAME="form">
 
 <TABLE cellpadding=9 cellspacing=0 >
-<TR VALIGN=TOP>
-       <TD ALIGN=RIGHT><P>auth:</TD>
-       <TD>
-    <? $modules = get_list_of_plugins("auth");
-       foreach ($modules as $module) {
-           $options[$module] = $module;
-       }
-       choose_from_menu ($options, "auth", $config->auth, "", "", "");
-       formerr($err["auth"]);
-       unset($options);
-    ?>
-    </TD>
-    <TD>
-    <? print_string("configauth") ?>
-    </TD>
-</TR>
 <TR VALIGN=TOP>
        <TD ALIGN=RIGHT><P>lang:</TD>
        <TD>
index f1a8aff0bc69953c5d293ba844b4640f52a01d4f..e1649a3a0566ed3c104131825dec7e74858f3a32 100644 (file)
                          "<P><A HREF=\"../course/delete.php\">".get_string("deletecourse")."</A></P>".
                          "<P><A HREF=\"../course/categories.php\">".get_string("categories")."</A></P>";
     $table->data[0][2] = "<P><A HREF=\"user.php?newuser=true\">".get_string("addnewuser")."</A></P>".
-                         "<P><A HREF=\"user.php\">".get_string("edituser")."</A></P>";
+                         "<P><A HREF=\"user.php\">".get_string("edituser")."</A></P>".
+                         "<P><A HREF=\"auth.php\">".get_string("authentication")."</A></P>";
 
     print_table($table);
 
diff --git a/auth/db/config.html b/auth/db/config.html
new file mode 100644 (file)
index 0000000..493b921
--- /dev/null
@@ -0,0 +1,100 @@
+<tr valign="top">
+       <TD ALIGN=RIGHT><P>auth_dbhost:</TD>
+       <TD>
+        <INPUT name=auth_dbhost TYPE=text SIZE=30 VALUE="<?=$config->auth_dbhost?>">
+       <? formerr($err["auth_dbhost"]); ?>
+       </TD>
+    <TD>
+    <? print_string("auth_dbhost","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbtype:</TD>
+       <TD>
+    <? $dbtypes = array("access","ado_access", "ado", "ado_mssql", "borland_ibase", "csv", "db2", "fbsql", "firebird", "ibase", "informix72", "informix", "mssql", "mysql", "mysqlt", "oci805", "oci8", "oci8po", "odbc", "odbc_mssql", "odbc_oracle", "oracle", "postgres64", "postgres7", "postgres", "proxy", "sqlanywhere", "sybase", "vfp");
+       choose_from_menu($dbtypes, "auth_dbtype", $config->auth_dbtype, "");
+    ?>
+      
+    </TD>
+    <TD>
+    <? print_string("auth_dbtype","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbname:</TD>
+       <TD>
+    <INPUT name=auth_dbname TYPE=text SIZE=30 VALUE="<?=$config->auth_dbname?>">
+    <? formerr($err["auth_dbname"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_dbname","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbuser:</TD>
+       <TD>
+    <INPUT name=auth_dbuser TYPE=text SIZE=30 VALUE="<?=$config->auth_dbuser?>">
+    <? formerr($err["auth_dbuser"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_dbuser","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbpass:</TD>
+       <TD>
+    <INPUT name="auth_dbpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbpass?>">
+    <? formerr($err["auth_dbpass"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_dbpass","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbtable:</TD>
+       <TD>
+    <INPUT name="auth_dbtable" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbtable?>">
+    <? formerr($err["auth_dbtable"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_dbtable","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbfielduser:</TD>
+       <TD>
+    <INPUT name="auth_dbfielduser" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfielduser?>">
+    <? formerr($err["auth_dbfielduser"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_dbfielduser","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_dbfieldpass:</TD>
+       <TD>
+    <INPUT name="auth_dbfieldpass" TYPE="text" SIZE="30" VALUE="<?=$config->auth_dbfieldpass?>">
+    <? formerr($err["auth_dbfieldpass"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_dbfieldpass","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+       <TD>
+    <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA> 
+    </TD>
+    <TD>
+    <? print_string("authinstructions","auth") ?>
+    <? helpbutton("text", get_string("helptext")) ?>
+    </TD>
+</TR>
index 9f220e7415db373fe4ab5d1b52bd417c9c38aab2..28aeee25bca5fbc5eae2112fcb521edb388b87d6 100644 (file)
@@ -4,15 +4,6 @@
 // This code is completely untested so far - IT NEEDS TESTERS!
 // Looks like it should work though ...
 
-$CFG->auth_dbhost   = "localhost"; // The computer hosting the database server
-$CFG->auth_dbtype   = "mysql";     // The database type (mysql, postgres7, access, oracle etc)
-$CFG->auth_dbname   = "authtest";  // Name of the database itself
-$CFG->auth_dbuser   = "user";      // Username with read access to the database
-$CFG->auth_dbpass   = "pass";      // Password matching the above username
-$CFG->auth_dbtable  = "users";     // Name of the table in the database
-$CFG->auth_dbfielduser = "user";   // Name of the field containing usernames
-$CFG->auth_dbfieldpass = "pass";   // Name of the field containing passwords
-$CFG->auth_instructions = "Use the same username and password as your school account";   // Instructions
 
 function auth_user_login ($username, $password) {
 // Returns true if the username and password work
diff --git a/auth/email/config.html b/auth/email/config.html
new file mode 100644 (file)
index 0000000..ad9ab1e
--- /dev/null
@@ -0,0 +1 @@
+<!-- No config needed -->
diff --git a/auth/imap/config.html b/auth/imap/config.html
new file mode 100644 (file)
index 0000000..2f0e5c7
--- /dev/null
@@ -0,0 +1,44 @@
+<tr valign="top">
+       <TD ALIGN=RIGHT><P>auth_imaphost:</TD>
+       <TD>
+        <INPUT name=auth_imaphost TYPE=text SIZE=30 VALUE="<?=$config->auth_imaphost?>">
+       <? formerr($err["ldap_host_url"]); ?>
+       </TD>
+    <TD>
+    <? print_string("auth_imaphost","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_imaptype:</TD>
+       <TD>
+    <? $imaptypes = array("imap","imapssl", "imapcert", "imaptls");
+       choose_from_menu($imaptypes, "auth_imaptype", $config->auth_imaptype, "");
+    ?>
+    </TD>
+    <TD>
+    <? print_string("auth_imaptype","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_imapport:</TD>
+       <TD>
+    <INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_imapport?>">
+    <? formerr($err["auth_imapport"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_imapport","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+       <TD>
+    <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA> 
+    </TD>
+    <TD>
+    <? print_string("authinstructions","auth") ?>
+    <? helpbutton("text", get_string("helptext")) ?>
+    </TD>
+</TR>
index c16faeefd642f9e19e3a83c7529bb9ea7a3f9dff..ab0d9fa5c0cab741f39eb5eb719e1f4a0200251d 100644 (file)
@@ -1,15 +1,6 @@
 <?PHP  // $Id$
        // Authentication by looking up an IMAP server
 
-// This code is completely untested so far  -  IT NEEDS TESTERS!
-// Looks like it should work though ...
-
-$CFG->auth_imaphost   = "127.0.0.1";  // Should be IP number
-$CFG->auth_imaptype   = "imap";       // imap, imaptls, imapssl, imapcert
-$CFG->auth_imapport   = "143";        // 143, 993
-$CFG->auth_instructions = "Use the same username and password as your school email account";   // Instructions
-
-
 function auth_user_login ($username, $password) {
 // Returns true if the username and password work
 // and false if they are wrong or don't exist.
@@ -18,22 +9,26 @@ function auth_user_login ($username, $password) {
 
     switch ($CFG->auth_imaptype) {
         case "imapssl":
-            $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl}INBOX";
+            $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl}";
         break;
 
         case "imapcert":
-            $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl/novalidate-cert}INBOX";
+            $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/ssl/novalidate-cert}";
         break;
 
         case "imaptls":
-            $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/notls}INBOX";
+            $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport/imap/notls}";
         break;
 
         default:
             $host = "{".$CFG->auth_imaphost.":$CFG->auth_imapport}";
     }
 
-    if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
+    error_reporting(0);
+    $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+    error_reporting(7);   
+
+    if ($connection) {
         imap_close($connection);
         return true;
 
diff --git a/auth/ldap/config.html b/auth/ldap/config.html
new file mode 100644 (file)
index 0000000..6a8a26f
--- /dev/null
@@ -0,0 +1,74 @@
+<tr valign="top">
+       <TD ALIGN=RIGHT><P>ldap_host_url:</TD>
+       <TD>
+        <INPUT name=ldap_host_url TYPE=text SIZE=30 VALUE="<?=$config->ldap_host_url?>">
+       <? formerr($err["ldap_host_url"]); ?>
+       </TD>
+    <TD>
+    <? print_string("auth_ldap_host_url","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>ldap_user_context(s):</TD>
+       <TD>
+    <INPUT name=ldap_contexts TYPE=text SIZE=30 VALUE="<?=$config->ldap_contexts?>">
+    <? formerr($err["ldap_contexts"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_ldap_contexts","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>ldap_user_attribute(s):</TD>
+       <TD>
+    <INPUT name=ldap_user_attribute TYPE=text SIZE=30 VALUE="<?=$config->ldap_user_attribute?>">
+    <? formerr($err["ldap_user_attribute"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_ldap_user_attribute","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>ldap_search_sub:</TD>
+       <TD>
+    <INPUT name=ldap_search_sub TYPE=text SIZE=1 VALUE="<?=$config->ldap_search_sub?>">
+    <? formerr($err["ldap_search_sub"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_ldap_search_sub","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>ldap_bind_dn:</TD>
+       <TD>
+    <INPUT name=ldap_bind_dn TYPE=text SIZE=30 VALUE="<?=$config->ldap_bind_dn?>">
+    <? formerr($err["ldap_bind_dn"]); ?>
+    </TD><TD>
+    <? print_string("auth_ldap_bind_dn","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>ldap_bind_password:</TD>
+       <TD>
+    <INPUT name=ldap_bind_pw TYPE=text SIZE=30 VALUE="<?=$config->ldap_bind_pw?>">
+    <? formerr($err["ldap_bind_pw"]); ?>
+    </TD><TD>
+    <? print_string("auth_ldap_bind_pw","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+       <TD>
+    <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA> 
+    </TD>
+    <TD>
+    <? print_string("authinstructions","auth") ?>
+    <? helpbutton("text", get_string("helptext")) ?>
+    </TD>
+</TR>
diff --git a/auth/nntp/config.html b/auth/nntp/config.html
new file mode 100644 (file)
index 0000000..f949291
--- /dev/null
@@ -0,0 +1,32 @@
+<tr valign="top">
+       <TD ALIGN=RIGHT><P>auth_nntphost:</TD>
+       <TD>
+        <INPUT name="auth_nntphost" TYPE="text" SIZE=30 VALUE="<?=$config->auth_nntphost?>">
+       <? formerr($err["ldap_nntphost"]); ?>
+       </TD>
+    <TD>
+    <? print_string("auth_nntphost","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_nntpport:</TD>
+       <TD>
+    <INPUT name=auth_imapport TYPE=text SIZE=6 VALUE="<?=$config->auth_nntpport?>">
+    <? formerr($err["auth_nntpport"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_nntpport","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+       <TD>
+    <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA> 
+    </TD>
+    <TD>
+    <? print_string("authinstructions","auth") ?>
+    <? helpbutton("text", get_string("helptext")) ?>
+    </TD>
+</TR>
index 605fcaf5c6ff87718b0f2cd02bd9f18dc88ba008..6ed1cfeac77c7532e422f159de4624baf05747a2 100644 (file)
@@ -4,10 +4,6 @@
 // This code is completely untested so far  -  IT NEEDS TESTERS!
 // Looks like it should work though ...
 
-$CFG->auth_nntphost   = "127.0.0.1";  // Should be IP number
-$CFG->auth_nntpport   = "119";        // 119 is most common
-$CFG->auth_instructions = "Use the same username and password as your school news account";   // Instructions
-
 
 function auth_user_login ($username, $password) {
 // Returns true if the username and password work
@@ -17,7 +13,11 @@ function auth_user_login ($username, $password) {
 
     $host = "{".$CFG->auth_nntphost.":$CFG->auth_nntpport/nntp}";
 
-    if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
+    error_reporting(0);
+    $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+    error_reporting(7);   
+
+    if ($connection) {
         imap_close($connection);
         return true;
 
diff --git a/auth/none/config.html b/auth/none/config.html
new file mode 100644 (file)
index 0000000..ad9ab1e
--- /dev/null
@@ -0,0 +1 @@
+<!-- No config needed -->
diff --git a/auth/pop3/config.html b/auth/pop3/config.html
new file mode 100644 (file)
index 0000000..97fb3d3
--- /dev/null
@@ -0,0 +1,45 @@
+<tr valign="top">
+       <TD ALIGN=RIGHT><P>auth_pop3host:</TD>
+       <TD>
+        <INPUT name=auth_pop3host TYPE=text SIZE=30 VALUE="<?=$config->auth_pop3host?>">
+       <? formerr($err["ldap_host_url"]); ?>
+       </TD>
+    <TD>
+    <? print_string("auth_pop3host","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_pop3type:</TD>
+       <TD>
+    <? $pop3types = array("pop3","pop3cert");
+       choose_from_menu($pop3types, "auth_pop3type", $config->auth_pop3type, "");
+    ?>
+    <? formerr($err["auth_pop3type"]); ?>
+    </TD>
+<TD>
+    <? print_string("auth_pop3type","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_pop3port:</TD>
+       <TD>
+    <INPUT name=auth_pop3port TYPE=text SIZE=6 VALUE="<?=$config->auth_pop3port?>">
+    <? formerr($err["auth_pop3port"]); ?>
+    </TD>
+    <TD>
+    <? print_string("auth_pop3port","auth") ?>
+    </TD>
+</TR>
+
+<TR VALIGN=TOP>
+       <TD ALIGN=RIGHT><P>auth_instructions:</TD>
+       <TD>
+    <TEXTAREA NAME=auth_instructions COLS=30 ROWS=10 WRAP=virtual><? p($config->auth_instructions) ?></TEXTAREA> 
+    </TD>
+    <TD>
+    <? print_string("authinstructions","auth") ?>
+    <? helpbutton("text", get_string("helptext")) ?>
+    </TD>
+</TR>
index 9a04493d1549150a3b6a4b72e6042b648b107e92..88412f6b98149955e8652064910b58626202dd87 100644 (file)
@@ -4,12 +4,6 @@
 // This code is completely untested so far  -  IT NEEDS TESTERS!
 // Looks like it should work though ...
 
-$CFG->auth_pop3host   = "127.0.0.1";  // Should be IP number
-$CFG->auth_pop3type   = "pop3";       // pop3, pop3cert
-$CFG->auth_pop3port   = "110";        // 110 is most common
-$CFG->auth_instructions = "Use the same username and password as your school email account";   // Instructions
-
-
 function auth_user_login ($username, $password) {
 // Returns true if the username and password work
 // and false if they are wrong or don't exist.
@@ -25,7 +19,11 @@ function auth_user_login ($username, $password) {
         break;
     }
 
-    if ($connection = imap_open($host, $username, $password, OP_HALFOPEN)) {
+    error_reporting(0);
+    $connection = imap_open($host, $username, $password, OP_HALFOPEN);
+    error_reporting(7);   
+
+    if ($connection) {
         imap_close($connection);
         return true;
 
diff --git a/lang/en/auth.php b/lang/en/auth.php
new file mode 100644 (file)
index 0000000..3777c41
--- /dev/null
@@ -0,0 +1,58 @@
+<?PHP
+$string['authintroduction'] = "Choose the authentication module you want to use.  The default is 'email' and has the best security.  The method 'none' has no checking whatsoever - be careful using it unless you really know what you are doing.";
+$string['showguestlogin'] = "You can hide or show the guest login button on the login page.";
+$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['chooseauthmethod'] = "Choose an authentication method: ";
+
+$string['auth_emailtitle'] = "Email-based authentication";
+$string['auth_emaildescription'] = "Email confirmation is the default authentication method.  When the user signs up, choosing their own new username and password, a confirmation email is sent to the user's email address.  This email contains a secure link to a page where the user can confirm their account.";
+
+$string['auth_nonetitle'] = "No authentication";
+$string['auth_nonedescription'] = "Users can sign in and create valid accounts immediately, with no authentication against an external server and no confirmation via email.  Be careful using this option - think of the security and administration problems this could cause.";
+
+$string['auth_ldaptitle'] = "Use an LDAP server";
+$string['auth_ldapdescription'] = "This method provides authentication against an external LDAP server.
+                                  If the given username and password are valid, Moodle creates a new user 
+                                  entry in its database. This module can read user attributes from LDAP and prefill 
+                                  wanted fields in Moodle.  For following logins only the username and 
+                                  password are checked.";
+$string['auth_ldap_bind_dn'] = "If you like to use bind-user to search users, specify it here. Someting like 'cn=ldapuser,ou=public,o=org'";
+$string['auth_ldap_bind_pw'] = "Password for bind-user.";
+$string['auth_ldap_contexts'] = "List of contexts where users are located. Separate different contexts with ';'. Something like 'ou=users,o=org; ou=others,o=org'";
+$string['auth_ldap_host_url'] = "Specify LDAP host in URL-form like 'ldap://ldap.myorg.com/' or 'ldaps//ldap.myorg.com/' ";
+$string['auth_ldap_search_sub'] = "Put value &lt;&gt; 0 if  you like to search users from subcontexts.";
+$string['auth_ldap_update_userinfo'] = "Update user information (firstname, lastname, address..) from ldap to Moodle. Look /auth/ldap/attr_mappings.php for mapping information";
+$string['auth_ldap_user_attribute'] = "The attribute used to name/search users. Usually 'cn'.";
+
+$string['auth_imaptitle'] = "Use an IMAP server";
+$string['auth_imapdescription'] = "This method uses an IMAP server to check whether a given username and password is valid.";
+$string['auth_imaphost'] = "The IMAP server address. Use an IP number, not DNS name.";
+$string['auth_imaptype'] = "The IMAP server type.  See the help page (above) for more details.";
+$string['auth_imapport'] = "IMAP server port number. Usually this is 143 or 993.";
+
+$string['auth_dbtitle'] = "Use an external database";
+$string['auth_dbdescription'] = "This method uses an external database table to check whether a given username and password is valid.";
+$string['auth_dbhost']   = "The computer hosting the database server.";
+$string['auth_dbtype']   = "The database type (mysql, postgres7, access, oracle etc)";
+$string['auth_dbname']   = "Name of the database itself";
+$string['auth_dbuser']   = "Username with read access to the database";
+$string['auth_dbpass']   = "Password matching the above username";
+$string['auth_dbtable']  = "Name of the table in the database";
+$string['auth_dbfielduser'] = "Name of the field containing usernames";
+$string['auth_dbfieldpass'] = "Name of the field containing passwords";
+$string['auth_db_instructions'] = "Use the same username and password as your school account";   
+
+$string['auth_nntptitle'] = "Use an NNTP server";
+$string['auth_nntpdescription'] = "This method uses an NNTP server to check whether a given username and password is valid.";
+$string['auth_nntphost']   = "The NNTP server address. Use an IP number, not DNS name.";
+$string['auth_nntpport']   = "119 is the most common port used";
+
+$string['auth_pop3title'] = "Use a POP3 server";
+$string['auth_pop3description'] = "This method uses a POP3 server to check whether a given username and password is valid.";
+$string['auth_pop3host']   = "The POP3 server address. Use an IP number, not DNS name.";
+$string['auth_pop3type']  = "Server type. If your server uses certificate security, choose pop3cert.";
+$string['auth_pop3port']   = "Server port (110 is the most common)";
+
+?>
index d073f20ec35fd30be30bd252b3e1243d2121ab37..5344ef760f6fe7951a95a3f0777ed29739514f7b 100644 (file)
@@ -31,6 +31,7 @@ $string['alreadyconfirmed'] = "Registration has already been confirmed";
 $string['answer'] = "Answer";
 $string['assessment'] = "Assessment";
 $string['assignteachers'] = "Assign teachers";
+$string['authentication'] = "Authentication";
 $string['availablecourses'] = "Available Courses";
 $string['cancel'] = "Cancel";
 $string['categories'] = "Course categories";
@@ -50,7 +51,6 @@ $string['chooseuser'] = "Choose a user";
 $string['city'] = "City/town";
 $string['closewindow'] = "Close this window";
 $string['comparelanguage'] = "Compare and edit current language";
-$string['configauth'] = "Choose the authentication module you want to use.  The default is 'email' and has the best security.  The method 'none' has no checking whatsoever - be careful using it unless you really know what you are doing.";
 $string['configgdversion'] = "Indicate the version of GD that is installed.  The version shown by default is the one that has been auto-detected.  Don't change this unless you really know what you're doing.";
 $string['configerrorlevel'] = "Choose the amount of PHP warnings that you want to be displayed.  Normal is usually the best choice.";
 $string['confightmleditor'] = "Choose whether or not to allow use of the embedded HTML text editor. Even if you choose allow, this editor will only appear when the user is using a compatible browser (IE 5.5 or later).  Users can also choose not to use it.";
@@ -416,6 +416,7 @@ $string['serverlocaltime'] = "Server's local time";
 $string['settings'] = "Settings";
 $string['shortname'] = "Short name";
 $string['shortsitename'] = "Short name for site (eg single word)";
+$string['show'] = "Show";
 $string['showalltopics'] = "Show all topics";
 $string['showallweeks'] = "Show all weeks";
 $string['showlistofcourses'] = "Show list of courses";
index 1b7270800a6109bac9dad69dcfcb57d524af7cc3..b23d80940f12d8d32a5f72a7190628ef9cc7583c 100644 (file)
@@ -1,7 +1,6 @@
 <?PHP // $Id$
     require("../config.php");
 
-
     // Check if the guest user exists.  If not, create one.
     if (! record_exists("user", "username", "guest")) {
         $guest->username    = "guest"; 
     } else {
         $focus = "form.username";
     }
+
+    if ($CFG->auth == "email" or $CFG->auth == "none" or $CFG->auth_instructions) {
+        $show_instructions = true;
+    } else {
+        $show_instructions = false;
+    }
     
+    if (!$site = get_site()) {
+        error("No site found!");
+    }
     $loginsite = get_string("loginsite");
 
-    print_header($loginsite, $loginsite, get_string("login"), $focus); 
+    print_header("$site->fullname: $loginsite", "$loginsite", get_string("login"), $focus); 
     include("index_form.html");
     print_footer();
 
index 94f6c8398f47a04158eb3b42b901995d49428b8a..375850597f693826c4cb4862e57bc771406197d0 100644 (file)
@@ -2,12 +2,14 @@
 \r
 <TABLE WIDTH="90%" BORDER="0" CELLSPACING="10" CELLPADDING="5" ALIGN="CENTER">\r
   <TR>\r
-    <TD WIDTH="50%" bgcolor=<?=$THEME->cellheading2?>>\r
-      <P ALIGN="CENTER"><B><FONT SIZE=3><? print_string("returningtosite") ?></FONT></B></P>\r
-    </TD>\r
-    <TD WIDTH="50%" bgcolor=<?=$THEME->cellheading2?>>\r
-      <P ALIGN="CENTER"><B><FONT SIZE=3><? print_string("firsttime") ?></FONT></B></P>\r
-    </TD>\r
+    <? if ($show_instructions) { ?>\r
+        <TD WIDTH="50%" bgcolor=<?=$THEME->cellheading2?>>\r
+          <P ALIGN="CENTER"><B><FONT SIZE=3><? print_string("returningtosite") ?></FONT></B></P>\r
+        </TD>\r
+        <TD WIDTH="50%" bgcolor=<?=$THEME->cellheading2?>>\r
+          <P ALIGN="CENTER"><B><FONT SIZE=3><? print_string("firsttime") ?></FONT></B></P>\r
+        </TD>\r
+    <? } ?>\r
   </TR>\r
   <TR>\r
     <TD WIDTH="50%" VALIGN="TOP" bgcolor="<?=$THEME->cellheading?>"> <FONT SIZE=2> \r
          </FORM>\r
       <FONT SIZE=2> \r
       <BLOCKQUOTE>\r
-      <HR>\r
-        <P ALIGN=CENTER><? print_string("someallowguest") ?>:</P>\r
-        <CENTER>\r
-        <FORM NAME="form2" ACTION="index.php" METHOD=post>\r
-        <INPUT TYPE="hidden" NAME="username" VALUE="guest">\r
-        <INPUT TYPE="hidden" NAME="password" VALUE="guest">\r
-        <INPUT type="submit" NAME="Submit"   VALUE="<? print_string("loginguest") ?>">\r
-        </FORM>\r
-        </CENTER>\r
+    <? if ($CFG->guestloginbutton) {  ?>\r
+          <HR>\r
+            <P ALIGN=CENTER><? print_string("someallowguest") ?>:</P>\r
+            <CENTER>\r
+            <FORM NAME="form2" ACTION="index.php" METHOD=post>\r
+            <INPUT TYPE="hidden" NAME="username" VALUE="guest">\r
+            <INPUT TYPE="hidden" NAME="password" VALUE="guest">\r
+            <INPUT type="submit" NAME="Submit"   VALUE="<? print_string("loginguest") ?>">\r
+            </FORM>\r
+            </CENTER>\r
+    <? } ?>\r
       <HR>\r
         <P ALIGN=CENTER><? print_string("forgotten") ?></P> \r
         <CENTER>\r
         </CENTER>\r
         </BLOCKQUOTE>\r
       </FONT> </TD>\r
-    <TD WIDTH="50%" VALIGN="TOP" bgcolor="<?=$THEME->cellheading?>">\r
-      <FONT SIZE=2>\r
-      <? switch ($CFG->auth) {\r
-           case "email":             ?>\r
-             <P><? print_string("loginsteps", "", "signup.php") ?></P>\r
-             </FONT>\r
-             <CENTER>\r
-             <FORM NAME="form4" ACTION="signup.php" METHOD=post>\r
-             <INPUT type="submit" NAME="Submit" VALUE="<? print_string("startsignup") ?>">\r
-             </FORM>\r
-             </CENTER>\r
-      <?     break;\r
-           case "none":\r
-             echo "<P>".get_string("loginstepsnone")."</P>";\r
-             break;\r
-           default:\r
-             echo format_text($CFG->auth_instructions);\r
-         }\r
-      ?>\r
+    <? if ($show_instructions) { ?>\r
+        <TD WIDTH="50%" VALIGN="TOP" bgcolor="<?=$THEME->cellheading?>">\r
+          <FONT SIZE=2>\r
+          <? switch ($CFG->auth) {\r
+               case "email":             ?>\r
+                 <P><? print_string("loginsteps", "", "signup.php") ?></P>\r
+                 </FONT>\r
+                 <CENTER>\r
+                 <FORM NAME="form4" ACTION="signup.php" METHOD=post>\r
+                 <INPUT type="submit" NAME="Submit" VALUE="<? print_string("startsignup") ?>">\r
+                 </FORM>\r
+                 </CENTER>\r
+          <?     break;\r
+               case "none":\r
+                 echo "<P>".get_string("loginstepsnone")."</P>";\r
+                 break;\r
+               default:\r
+                 echo "<BLOCKQUOTE>";\r
+                 echo format_text($CFG->auth_instructions);\r
+                 echo "</BLOCKQUOTE>";\r
+             }\r
+          ?>\r
+    \r
+          </TD>\r
+    <?  } ?>\r
 \r
-      </TD>\r
   </TR>\r
 </TABLE>\r