1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Stephan Dekker <Stephan@SparklingSoftware.com.au> 5 */ 6 7if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 8require_once DOKU_PLUGIN.'action.php'; 9require_once(DOKU_PLUGIN.'git/lib/Git.php'); 10 11class action_plugin_git_alertupstreamchanges extends DokuWiki_Action_Plugin { 12 13 var $helper = null; 14 15 function action_plugin_git_alertupstreamchanges (){ 16 $this->helper =& plugin_load('helper', 'git'); 17 if(!$this->helper) msg('Loading the git helper in the git_alertupstreamchanges class failed.', -1); 18 } 19 20 function register(&$controller) { 21 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handler'); 22 } 23 24 function current_url(){ 25 $pageURL = 'http'; 26 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} 27 $pageURL .= "://"; 28 if ($_SERVER["SERVER_PORT"] != "80") { 29 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 30 } else { 31 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 32 } 33 return $pageURL; 34 } 35 36 function handler(&$event, $param) { 37 global $conf, $ID; 38 $this->getConf(''); 39 40 $gitRemoteStatusUrl = DOKU_URL.'doku.php?id='.$conf['plugin']['git']['origin_status_page']; 41 42 $currentURL = $this->current_url(); 43 if ($gitRemoteStatusUrl === wl($ID,'',true)) return; // Skip remote GIT status page, no notification needed when the user is looking at the details. 44 if (strpos(strtolower($currentURL), strtolower('mediamanager.php')) > 0) return; // Skip media manager page as well 45 46 if ($this->helper->CheckForUpstreamUpdates()) 47 msg('Other improvements have been approved. <a href="'.$gitRemoteStatusUrl.'">click here to merge changes into this workspace.</a>'); 48 } 49 50 51 52 53} 54