xref: /dokuwiki/inc/Action/Admin.php (revision f21dad3906d4ec6b3d86685599409894630abdc1)
1*f21dad39SAndreas Gohr<?php
2*f21dad39SAndreas Gohr/**
3*f21dad39SAndreas Gohr * Created by IntelliJ IDEA.
4*f21dad39SAndreas Gohr * User: andi
5*f21dad39SAndreas Gohr * Date: 2/11/17
6*f21dad39SAndreas Gohr * Time: 11:33 AM
7*f21dad39SAndreas Gohr */
8*f21dad39SAndreas Gohr
9*f21dad39SAndreas Gohrnamespace dokuwiki\Action;
10*f21dad39SAndreas Gohr
11*f21dad39SAndreas Gohruse dokuwiki\Action\Exception\ActionException;
12*f21dad39SAndreas Gohr
13*f21dad39SAndreas Gohrclass Admin extends AbstractUserAction {
14*f21dad39SAndreas Gohr
15*f21dad39SAndreas Gohr    /** @inheritdoc */
16*f21dad39SAndreas Gohr    function minimumPermission() {
17*f21dad39SAndreas Gohr        global $INFO;
18*f21dad39SAndreas Gohr
19*f21dad39SAndreas Gohr        if($INFO['ismanager']) {
20*f21dad39SAndreas Gohr            return AUTH_READ; // let in check later
21*f21dad39SAndreas Gohr        } else {
22*f21dad39SAndreas Gohr            return AUTH_ADMIN;
23*f21dad39SAndreas Gohr        }
24*f21dad39SAndreas Gohr    }
25*f21dad39SAndreas Gohr
26*f21dad39SAndreas Gohr    public function checkPermissions() {
27*f21dad39SAndreas Gohr        parent::checkPermissions();
28*f21dad39SAndreas Gohr
29*f21dad39SAndreas Gohr        global $INFO;
30*f21dad39SAndreas Gohr        if(!$INFO['ismanager']) {
31*f21dad39SAndreas Gohr            throw new ActionException('denied');
32*f21dad39SAndreas Gohr        }
33*f21dad39SAndreas Gohr    }
34*f21dad39SAndreas Gohr
35*f21dad39SAndreas Gohr    public function preProcess() {
36*f21dad39SAndreas Gohr        global $INPUT;
37*f21dad39SAndreas Gohr        global $INFO;
38*f21dad39SAndreas Gohr
39*f21dad39SAndreas Gohr        // retrieve admin plugin name from $_REQUEST['page']
40*f21dad39SAndreas Gohr        if (($page = $INPUT->str('page', '', true)) != '') {
41*f21dad39SAndreas Gohr            /** @var $plugin \DokuWiki_Admin_Plugin */
42*f21dad39SAndreas Gohr            if ($plugin = plugin_getRequestAdminPlugin()){ // FIXME this method does also permission checking
43*f21dad39SAndreas Gohr                if($plugin->forAdminOnly() && !$INFO['isadmin'] ) {
44*f21dad39SAndreas Gohr                    throw new ActionException('denied');
45*f21dad39SAndreas Gohr                }
46*f21dad39SAndreas Gohr                $plugin->handle();
47*f21dad39SAndreas Gohr            }
48*f21dad39SAndreas Gohr        }
49*f21dad39SAndreas Gohr    }
50*f21dad39SAndreas Gohr
51*f21dad39SAndreas Gohr    public function tplContent() {
52*f21dad39SAndreas Gohr        tpl_admin();
53*f21dad39SAndreas Gohr    }
54*f21dad39SAndreas Gohr
55*f21dad39SAndreas Gohr}
56