1<?php 2 3if(!defined('DOKU_INC')) die(); 4 5class action_plugin_publish_start 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(Doku_Event_Handler $controller) { 17 $controller->register_hook('DOKUWIKI_STARTED', 'BEFORE', $this, 'handle_start', array()); 18 } 19 20 function handle_start(&$event, $param) { 21 global $ACT; 22 global $REV; 23 global $INFO; 24 global $ID; 25 26 if ($ACT !== 'show') { 27 return; 28 } 29 30 if ($REV != '') { 31 return; 32 } 33 34 if ($INFO['perm'] != AUTH_READ) { 35 return; 36 } 37 38 global $_GET; 39 if($_GET['force_rev']) { 40 return; 41 } 42 43 if (!$this->hlp->isActive()) { 44 return; 45 } 46 47 if (!$this->hlp->isCurrentRevisionApproved()) { 48 $latestApproved = $this->hlp->getLatestApprovedRevision(); 49 if ($latestApproved) { 50 $REV = $latestApproved; 51 $INFO['rev'] = $latestApproved; 52 } 53 } 54 } 55 56} 57