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 if (!in_array($event->data, array('show', 'edit', 'source', 'diff'))) { 36 return; 37 } 38 39 $event->data = 'denied'; 40 41 $event->preventDefault(); 42 $event->stopPropagation(); 43 44 print p_locale_xhtml('denied'); 45 } 46 47 function hidePage(Doku_Event &$event, $params) { 48 if (!$this->hlp->isHiddenForUser($event->data['id'])) { 49 return; 50 } 51 52 $event->data['hidden'] = true; 53 } 54 55} 56