Completed
Push — master ( b25745...c45ab5 )
by Andreas
05:33
created

Admin::checkPreconditions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace dokuwiki\Action;
4
5
use dokuwiki\Action\Exception\ActionException;
6
7
/**
8
 * Class Admin
9
 *
10
 * Action to show the admin interface or admin plugins
11
 *
12
 * @package dokuwiki\Action
13
 */
14
class Admin extends AbstractUserAction {
15
16
    /** @inheritdoc */
17
    public function minimumPermission() {
18
        return AUTH_READ; // let in check later
19
    }
20
21
    /** @inheritDoc */
22
    public function preProcess() {
23
        global $INPUT;
24
        global $INFO;
25
26
        // retrieve admin plugin name from $_REQUEST['page']
27
        if(($page = $INPUT->str('page', '', true)) != '') {
28
            /** @var $plugin \dokuwiki\Extension\AdminPlugin */
29
            if($plugin = plugin_getRequestAdminPlugin()) { // FIXME this method does also permission checking
30
                if(!$plugin->isAccessibleByCurrentUser()) {
31
                    throw new ActionException('denied');
32
                }
33
                $plugin->handle();
34
            }
35
        }
36
    }
37
38
    /** @inheritDoc */
39
    public function tplContent() {
40
        tpl_admin();
41
    }
42
}
43