1<?php
2/**
3 * DokuWiki Plugin denyactions (Action Component)
4 *
5 * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html
6 * @author  Otto Vainio <otto@valjakko.net>
7 */
8
9if(!defined('DOKU_INC')) die();
10
11class action_plugin_denyactions_rev extends DokuWiki_Action_Plugin {
12
13    function register(Doku_Event_Handler $controller) {
14        $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'handle_start', array());
15    }
16
17    function handle_start(Doku_Event $event, $param) {
18        global $INFO;
19        global $lang;
20        $pif=pageinfo();
21
22        $style=$this->getConf('denystyle');
23        $drev=$this->getConf('denyrev');
24        $perm = auth_quickaclcheck($ID);
25        if($perm < AUTH_EDIT){
26          if ($drev && $pif['rev'] !== 0) {
27            if ($style==='login') {
28              global $ACT;
29              $ACT = 'denied';
30            } else {
31              if ($style==='msg') {
32                $this->setupLocale();
33                msg($this->lang['actiondenied'],-1);
34              }
35              $event->preventDefault();
36              $event->stopPropagation();
37            }
38          }
39        }
40    }
41}
42