xref: /dokuwiki/inc/Action/Draftdel.php (revision 8c7c53b0321a3cd3116b8d3b2ad27863a38dece7)
1<?php
2
3namespace dokuwiki\Action;
4
5use dokuwiki\Draft;
6use dokuwiki\Action\Exception\ActionAbort;
7
8/**
9 * Class Draftdel
10 *
11 * Delete a draft
12 *
13 * @package dokuwiki\Action
14 */
15class Draftdel extends AbstractAction
16{
17
18    /** @inheritdoc */
19    public function minimumPermission() {
20        return AUTH_EDIT;
21    }
22
23    /**
24     * Delete an existing draft for the current page and user if any
25     *
26     * Redirects to show, afterwards.
27     *
28     * @throws ActionAbort
29     */
30    public function preProcess() {
31        global $INFO, $ID;
32        $draft = new Draft($ID, $INFO['client']);
33        if ($draft->isDraftAvailable() && checkSecurityToken()) {
34            $draft->deleteDraft();
35        }
36
37        throw new ActionAbort('redirect');
38    }
39}
40