1<?php
2
3namespace dokuwiki\Action;
4
5use dokuwiki\Ui\PageDraft;
6use dokuwiki\Action\Exception\ActionException;
7use dokuwiki\Ui;
8
9/**
10 * Class Draft
11 *
12 * Screen to see and recover a draft
13 *
14 * @package dokuwiki\Action
15 * @fixme combine with Recover?
16 */
17class Draft extends AbstractAction
18{
19    /** @inheritdoc */
20    public function minimumPermission()
21    {
22        global $INFO;
23        if ($INFO['exists']) {
24            return AUTH_EDIT;
25        } else {
26            return AUTH_CREATE;
27        }
28    }
29
30    /** @inheritdoc */
31    public function checkPreconditions()
32    {
33        parent::checkPreconditions();
34        global $INFO;
35        if (!isset($INFO['draft']) || !file_exists($INFO['draft'])) throw new ActionException('edit');
36    }
37
38    /** @inheritdoc */
39    public function tplContent()
40    {
41        (new PageDraft())->show();
42    }
43}
44