xref: /dokuwiki/inc/Action/ProfileDelete.php (revision d868eb89f182718a31113373a6272670bd7f8012)
133551e4eSAndreas Gohr<?php
233551e4eSAndreas Gohr
333551e4eSAndreas Gohrnamespace dokuwiki\Action;
433551e4eSAndreas Gohr
533551e4eSAndreas Gohruse dokuwiki\Action\Exception\ActionAbort;
6480336a3SAndreas Gohruse dokuwiki\Action\Exception\ActionDisabledException;
779a2d784SGerrit Uitslaguse dokuwiki\Extension\AuthPlugin;
833551e4eSAndreas Gohr
933551e4eSAndreas Gohr/**
1033551e4eSAndreas Gohr * Class ProfileDelete
1133551e4eSAndreas Gohr *
1233551e4eSAndreas Gohr * Delete a user account
1333551e4eSAndreas Gohr *
1433551e4eSAndreas Gohr * @package dokuwiki\Action
1533551e4eSAndreas Gohr */
168c7c53b0SAndreas Gohrclass ProfileDelete extends AbstractUserAction
178c7c53b0SAndreas Gohr{
1833551e4eSAndreas Gohr
1933551e4eSAndreas Gohr    /** @inheritdoc */
20*d868eb89SAndreas Gohr    public function minimumPermission()
21*d868eb89SAndreas Gohr    {
2233551e4eSAndreas Gohr        return AUTH_NONE;
2333551e4eSAndreas Gohr    }
2433551e4eSAndreas Gohr
2533551e4eSAndreas Gohr    /** @inheritdoc */
26*d868eb89SAndreas Gohr    public function checkPreconditions()
27*d868eb89SAndreas Gohr    {
28b2c9cd19SAndreas Gohr        parent::checkPreconditions();
29480336a3SAndreas Gohr
3079a2d784SGerrit Uitslag        /** @var AuthPlugin $auth */
31480336a3SAndreas Gohr        global $auth;
32480336a3SAndreas Gohr        if(!$auth->canDo('delUser')) throw new ActionDisabledException();
33480336a3SAndreas Gohr    }
34480336a3SAndreas Gohr
35480336a3SAndreas Gohr    /** @inheritdoc */
36*d868eb89SAndreas Gohr    public function preProcess()
37*d868eb89SAndreas Gohr    {
3833551e4eSAndreas Gohr        global $lang;
3933551e4eSAndreas Gohr        if(auth_deleteprofile()) {
4033551e4eSAndreas Gohr            msg($lang['profdeleted'], 1);
4133551e4eSAndreas Gohr            throw new ActionAbort('show');
4233551e4eSAndreas Gohr        } else {
4333551e4eSAndreas Gohr            throw new ActionAbort('profile');
4433551e4eSAndreas Gohr        }
4533551e4eSAndreas Gohr    }
4633551e4eSAndreas Gohr}
47