xref: /dokuwiki/inc/Action/Admin.php (revision d868eb89f182718a31113373a6272670bd7f8012)
1f21dad39SAndreas Gohr<?php
2f21dad39SAndreas Gohr
3f21dad39SAndreas Gohrnamespace dokuwiki\Action;
4f21dad39SAndreas Gohr
5f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionException;
679a2d784SGerrit Uitslaguse dokuwiki\Extension\AdminPlugin;
7f21dad39SAndreas Gohr
8ab583a1bSAndreas Gohr/**
9ab583a1bSAndreas Gohr * Class Admin
10ab583a1bSAndreas Gohr *
11ab583a1bSAndreas Gohr * Action to show the admin interface or admin plugins
12ab583a1bSAndreas Gohr *
13ab583a1bSAndreas Gohr * @package dokuwiki\Action
14ab583a1bSAndreas Gohr */
158c7c53b0SAndreas Gohrclass Admin extends AbstractUserAction
168c7c53b0SAndreas Gohr{
17f21dad39SAndreas Gohr
18f21dad39SAndreas Gohr    /** @inheritdoc */
19*d868eb89SAndreas Gohr    public function minimumPermission()
20*d868eb89SAndreas Gohr    {
21f21dad39SAndreas Gohr        return AUTH_READ; // let in check later
22f21dad39SAndreas Gohr    }
23f21dad39SAndreas Gohr
24c45ab550SAndreas Gohr    /** @inheritDoc */
25*d868eb89SAndreas Gohr    public function preProcess()
26*d868eb89SAndreas Gohr    {
27f21dad39SAndreas Gohr        global $INPUT;
28f21dad39SAndreas Gohr
29f21dad39SAndreas Gohr        // retrieve admin plugin name from $_REQUEST['page']
3079a2d784SGerrit Uitslag        if($INPUT->str('page', '', true) != '') {
3179a2d784SGerrit Uitslag            /** @var AdminPlugin $plugin */
32f21dad39SAndreas Gohr            if($plugin = plugin_getRequestAdminPlugin()) { // FIXME this method does also permission checking
3364cdf779SAndreas Gohr                if(!$plugin->isAccessibleByCurrentUser()) {
34f21dad39SAndreas Gohr                    throw new ActionException('denied');
35f21dad39SAndreas Gohr                }
36f21dad39SAndreas Gohr                $plugin->handle();
37f21dad39SAndreas Gohr            }
38f21dad39SAndreas Gohr        }
39f21dad39SAndreas Gohr    }
40f21dad39SAndreas Gohr
41c45ab550SAndreas Gohr    /** @inheritDoc */
42*d868eb89SAndreas Gohr    public function tplContent()
43*d868eb89SAndreas Gohr    {
44f21dad39SAndreas Gohr        tpl_admin();
45f21dad39SAndreas Gohr    }
46f21dad39SAndreas Gohr}
47