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
9// must be run within Dokuwiki
10if (!defined('DOKU_INC')) die();
11
12if (!defined('DOKU_LF')) define('DOKU_LF', "\n");
13if (!defined('DOKU_TAB')) define('DOKU_TAB', "\t");
14if (!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/');
15
16require_once DOKU_PLUGIN.'action.php';
17
18class action_plugin_denyactions_act extends DokuWiki_Action_Plugin {
19
20    public function register(Doku_Event_Handler $controller) {
21
22       $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_action_act_preprocess');
23
24    }
25
26    public function handle_action_act_preprocess(Doku_Event $event, $param) {
27      global $ID;
28	    global $lang;
29	    $todeny=$this->getConf('denyactions');
30      $style=$this->getConf('denystyle');
31	    $do = $event->data;
32      echo
33      $this->setupLocale();
34      $perm = auth_quickaclcheck($ID);
35      if($perm < AUTH_EDIT){
36        if (stristr($todeny,$do)) {
37          $event->data='show';
38          if ($style==='msg') {
39            msg($this->lang['actiondenied'],-1);
40          } else if ($style==='login') {
41            global $ACT;
42            $ACT = 'denied';
43            $event->preventDefault();
44            $event->stopPropagation();
45
46          }
47        }
48      }
49    }
50}
51
52// vim:ts=4:sw=4:et:
53