xref: /dokuwiki/inc/Action/ProfileDelete.php (revision 4b230b99ca279d0f160ebd0981007d2de6120995)
1<?php
2
3namespace dokuwiki\Action;
4
5use dokuwiki\Action\Exception\ActionAbort;
6use dokuwiki\Action\Exception\ActionDisabledException;
7use dokuwiki\Extension\AuthPlugin;
8
9/**
10 * Class ProfileDelete
11 *
12 * Delete a user account
13 *
14 * @package dokuwiki\Action
15 */
16class ProfileDelete extends AbstractUserAction
17{
18
19    /** @inheritdoc */
20    public function minimumPermission()
21    {
22        return AUTH_NONE;
23    }
24
25    /** @inheritdoc */
26    public function checkPreconditions()
27    {
28        parent::checkPreconditions();
29
30        /** @var AuthPlugin $auth */
31        global $auth;
32        if (!$auth->canDo('delUser')) throw new ActionDisabledException();
33    }
34
35    /** @inheritdoc */
36    public function preProcess()
37    {
38        global $lang;
39        if (auth_deleteprofile()) {
40            msg($lang['profdeleted'], 1);
41            throw new ActionAbort('show');
42        } else {
43            throw new ActionAbort('profile');
44        }
45    }
46}
47