summaryrefslogtreecommitdiffstats
path: root/app/model/common.mod.php
diff options
context:
space:
mode:
authorMalf Furious <m@lfurio.us>2016-05-22 16:34:39 -0400
committerMalf Furious <m@lfurio.us>2016-05-22 16:34:39 -0400
commit2d1e4242a87b54578e24546dabe1525a014da24e (patch)
tree152db15fb227134a48fa54d4696f0069bf651d62 /app/model/common.mod.php
parent04cf93366774e7c1a9070013af866380c5f5ad95 (diff)
downloadscrott-2d1e4242a87b54578e24546dabe1525a014da24e.tar.gz
scrott-2d1e4242a87b54578e24546dabe1525a014da24e.zip
Add form submission handler for user removal
Added handler for the button added in the previous commit.
Diffstat (limited to 'app/model/common.mod.php')
-rw-r--r--app/model/common.mod.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/app/model/common.mod.php b/app/model/common.mod.php
index 03ed54f..5e6373c 100644
--- a/app/model/common.mod.php
+++ b/app/model/common.mod.php
@@ -58,6 +58,7 @@ class CommonModel extends MasterModel
case "common-setting-admin": $this->saveSettingAdmin($input); break;
case "common-setting-allusers-adduser": $this->saveSettingAllusersAdduser($input); break;
case "common-setting-allusers-edituser": $this->saveSettingAllusersEdituser($input, $attachment); break;
+ case "common-setting-allusers-deluser": $this->saveSettingAllusersDeluser($input); break;
}
}
@@ -283,6 +284,51 @@ class CommonModel extends MasterModel
else
$this->logFormErrors($form);
}
+
+ /*
+ * Allow admin to remove user accounts
+ */
+ function saveSettingAllusersDeluser($input)
+ {
+ $form = new Form();
+ $form->field_text("guid");
+
+ if (!$form->populate($input))
+ {
+ $this->logFormErrors($form);
+ return;
+ }
+
+ $user = $this->getCurrentUser();
+
+ if (!$user || $user->admin == 0)
+ {
+ $this->logError("Admin permissions required");
+ return;
+ }
+
+ $user = new User($form->guid);
+
+ if ($user->type != "user")
+ {
+ $this->logError("Invalid user GUID");
+ return;
+ }
+
+ if ($user->admin && $user->getNumAdmins() == 1)
+ {
+ $this->logError("Account not deleted - Cannot remove the last admin account");
+ return;
+ }
+
+ $user->delObj();
+
+ if (!$this->getCurrentUser())
+ {
+ /* did user delete their own account? */
+ $this->redirectTo($this->ar() . "/");
+ }
+ }
}
?>