xref: /dokuwiki/inc/Action/ProfileDelete.php (revision 79a2d7845d5e5e48fe3be8f192717de9294aaba5)
133551e4eSAndreas Gohr<?php
233551e4eSAndreas Gohr
333551e4eSAndreas Gohrnamespace dokuwiki\Action;
433551e4eSAndreas Gohr
533551e4eSAndreas Gohruse dokuwiki\Action\Exception\ActionAbort;
6480336a3SAndreas Gohruse dokuwiki\Action\Exception\ActionDisabledException;
7*79a2d784SGerrit 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 */
1633551e4eSAndreas Gohrclass ProfileDelete extends AbstractUserAction {
1733551e4eSAndreas Gohr
1833551e4eSAndreas Gohr    /** @inheritdoc */
19ec701221SAndreas Gohr    public function minimumPermission() {
2033551e4eSAndreas Gohr        return AUTH_NONE;
2133551e4eSAndreas Gohr    }
2233551e4eSAndreas Gohr
2333551e4eSAndreas Gohr    /** @inheritdoc */
24b2c9cd19SAndreas Gohr    public function checkPreconditions() {
25b2c9cd19SAndreas Gohr        parent::checkPreconditions();
26480336a3SAndreas Gohr
27*79a2d784SGerrit Uitslag        /** @var AuthPlugin $auth */
28480336a3SAndreas Gohr        global $auth;
29480336a3SAndreas Gohr        if(!$auth->canDo('delUser')) throw new ActionDisabledException();
30480336a3SAndreas Gohr    }
31480336a3SAndreas Gohr
32480336a3SAndreas Gohr    /** @inheritdoc */
3333551e4eSAndreas Gohr    public function preProcess() {
3433551e4eSAndreas Gohr        global $lang;
3533551e4eSAndreas Gohr        if(auth_deleteprofile()) {
3633551e4eSAndreas Gohr            msg($lang['profdeleted'], 1);
3733551e4eSAndreas Gohr            throw new ActionAbort('show');
3833551e4eSAndreas Gohr        } else {
3933551e4eSAndreas Gohr            throw new ActionAbort('profile');
4033551e4eSAndreas Gohr        }
4133551e4eSAndreas Gohr    }
4233551e4eSAndreas Gohr
4333551e4eSAndreas Gohr}
44