From a64eec16d2d0bb6f36960279324ff4c67887bfbb Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Tue, 27 Jan 2009 19:25:21 +0100 Subject: reverted plugin disabling method back to old behaviour Ignore-this: b5fadadeee9de8e52c41c056cf62be6d With this patch plugins are now disabled by placing a disabled file in the plugin directory again. Even though renaming plugin directories is the method with the fewest disk accesses it makes a lot of trouble with code revision control systems and, more important, Linux package management systems. Future versions of DokuWiki may use a central config file instead. This patch also fixes the problem with the plugin manager not checking the return values of the pugin_(dis|en)able functions correctly. darcs-hash:20090127182521-7ad00-62018a546d49d57582d93298c8228fd71601a5e8.gz --- lib/plugins/upgradeplugindirectory/action.php | 110 -------------------------- 1 file changed, 110 deletions(-) delete mode 100644 lib/plugins/upgradeplugindirectory/action.php (limited to 'lib/plugins/upgradeplugindirectory') diff --git a/lib/plugins/upgradeplugindirectory/action.php b/lib/plugins/upgradeplugindirectory/action.php deleted file mode 100644 index c541db207..000000000 --- a/lib/plugins/upgradeplugindirectory/action.php +++ /dev/null @@ -1,110 +0,0 @@ - - */ - -if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../../').'/'); -if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); -require_once(DOKU_PLUGIN.'action.php'); - -/** - * All DokuWiki plugins to extend the parser/rendering mechanism - * need to inherit from this class - */ -class action_plugin_upgradeplugindirectory extends DokuWiki_Action_Plugin { - - /** - * return some info - */ - function getInfo(){ - return array( - 'author' => 'Christopher Smith', - 'email' => 'chris@jalakai.co.uk', - 'date' => '2009-01-18', - 'name' => 'Upgrade Plugin Directory', - 'desc' => 'Silently updates plugin disabled indicator to new more efficient format', - 'url' => 'http://wiki.splitbrain.org/plugin:upgradeplugindirectory', - ); - } - - /* - * plugin should use this method to register its handlers with the dokuwiki's event controller - */ - function register(&$controller) { - $controller->register_hook('DOKUWIKI_STARTED','BEFORE', $this, 'handle_upgrade','before'); - } - - function handle_upgrade(&$event, $param) { - global $plugin_controller; - $attempts = 0; - $success = 0; - $updated = 0; - $failures = array(); - $badclean = array(); - - if (empty($plugin_controller)) return; - - if(!is_writable(DOKU_INC.'lib/plugins') && !auth_isAdmin()) { - return; - } - - $plugins = $plugin_controller->getList('',true); // get all plugins - foreach ($plugins as $plugin) { - if ($this->plugin_isdisabled_oldstyle($plugin)) { - $attempts++; - if (@$plugin_controller->disable($plugin)) { - $updated++; - if ($this->plugin_clean($plugin)) { - $success++; - } else { - $badclean[] = $plugin; - } - } else { - $failures[] = $plugin; - } - } - } - - // note: only send messages when the user is an admin - if ($attempts && auth_isAdmin()) { - $level = $failures ? -1 : ($badclean ? 2 : 1); - msg("Plugin Directory Upgrade, $updated/$attempts plugins updated, $success/$attempts cleaned.",$level); - if ($badclean) msg("- the following disabled plugins were updated, but their directories couldn't be cleaned: ".join(',',$badclean),$level); - if ($failures) { - msg("- the following disabled plugins couldn't be updated, please update by hand: ".join(',',$failures),$level); - } - $morelink = true; - } - - // no failures, our job is done, disable ourself - if (!$failures) { - if ($plugin_controller->disable($this->getPluginName())) { - // redirect to let dokuwiki start cleanly with plugins disabled. - act_redirect($ID,'upgradeplugindirectory'); - } else { - if (auth_isAdmin()) { - if (!$attempts) msg('Plugin Directory Upgrade: Your plugin directory is up-to-date.',1); - msg('Plugin Directory Upgrade: Could not disable the upgrade plugin, please disable or delete it manually.',-1); - $morelink = true; - $level = -1; - } - } - } - if ($morelink) msg('For more information see http://www.dokuwiki.org/update',$level); - } - - /* old style plugin isdisabled function */ - function plugin_isdisabled_oldstyle($name) { - return @file_exists(DOKU_PLUGIN.$name.'/disabled'); - } - - function plugin_clean($name) { - return @unlink(DOKU_PLUGIN.$name.'.disabled/disabled'); - } -} - -//Setup VIM: ex: et ts=4 enc=utf-8 : -- cgit v1.2.3