1<?php 2 3use dokuwiki\plugin\structpublish\meta\Revision; 4 5class action_plugin_structpublish_show extends DokuWiki_Action_Plugin 6{ 7 /** 8 * @inheritDoc 9 */ 10 public function register(Doku_Event_Handler $controller) 11 { 12 $controller->register_hook('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handleShow'); 13 } 14 15 public function handleShow(Doku_Event $event) 16 { 17 if ($event->data != 'show') return; 18 19 global $ID; 20 global $REV; 21 global $INFO; 22 23 /** @var helper_plugin_structpublish_db $dbHelper */ 24 $dbHelper = plugin_load('helper', 'structpublish_db'); 25 26 if (!$dbHelper->isPublishable()) return; 27 28 $currentRevision = new Revision($dbHelper->getDB(), $ID, $INFO['currentrev']); 29 if ( 30 $currentRevision->getStatus() !== Revision::STATUS_PUBLISHED 31 && !$dbHelper->IS_PUBLISHER($ID) 32 ) { 33 $latestPublishedRev = $currentRevision->getLatestPublished('revision'); 34 if (!$latestPublishedRev) { 35 $event->data = 'denied'; 36 $event->preventDefault(); 37 $event->stopPropagation(); 38 print p_locale_xhtml('denied'); 39 } 40 41 $REV = $latestPublishedRev; 42 $INFO['rev'] = $latestPublishedRev; 43 } 44 } 45} 46