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 11 12class action_plugin_git_alertcommited extends DokuWiki_Action_Plugin { 13 14 var $helper = null; 15 16 function action_plugin_git_alertcommited (){ 17 $this->helper =& plugin_load('helper', 'git'); 18 if(!$this->helper) msg('Loading the git helper in the git_alertupstreamchanges class failed.', -1); 19 } 20 21 function register(&$controller) { 22 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, 'handler'); 23 } 24 25 function current_url(){ 26 27 $pageURL = 'http'; 28 if ($_SERVER["HTTPS"] == "on") {$pageURL .= "s";} 29 $pageURL .= "://"; 30 if ($_SERVER["SERVER_PORT"] != "80") { 31 $pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"]; 32 } else { 33 $pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; 34 } 35 return $pageURL; 36 } 37 38 function handler(&$event, $param) { 39 global $conf, $INFO; 40 $this->getConf(''); 41 42 $git_exe_path = $conf['plugin']['git']['git_exe_path']; 43 $gitLocalStatusUrl = wl($conf['plugin']['git']['local_status_page'],'',true); 44 $datapath = $conf['savedir']; 45 46 $currentURL = $this->current_url(); 47 if ($gitLocalStatusUrl === $currentURL) return; // Skip local GIT status page, no notification needed when the user is looking at the details. 48 if (strpos(strtolower($currentURL), strtolower('mediamanager.php')) > 0) return; // Skip media manager page as well 49 50 $changesAwaiting = $this->helper->readLocalChangesAwaitingFromCache(); 51 52 if ($changesAwaiting) { 53 msg('Changes waiting to be approved. <a href="'.$gitLocalStatusUrl.'">click here to view changes.</a>'); 54 } 55 } 56 57 58} 59