2 // config.php - allows admin to edit all configuration variables
4 include("../config.php");
8 if (!$site = get_site()) {
13 error("Only the admin can use this page");
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) {
27 foreach ($config as $name => $value) {
28 if (! set_config($name, $value)) {
29 notify("Problem saving config $name as $value");
32 redirect("auth.php", get_string("changessaved"), 1);
36 foreach ($err as $key => $value) {
42 /// Otherwise fill and print the form.
44 if (!isset($config)) {
48 $modules = get_list_of_plugins("auth");
49 foreach ($modules as $module) {
50 $options[$module] = get_string("auth_$module"."title", "auth");
53 if (isset($_GET['auth'])) {
54 $auth = $_GET['auth'];
56 $auth = $config->auth;
59 if (! isset($config->guestloginbutton)) {
60 $config->guestloginbutton = 1;
62 if (! isset($config->auth_instructions)) {
63 $config->auth_instructions = "";
65 if (! isset($config->changepassword)) {
66 $config->changepassword = "";
68 $user_fields = array("firstname", "lastname", "email", "phone1", "phone2", "department", "address", "city", "country", "description", "idnumber", "lang");
70 foreach ($user_fields as $user_field) {
71 $user_field = "auth_user_$user_field";
72 if (! isset($config->$user_field)) {
73 $config->$user_field = "";
81 $guestoptions[0] = get_string("hide");
82 $guestoptions[1] = get_string("show");
84 $stradministration = get_string("administration");
85 $strauthentication = get_string("authentication");
86 $strauthenticationoptions = get_string("authenticationoptions","auth");
87 $strsettings = get_string("settings");
89 print_header("$site->shortname: $strauthenticationoptions", "$site->fullname",
90 "<A HREF=\"index.php\">$stradministration</A> -> $strauthenticationoptions", "$focus");
92 echo "<CENTER><P><B>";
93 echo "<form TARGET=\"_top\" NAME=\"authmenu\" method=\"post\" action=\"auth.php\">";
94 print_string("chooseauthmethod","auth");
96 choose_from_menu ($options, "auth", $auth, "","top.location='auth.php?auth='+document.authmenu.auth.options[document.authmenu.auth.selectedIndex].value", "");
98 echo "</B></P></CENTER>";
100 print_simple_box_start("center", "100%", "$THEME->cellheading");
101 print_heading($options[$auth]);
103 echo "<BLOCKQUOTE><CENTER><P>";
104 print_string("auth_$auth"."description", "auth");
105 echo "</P></CENTER></BLOCKQUOTE>";
109 print_heading($strsettings);
111 echo "<table border=\"0\" width=\"100%\" cellpadding=\"4\">";
113 require("$CFG->dirroot/auth/$auth/config.html");
115 if ($auth != "email" and $auth != "none") {
116 echo "<tr valign=\"top\">";
117 echo "<td align=right nowrap><p>";
118 print_string("changepassword", "auth");
121 echo "<INPUT TYPE=\"text\" NAME=\"changepassword\" SIZE=40 VALUE=\"$config->changepassword\">";
124 print_string("changepasswordhelp","auth");
129 echo "<tr valign=\"top\">";
130 echo "<td align=right nowrap><p>";
131 print_string("guestloginbutton", "auth");
134 choose_from_menu($guestoptions, "guestloginbutton", $config->guestloginbutton, "");
137 print_string("showguestlogin","auth");
138 echo "</td></tr></table>";
141 echo "<CENTER><P><INPUT TYPE=\"submit\" VALUE=\"";
142 print_string("savechanges");
143 echo "\"></P></CENTER></FORM>";
145 print_simple_box_end();
150 /// Functions /////////////////////////////////////////////////////////////////
152 function validate_form(&$form, &$err) {
154 // if (empty($form->fullname))
155 // $err["fullname"] = get_string("missingsitename");