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(&$controller) { 17 if ($this->getConf('hide drafts')) { 18 $controller->register_hook('TPL_ACT_RENDER', 'BEFORE', $this, 'hide', array()); 19 } 20 } 21 22 /** 23 * @param Doku_Event $event 24 * @param array $param 25 */ 26 function hide(&$event, $param) { 27 global $ID; 28 global $REV; 29 if ($this->hlp->isRevisionApproved($REV, $ID)) { 30 return; 31 } 32 33 $allowedGroups = array_filter(explode(' ', trim($this->getConf('author groups')))); 34 if (empty($allowedGroups)) { 35 if (auth_quickaclcheck($ID) >= AUTH_EDIT) { 36 return; 37 } 38 } else { 39 global $USERINFO; 40 foreach ($allowedGroups as $allowedGroup) { 41 $allowedGroup = trim($allowedGroup); 42 if (in_array($allowedGroup, $USERINFO['grps'])) { 43 return; 44 } 45 } 46 } 47 48 global $ACT; 49 if (!in_array($ACT, array('show', 'edit', 'source', 'diff'))) { 50 return; 51 } 52 53 $ACT = 'denied'; 54 55 $event->preventDefault(); 56 $event->stopPropagation(); 57 58 print p_locale_xhtml('denied'); 59 60 } 61 62}