Completed
Push — master ( 13ce47...b2c9cd )
by Andreas
10:39 queued 06:48
created

Admin::checkPreconditions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 0
dl 0
loc 8
rs 9.4285
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
        global $INFO;
19
20
        if($INFO['ismanager']) {
21
            return AUTH_READ; // let in check later
22
        } else {
23
            return AUTH_ADMIN;
24
        }
25
    }
26
27
    public function checkPreconditions() {
28
        parent::checkPreconditions();
29
30
        global $INFO;
31
        if(!$INFO['ismanager']) {
32
            throw new ActionException('denied');
33
        }
34
    }
35
36
    public function preProcess() {
37
        global $INPUT;
38
        global $INFO;
39
40
        // retrieve admin plugin name from $_REQUEST['page']
41
        if(($page = $INPUT->str('page', '', true)) != '') {
42
            /** @var $plugin \DokuWiki_Admin_Plugin */
43
            if($plugin = plugin_getRequestAdminPlugin()) { // FIXME this method does also permission checking
44
                if($plugin->forAdminOnly() && !$INFO['isadmin']) {
45
                    throw new ActionException('denied');
46
                }
47
                $plugin->handle();
48
            }
49
        }
50
    }
51
52
    public function tplContent() {
53
        tpl_admin();
54
    }
55
56
}
57