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 the actual namespace is aet in the no_apr_namespace 28 global $ID; 29 $no_apr_namespaces = $this->getConf('no_apr_namespaces'); 30 if (!empty($no_apr_namespaces)) { 31 if ($this->hlp->in_namespace($no_apr_namespaces, $ID)) { 32 return false; 33 } 34 } 35 36 if (!$this->hlp->isHiddenForUser()) { 37 return; 38 } 39 40 global $ACT; 41 if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) { 42 return; 43 } 44 45 $ACT = 'denied'; 46 47 $event->preventDefault(); 48 $event->stopPropagation(); 49 50 print p_locale_xhtml('denied'); 51 } 52 53 function hidePage(Doku_Event &$event, $params) { 54 if (!$this->hlp->isHiddenForUser($event->data['id'])) { 55 return; 56 } 57 58 $event->data['hidden'] = true; 59 } 60 61}