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

Admin   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 43
rs 10
c 0
b 0
f 0
wmc 10
lcom 0
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A minimumPermission() 0 9 2
B preProcess() 0 15 5
A tplContent() 0 3 1
A checkPreconditions() 0 8 2
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