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 $sqlite = $this->permissionsHelper->getDb(); 29 $dbHelper = plugin_load('helper', 'structpublish_db'); 30 31 $currentRevision = new Revision($sqlite, $ID, $INFO['currentrev']); 32 if ( 33 $currentRevision->getStatus() !== Revision::STATUS_PUBLISHED 34 && !$dbHelper->IS_PUBLISHER($ID) 35 ) { 36 /** @var Revision $latestPublished */ 37 $latestPublished = $currentRevision->getLatestPublishedRev(); 38 if (!$latestPublished) { 39 $event->data = 'denied'; 40 41 $event->preventDefault(); 42 $event->stopPropagation(); 43 44 print p_locale_xhtml('denied'); 45 } 46 47 $REV = $latestPublished; 48 $INFO['rev'] = $latestPublished; 49 } 50 } 51} 52