xref: /dokuwiki/inc/Action/Admin.php (revision 1de6f5c9063eaf6eda4e88702b2e2cdeb59ea652)
1<?php
2
3namespace dokuwiki\Action;
4
5use 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 */
14class 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 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