Completed
Push — actionrefactor ( 6e4bf0 )
by Andreas
04:36
created

Admin::preProcess()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
eloc 8
nc 4
nop 0
dl 0
loc 15
rs 8.8571
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
    function minimumPermission() {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
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 checkPermissions() {
28
        parent::checkPermissions();
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