if($qspl[1] == "confremoveuser") {
return "gwvpmini_ConfRemoveUser";
}
+ if($qspl[1] == "switchenable") {
+ return "gwvpmini_SwitchEnableUser";
+ }
} else {\r
error_log("i got here, where next?");\r
return "gwvpmini_AdminMainPage";\r
$st_t = $val["status"];
$st_l = $val["level"];
+ $astat = "0";
+ $cstat = "WTF";
$level = "WTF";
if($st_l == 0) $level = "User";
if($st_l == 1) $level = "Admin";
$status = "";
if($st_t[0] == "1") {
$status = ", disabled";
- }
- if($st_t[0] == "2") {
+ $astat = 0;
+ $cstat = "Enable";
+ } else if ($st_t[0] == "0") {
+ $astat = 1;
+ $cstat = "Disable";
+ } else if($st_t[0] == "2") {
$vl = explode(":", $st_t);
error_log("VL: ".print_r($vl, true));
$status = " Awaiting Confirmation (<a href=\"$BASE_URL/register/confirmreg/".$vl[1]."\">Confirm</a>)";
$st = "$level$status";
$unlval = "<a href=\"$BASE_URL/user/$un\">$un</a>";
- echo "<tr><td>$unlval</td><td>$em</td><td>$fn</td><td>$ds</td><td>$st</td><td><a href=\"$BASE_URL/admin/removeuser/$id\">Remove</a> <a href=\"$BASE_URL/admin/disableuser&id=$id\">Disable</a></td></tr>";
+ echo "<tr><td>$unlval</td><td>$em</td><td>$fn</td><td>$ds</td><td>$st</td><td><a href=\"$BASE_URL/admin/removeuser/$id\">Remove</a> ";
+ if ($st_t[0] == "0"||$st_t[0] == "1") echo "<a href=\"$BASE_URL/admin/switchenable/$astat/$id\">$cstat</a></td></tr>";
+ else echo "</td></tr>";
}
$rn = $val["name"];
$ds = $val["desc"];
$ow = $val["owner"];
- echo "<tr><td><a href=\"$BASE_URL/view/$rn\">$rn</a></td><td>$ds</td><td>$ow</td><td><a href=\"$BASE_URL/admin/removeuser&id=$id\">Remove</a> <a href=\"$BASE_URL/admin/disableuser&id=$id\">Disable</a></td></tr>";
+ echo "<tr><td><a href=\"$BASE_URL/view/$rn\">$rn</a></td><td>$ds</td><td>$ow</td><td><a href=\"$BASE_URL/admin/removeuser&id=$id\">Remove</a> <a href=\"$BASE_URL/admin/switchenable/$id\">Disable</a></td></tr>";
}
echo "</table>";
}\r
}\r
header("Location: $BASE_URL/admin");\r
-}\r
+}
+function gwvpmini_SwitchEnableUser()\r
+{
+ global $BASE_URL;\r
+ \r
+ $uid = -1;
+ $newst = -1;\r
+ if(isset($_REQUEST["q"])) {\r
+ $query = $_REQUEST["q"];\r
+ $qspl = explode("/", $query);\r
+ if(isset($qspl[2])) {\r
+ $newst = $qspl[2];\r
+ }
+ if(isset($qspl[3])) {
+ $uid = $qspl[3];
+ }\r
+ }
+
+ if($newst == 1) $stat = "disabled";
+ else $stat = "enabled";\r
+ \r
+ if($uid > 0 && ($newst == 1 || $newst == 0)) {\r
+ $details = gwvpmini_getUser(null, null, $uid);\r
+ $uname = $details["username"];\r
+ if($newst == 1) gwvpmini_DisableUser($uid);
+ if($newst == 0) gwvpmini_EnableUser($uid);\r
+ gwvpmini_SendMessage("info", "User $uname ($uid) has been $stat");\r
+ } else {\r
+ gwvpmini_SendMessage("info", "Problem disabling user with uid $uid");\r
+ }\r
+ \r
+ header("Location: $BASE_URL/admin");\r
+
+}
?>
\ No newline at end of file
} else if($email != null) {\r
$res = $conn->query("select * from users where user_email='$email'");\r
} else if($id != null) {\r
- $res = $conn->query("select * from users where users_id='$id'");\r
+ $res = $conn->query("select * from users where user_id='$id'");\r
} else return false;\r
\r
$returns = false;\r
$sql = "delete from users where user_id='$uid'";
return $conn->query($sql);
+}
+
+function gwvpmini_DisableUser($uid)
+{
+ $conn = gwvpmini_ConnectDB();\r
+ \r
+ if($uid < 0) return;\r
+ \r
+ $sql = "update users set user_status=1 where user_id='$uid'";\r
+ \r
+ return $conn->query($sql);
}\r
+function gwvpmini_EnableUser($uid)\r
+{\r
+ $conn = gwvpmini_ConnectDB();\r
+\r
+ if($uid < 0) return;\r
+\r
+ $sql = "update users set user_status=0 where user_id='$uid'";\r
+\r
+ return $conn->query($sql);\r
+}\r
+\r
+
function gwvpmini_ConnectDB()\r
{\r
global $WEB_ROOT_FS, $BASE_URL, $data_directory, $db_type, $db_name, $DB_CONNECTION;\r