1*1413d607SAndreas Gohr<?php 2*1413d607SAndreas Gohr/** 3*1413d607SAndreas Gohr * DokuWiki Plugin farmer (Action Component) 4*1413d607SAndreas Gohr * 5*1413d607SAndreas Gohr * @license GPL 2 http://www.gnu.org/licenses/gpl-2.0.html 6*1413d607SAndreas Gohr * @author Michael Große <grosse@cosmocode.de> 7*1413d607SAndreas Gohr * @author Andreas Gohr <gohr@cosmocode.de> 8*1413d607SAndreas Gohr */ 9*1413d607SAndreas Gohr 10*1413d607SAndreas Gohrif(!defined('DOKU_INC')) die(); 11*1413d607SAndreas Gohr 12*1413d607SAndreas Gohr/** 13*1413d607SAndreas Gohr * Disable Plugins on install 14*1413d607SAndreas Gohr */ 15*1413d607SAndreas Gohrclass action_plugin_farmer_disable extends DokuWiki_Action_Plugin { 16*1413d607SAndreas Gohr 17*1413d607SAndreas Gohr /** 18*1413d607SAndreas Gohr * plugin should use this method to register its handlers with the DokuWiki's event controller 19*1413d607SAndreas Gohr * 20*1413d607SAndreas Gohr * @param Doku_Event_Handler $controller DokuWiki's event controller object. Also available as global $EVENT_HANDLER 21*1413d607SAndreas Gohr * 22*1413d607SAndreas Gohr */ 23*1413d607SAndreas Gohr public function register(Doku_Event_Handler $controller) { 24*1413d607SAndreas Gohr /** @var helper_plugin_farmer $farmer */ 25*1413d607SAndreas Gohr $farmer = plugin_load('helper', 'farmer'); 26*1413d607SAndreas Gohr if($farmer->getAnimal()) return; 27*1413d607SAndreas Gohr 28*1413d607SAndreas Gohr if($this->getConf('disable_new_plugins')) { 29*1413d607SAndreas Gohr $controller->register_hook('PLUGIN_EXTENSION_CHANGE', 'AFTER', $this, 'handle_install'); 30*1413d607SAndreas Gohr } 31*1413d607SAndreas Gohr } 32*1413d607SAndreas Gohr 33*1413d607SAndreas Gohr /** 34*1413d607SAndreas Gohr * handle install of new plugin 35*1413d607SAndreas Gohr * 36*1413d607SAndreas Gohr * @param Doku_Event $event 37*1413d607SAndreas Gohr * @param $param 38*1413d607SAndreas Gohr */ 39*1413d607SAndreas Gohr public function handle_install(Doku_Event $event, $param) { 40*1413d607SAndreas Gohr if($event->data['action'] != 'install') return; 41*1413d607SAndreas Gohr 42*1413d607SAndreas Gohr /* @var Doku_Plugin_Controller $plugin_controller */ 43*1413d607SAndreas Gohr global $plugin_controller; 44*1413d607SAndreas Gohr $plugin_controller = new Doku_Plugin_Controller(); // we need to refresh the status 45*1413d607SAndreas Gohr 46*1413d607SAndreas Gohr /** @var helper_plugin_extension_extension $ext */ 47*1413d607SAndreas Gohr $ext = $event->data['extension']; 48*1413d607SAndreas Gohr $disabled = $ext->disable(); 49*1413d607SAndreas Gohr if($disabled === true) { 50*1413d607SAndreas Gohr msg($this->getLang('disable_new_plugins')); 51*1413d607SAndreas Gohr } else { 52*1413d607SAndreas Gohr msg(hsc($disabled), -1); 53*1413d607SAndreas Gohr } 54*1413d607SAndreas Gohr } 55*1413d607SAndreas Gohr} 56*1413d607SAndreas Gohr 57