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