1<?php 2 3class action_plugin_publish_start extends DokuWiki_Action_Plugin { 4 5 /** 6 * @var helper_plugin_publish 7 */ 8 private $hlp; 9 10 function __construct() { 11 $this->hlp = plugin_load('helper','publish'); 12 } 13 14 function register(Doku_Event_Handler $controller) { 15 $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_start', array()); 16 } 17 18 function handle_start(Doku_Event $event) { 19 global $ACT; 20 global $REV; 21 global $INFO; 22 global $ID; 23 24 if ($ACT !== 'show') { 25 return; 26 } 27 28 if (!empty($REV)) { 29 return; 30 } 31 32 if ($INFO['perm'] != AUTH_READ) { 33 return; 34 } 35 36 global $_GET; 37 if($_GET['force_rev']) { 38 return; 39 } 40 41 if (!$this->hlp->isActive()) { 42 return; 43 } 44 45 if (!$this->hlp->isCurrentRevisionApproved()) { 46 $latestApproved = $this->hlp->getLatestApprovedRevision(); 47 if ($latestApproved) { 48 $REV = $latestApproved; 49 $INFO['rev'] = $latestApproved; 50 } 51 } 52 } 53} 54