summaryrefslogtreecommitdiffstats
path: root/app/model/deleteacct.mod.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/model/deleteacct.mod.php')
-rw-r--r--app/model/deleteacct.mod.php34
1 files changed, 34 insertions, 0 deletions
diff --git a/app/model/deleteacct.mod.php b/app/model/deleteacct.mod.php
index ca01a0d..89aca14 100644
--- a/app/model/deleteacct.mod.php
+++ b/app/model/deleteacct.mod.php
@@ -1,6 +1,8 @@
<?php
require_once "model/common.mod.php";
+require_once "class/form.class.php";
+require_once "class/user.class.php";
class DeleteacctModel extends CommonModel
{
@@ -10,6 +12,38 @@ class DeleteacctModel extends CommonModel
function deflt()
{
}
+
+ /*
+ * Delete current user's account
+ */
+ function del($input)
+ {
+ $form = new Form();
+ $form->field_text("password", null, false);
+
+ if (!$form->populate($input))
+ {
+ $this->logFormErrors($form);
+ return;
+ }
+
+ $user = $this->getCurrentUser();
+
+ if (!$user->validatePassword($form->password))
+ {
+ $this->logError("Account not deleted - Password was incorrect");
+ return;
+ }
+
+ if ($user->admin && $user->getNumAdmins() == 1)
+ {
+ $this->logError("Account not deleted - Cannot remove the last admin account");
+ return;
+ }
+
+ $user->delObj();
+ $this->redirectTo($this->ar() . "/");
+ }
}
?>