xref: /dokuwiki/inc/Action/Draftdel.php (revision 0aabe6f83fad7d8ce23367ad642b6979fc65b4f0)
1f21dad39SAndreas Gohr<?php
2f21dad39SAndreas Gohr
3f21dad39SAndreas Gohrnamespace dokuwiki\Action;
4f21dad39SAndreas Gohr
5f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionAbort;
6f21dad39SAndreas Gohr
7ab583a1bSAndreas Gohr/**
8ab583a1bSAndreas Gohr * Class Draftdel
9ab583a1bSAndreas Gohr *
10ab583a1bSAndreas Gohr * Delete a draft
11ab583a1bSAndreas Gohr *
12ab583a1bSAndreas Gohr * @package dokuwiki\Action
13ab583a1bSAndreas Gohr */
14f1246b76SAndreas Gohrclass Draftdel extends AbstractAction {
15f21dad39SAndreas Gohr
16f21dad39SAndreas Gohr    /** @inheritdoc */
17ec701221SAndreas Gohr    public function minimumPermission() {
18f21dad39SAndreas Gohr        return AUTH_EDIT;
19f21dad39SAndreas Gohr    }
20f21dad39SAndreas Gohr
21231f749dSAndreas Gohr    /**
22*0aabe6f8SMichael Große     * Delete an existing draft for the current page and user if any
23231f749dSAndreas Gohr     *
24*0aabe6f8SMichael Große     * Redirects to show, afterwards.
25231f749dSAndreas Gohr     *
26231f749dSAndreas Gohr     * @throws ActionAbort
27231f749dSAndreas Gohr     */
28f21dad39SAndreas Gohr    public function preProcess() {
29*0aabe6f8SMichael Große        global $INFO, $ID;
30*0aabe6f8SMichael Große        $draft = new \dokuwiki\Draft($ID, $INFO['client']);
31*0aabe6f8SMichael Große        if ($draft->isDraftAvailable()) {
32*0aabe6f8SMichael Große            $draft->deleteDraft();
33*0aabe6f8SMichael Große        }
34231f749dSAndreas Gohr
3558528803SAndreas Gohr        throw new ActionAbort('redirect');
36f21dad39SAndreas Gohr    }
37f21dad39SAndreas Gohr
38f21dad39SAndreas Gohr}
39