diff options
author | chris <chris@jalakai.co.uk> | 2006-03-11 20:26:55 +0100 |
---|---|---|
committer | chris <chris@jalakai.co.uk> | 2006-03-11 20:26:55 +0100 |
commit | 087b3a7fd4d81528ea23786bb2aaa707b3b4de17 (patch) | |
tree | e34c5d97f1fca20298af3d56b6b3d53601ab20ea /inc | |
parent | 3e55d035ce3b611d07546b63ea8bf6315a43e617 (diff) | |
download | rpg-087b3a7fd4d81528ea23786bb2aaa707b3b4de17.tar.gz rpg-087b3a7fd4d81528ea23786bb2aaa707b3b4de17.tar.bz2 |
plugin manager upate: protect default plugins, add enable/disable functionality
darcs-hash:20060311192655-9b6ab-c54d280d35b121730e2f8d50b15fe647d986574c.gz
Diffstat (limited to 'inc')
-rw-r--r-- | inc/pluginutils.php | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/inc/pluginutils.php b/inc/pluginutils.php index 1a60d60be..d9cc848fe 100644 --- a/inc/pluginutils.php +++ b/inc/pluginutils.php @@ -5,21 +5,33 @@ * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) * @author Andreas Gohr <andi@splitbrain.org> */ - - + +// plugin related constants +$plugin_types = array('admin','syntax'); + /** * Returns a list of available plugins of given type * - * Returns all plugins if no type given + * @param $type string, plugin_type name; + * the type of plugin to return, + * use empty string for all types + * @param $all bool; + * false to only return enabled plugins, + * true to return both enabled and disabled plugins + * + * @return array of plugin names * * @author Andreas Gohr <andi@splitbrain.org> */ -function plugin_list($type=''){ +function plugin_list($type='',$all=false){ $plugins = array(); if ($dh = opendir(DOKU_PLUGIN)) { while (false !== ($plugin = readdir($dh))) { if ($plugin == '.' || $plugin == '..' || $plugin == 'tmp') continue; if (is_file(DOKU_PLUGIN.$plugin)) continue; + + // if required, skip disabled plugins + if (!$all && plugin_isdisabled($plugin)) continue; if ($type=='' || @file_exists(DOKU_PLUGIN."$plugin/$type.php")){ $plugins[] = $plugin; @@ -76,3 +88,7 @@ function &plugin_load($type,$name){ $DOKU_PLUGINS[$type][$name] = new $class; return $DOKU_PLUGINS[$type][$name]; } + +function plugin_isdisabled($name) { return @file_exists(DOKU_PLUGIN.$name.'/disabled'); } +function plugin_enable($name) { return @unlink(DOKU_PLUGIN.$name.'/disabled'); } +function plugin_disable($name) { return @touch(DOKU_PLUGIN.$name.'/disabled'); } |