3 // setup the call me function for useradmin - matches on url of admin/users
5 // crap, this wont work
6 //if(isset($_SESSION["usertype"])) if($_SESSION["usertype"] == "admin") {
7 $CALL_ME_FUNCTIONS["config"] = "gwvp_ConfigCallMe";
8 $MENU_ITEMS["40config"]["text"] = "Configuration";
9 $MENU_ITEMS["40config"]["link"] = "$BASE_URL/admin/config";
10 $MENU_ITEMS["40config"]["userlevel"] = "admin";
13 // config types are bool, int, or text
14 $CONFIG_VARS["userreg"]["type"] = "bool";
15 $CONFIG_VARS["userreg"]["text"] = "Allow User Registration";
17 $CONFIG_VARS["usercreategroups"]["type"] = "bool";
18 $CONFIG_VARS["usercreategroups"]["text"] = "Allow User Created Groups";
20 $CONFIG_VARS["repodir"]["type"] = "text";
21 $CONFIG_VARS["repodir"]["text"] = "Repository Storage Directory";
24 global $data_directory, $CONFIG_VARS;
26 function gwvp_ConfigCallMe()
28 if(isset($_REQUEST["q"])) {
29 $query = $_REQUEST["q"];
30 if($query == "admin/config") return "gwvp_ConfigPage";
31 if($query == "admin/configupdate") return "gwvp_ConfigUpdatePage";
38 function gwvp_ConfigPage()
40 gwvp_goMainPage("gwvp_ConfigPageBody");
43 function gwvp_ConfigUpdatePage()
45 global $CONFIG_VARS, $BASE_URL;
47 foreach($CONFIG_VARS as $key => $val) {
48 switch($val["type"]) {
50 if(isset($_REQUEST["$key"])) {
58 $pushval = $_REQUEST["$key"];
60 error_log("pushing value, $pushval for $key");
61 gwvp_setConfigVal($key, $pushval);
64 gwvp_SendMessage("info", "Configuration Updated");
65 header("Location: $BASE_URL/admin/config");
69 function gwvp_ConfigPageBody()
71 global $CONFIG_VARS, $BASE_URL;
73 echo "<h1>Global Configuration</h1>";
74 echo "<form method=\"post\" action=\"$BASE_URL/admin/configupdate\">";
76 foreach($CONFIG_VARS as $key=>$var) {
79 $cval = gwvp_getConfigVal($name);
81 switch($var["type"]) {
84 if($cval == 1) $curtypeval = "checked";
88 $curtypeval = "value=\"$cval\"";
92 $curtypeval = "value=\"$cval\"";
96 $curtypeval = "value=\"$cval\"";
99 error_log("go config $name as $ltype, $curtypeval");
100 echo "<tr><td>$text</td><td><input type=\"$ltype\" name=\"$name\" $curtypeval></td></tr>";
104 echo "<input type=\"submit\" name=\"Update\" value=\"Update\">";