diff options
author | Malf Furious <m@lfurio.us> | 2016-05-22 16:59:43 -0400 |
---|---|---|
committer | Malf Furious <m@lfurio.us> | 2016-05-22 16:59:43 -0400 |
commit | abd11313d0a9f2b28d7b709fcbd98befd95db15c (patch) | |
tree | 152db15fb227134a48fa54d4696f0069bf651d62 /app/model/deleteacct.mod.php | |
parent | d431ef2954455ad38454d27f5be866061794b4bf (diff) | |
parent | 2d1e4242a87b54578e24546dabe1525a014da24e (diff) | |
download | scrott-abd11313d0a9f2b28d7b709fcbd98befd95db15c.tar.gz scrott-abd11313d0a9f2b28d7b709fcbd98befd95db15c.zip |
Merge branch 'feature/user-removal' into dev
Diffstat (limited to '')
-rw-r--r-- | app/model/deleteacct.mod.php | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/app/model/deleteacct.mod.php b/app/model/deleteacct.mod.php new file mode 100644 index 0000000..89aca14 --- /dev/null +++ b/app/model/deleteacct.mod.php @@ -0,0 +1,49 @@ +<?php + +require_once "model/common.mod.php"; +require_once "class/form.class.php"; +require_once "class/user.class.php"; + +class DeleteacctModel extends CommonModel +{ + /* + * Default action + */ + 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() . "/"); + } +} + +?> |