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 if (!$this->hlp->isHiddenForUser()) { 27 return; 28 } 29 30 global $ACT; 31 if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) { 32 return; 33 } 34 35 $ACT = 'denied'; 36 37 $event->preventDefault(); 38 $event->stopPropagation(); 39 40 print p_locale_xhtml('denied'); 41 } 42 43 function hidePage(Doku_Event &$event, $params) { 44 if (!$this->hlp->isHiddenForUser($event->data['id'])) { 45 return; 46 } 47 48 $event->data['hidden'] = true; 49 } 50 51}