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 $controller->register_hook('PAGEUTILS_ID_HIDEPAGE', 'BEFORE', $this, 'hidePage', array()); 19 } 20 21 /** 22 * @param Doku_Event $event 23 * @param array $param 24 */ 25 function hide(Doku_Event &$event, $param) { 26 27 if (!$this->hlp->isActive()) { 28 return; 29 } 30 31 if (!$this->hlp->isHiddenForUser()) { 32 return; 33 } 34 35 global $ACT; 36 if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) { 37 return; 38 } 39 40 $ACT = 'denied'; 41 42 $event->preventDefault(); 43 $event->stopPropagation(); 44 45 print p_locale_xhtml('denied'); 46 } 47 48 function hidePage(Doku_Event &$event, $params) { 49 if (!$this->hlp->isHiddenForUser($event->data['id'])) { 50 return; 51 } 52 53 $event->data['hidden'] = true; 54 } 55 56} 57