xref: /plugin/publish/action/hide.php (revision 2b00c146e15e156e122978d8938a41da1d692f0d)
1<?php
2
3if(!defined('DOKU_INC')) die();
4
5class action_plugin_publish_hide extends DokuWiki_Action_Plugin {
6
7    /**
8     * @var helper_plugin_publish
9     */
10    private $hlp;
11
12    function __construct() {
13        $this->hlp = plugin_load('helper','publish');
14    }
15
16    function register(Doku_Event_Handler &$controller) {
17        $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'hide', array());
18    }
19
20    /**
21     * @param Doku_Event $event
22     * @param array $param
23     */
24    function hide(&$event, $param) {
25        if (!$this->hlp->isHiddenForUser()) {
26            return;
27        }
28
29        global $ACT;
30        if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) {
31            return;
32        }
33
34        $ACT = 'denied';
35
36        $event->preventDefault();
37        $event->stopPropagation();
38
39        print p_locale_xhtml('denied');
40
41    }
42
43}