5b5e4cfc1089fd07e5d737f1dc6a86830a687234
[moodle.git] / admin / auth.php
1 <?PHP  // $Id$
2        // config.php - allows admin to edit all configuration variables
4     include("../config.php");
6     require_login();
8     if (!$site = get_site()) {
9         redirect("index.php");
10     }
12     if (!isadmin()) {
13         error("Only the admin can use this page");
14     }
17 /// If data submitted, then process and store.
19         if (match_referer() && isset($HTTP_POST_VARS)) {
21         $config = (object)$HTTP_POST_VARS;
23         validate_form($config, $err);
25         if (count($err) == 0) {
26             print_header();
27             foreach ($config as $name => $value) {
28                 if (! set_config($name, $value)) {
29                     notify("Problem saving config $name as $value");
30                 }
31             }
32             redirect("auth.php", get_string("changessaved"), 1);
33             exit;
35         } else {
36             foreach ($err as $key => $value) {
37                 $focus = "form.$key";
38             }
39         }
40         }
42 /// Otherwise fill and print the form.
44     if (!isset($config)) {
45         $config = $CFG;
46     }
48     $modules = get_list_of_plugins("auth");
49     foreach ($modules as $module) {
50         $options[$module] = get_string("auth_$module"."title", "auth");
51     }
52     asort($options);
53         if (isset($_GET['auth'])) {
54             $auth = $_GET['auth'];
55         } else {
56         $auth = $config->auth;
57         } 
59     if (! isset($config->guestloginbutton)) {
60         $config->guestloginbutton = 1;
61     }
63     if (empty($focus)) {
64         $focus = "";
65     }
67     $guestoptions[0] = get_string("hide");
68     $guestoptions[1] = get_string("show");
70     $stradministration        = get_string("administration");
71     $strauthentication        = get_string("authentication");
72     $strauthenticationoptions = get_string("authenticationoptions","auth");
73     $strsettings = get_string("settings");
75     print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
76                   "<A HREF=\"index.php\">$stradministration</A> -> $strauthenticationoptions", "$focus");
78     echo "<CENTER><P><B>";
79     echo "<form TARGET=\"_top\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
80     print_string("chooseauthmethod","auth");
82         choose_from_menu ($options, "auth", $auth, "","top.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
84     echo "</B></P></CENTER>";
85         
86     print_simple_box_start("center", "100%", "$THEME->cellheading");
87     print_heading($options[$auth]);
89     echo "<BLOCKQUOTE><CENTER><P>";
90     print_string("auth_$auth"."description", "auth");
91     echo "</P></CENTER></BLOCKQUOTE>";
93     echo "<HR>";
95     print_heading($strsettings);
97     echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
99     require("$CFG->dirroot/auth/$auth/config.html");
101     if ($auth != "email" and $auth != "none") {
102         echo "<tr valign=\"top\">";
103             echo "<td align=right nowrap><p>";
104         print_string("changepassword", "auth");
105         echo ":</p></td>";
106             echo "<td>";
107         echo "<INPUT TYPE=\"text\" NAME=\"changepassword\" SIZE=40 VALUE=\"$config->changepassword\">";
108         echo "</td>";
109         echo "<td>";
110         print_string("changepasswordhelp","auth");
111         echo "</td></tr>";
113     }
115     echo "<tr valign=\"top\">";
116         echo "<td align=right nowrap><p>";
117     print_string("guestloginbutton", "auth");
118     echo ":</p></td>";
119         echo "<td>";
120     choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
121     echo "</td>";
122     echo "<td>";
123     print_string("showguestlogin","auth");
124     echo "</td></tr></table>";
127     echo "<CENTER><P><INPUT TYPE=\"submit\" VALUE=\"";
128     print_string("savechanges");
129     echo "\"></P></CENTER></FORM>";
131     print_simple_box_end(); 
133     print_footer();
134     exit; 
136 /// Functions /////////////////////////////////////////////////////////////////
138 function validate_form(&$form, &$err) {
140    // if (empty($form->fullname))
141    //     $err["fullname"] = get_string("missingsitename");
143     return;
147 ?>