summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Gohr <andi@splitbrain.org>2013-02-17 12:29:29 -0800
committerAndreas Gohr <andi@splitbrain.org>2013-02-17 12:29:29 -0800
commit344be1a1d9393191529b775e6d3429301e835823 (patch)
tree6554c889811237627b8023e007a1a3be136ea883
parent063de86b1d9417547f0a1f3dc91f7b9dab088bfc (diff)
parent22b77eded0c1fe0f6866972d97895a9e9dc26a1f (diff)
downloadrpg-344be1a1d9393191529b775e6d3429301e835823.tar.gz
rpg-344be1a1d9393191529b775e6d3429301e835823.tar.bz2
Merge pull request #183 from splitbrain/configmgr_and_disabled_plugins
Config Manager & Disabled Plugins.
-rw-r--r--lib/plugins/config/settings/config.class.php11
-rw-r--r--lib/plugins/config/settings/extra.class.php74
2 files changed, 41 insertions, 44 deletions
diff --git a/lib/plugins/config/settings/config.class.php b/lib/plugins/config/settings/config.class.php
index 4a84d6dc8..e5e09d8f8 100644
--- a/lib/plugins/config/settings/config.class.php
+++ b/lib/plugins/config/settings/config.class.php
@@ -20,6 +20,7 @@ if (!class_exists('configuration')) {
var $_metadata = array(); // holds metadata describing the settings
var $setting = array(); // array of setting objects
var $locked = false; // configuration is considered locked if it can't be updated
+ var $show_disabled_plugins = false;
// configuration filenames
var $_default_files = array();
@@ -267,7 +268,7 @@ if (!class_exists('configuration')) {
function get_plugin_list() {
if (is_null($this->_plugin_list)) {
- $list = plugin_list('',true); // all plugins, including disabled ones
+ $list = plugin_list('',$this->show_disabled_plugins);
// remove this plugin from the list
$idx = array_search('config',$list);
@@ -392,10 +393,12 @@ if (!class_exists('setting')) {
}
/**
- * update setting with user provided value $input
- * if value fails error check, save it
+ * update changed setting with user provided value $input
+ * - if changed value fails error check, save it to $this->_input (to allow echoing later)
+ * - if changed value passes error check, set $this->_local to the new value
*
- * @return boolean true if changed, false otherwise (incl. on error)
+ * @param mixed $input the new value
+ * @return boolean true if changed, false otherwise (incl. on error)
*/
function update($input) {
if (is_null($input)) return false;
diff --git a/lib/plugins/config/settings/extra.class.php b/lib/plugins/config/settings/extra.class.php
index 6998e1fbf..e4b97eb01 100644
--- a/lib/plugins/config/settings/extra.class.php
+++ b/lib/plugins/config/settings/extra.class.php
@@ -43,56 +43,50 @@ if (!class_exists('setting_authtype')) {
class setting_authtype extends setting_multichoice {
function initialize($default,$local,$protected) {
- global $plugin_controller;
+ global $plugin_controller;
- // retrive auth types provided by plugins
- foreach ($plugin_controller->getList('auth') as $plugin) {
- $this->_choices[] = $plugin;
- }
+ // retrieve auth types provided by plugins
+ foreach ($plugin_controller->getList('auth') as $plugin) {
+ $this->_choices[] = $plugin;
+ }
- parent::initialize($default,$local,$protected);
+ parent::initialize($default,$local,$protected);
}
function update($input) {
- global $plugin_controller;
-
- // is an update posible?
- $mayUpdate = parent::update($input);
-
- // is it an auth plugin?
- if (in_array($input, $plugin_controller->getList('auth'))) {
- // reject disabled plugins
- if ($plugin_controller->isdisabled($input)) {
- $this->_error = true;
- msg('Auth type ' . $input . ' is disabled.', -1);
- return false;
- }
-
- // load the plugin
- $auth_plugin = $plugin_controller->load('auth', $input);
-
- // @TODO: throw an error in plugin controller instead of returning null
- if (is_null($auth_plugin)) {
- $this->_error = true;
- msg('Cannot load Auth Plugin "' . $input . '"', -1);
- return false;
- }
-
- // verify proper instanciation (is this really a plugin?) @TODO use instanceof? impement interface?
- if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) {
- $this->_error = true;
- msg('Cannot create Auth Plugin "' . $input . '"', -1);
- return false;
- }
- }
+ global $plugin_controller;
+
+ // is an update possible/requested?
+ $local = $this->_local; // save this, parent::update() may change it
+ if (!parent::update($input)) return false; // nothing changed or an error caught by parent
+ $this->_local = $local; // restore original, more error checking to come
+
+ // attempt to load the plugin
+ $auth_plugin = $plugin_controller->load('auth', $input);
+
+ // @TODO: throw an error in plugin controller instead of returning null
+ if (is_null($auth_plugin)) {
+ $this->_error = true;
+ msg('Cannot load Auth Plugin "' . $input . '"', -1);
+ return false;
+ }
+
+ // verify proper instantiation (is this really a plugin?) @TODO use instanceof? implement interface?
+ if (is_object($auth_plugin) && !method_exists($auth_plugin, 'getPluginName')) {
+ $this->_error = true;
+ msg('Cannot create Auth Plugin "' . $input . '"', -1);
+ return false;
+ }
// did we change the auth type? logout
global $conf;
if($conf['authtype'] != $input) {
- msg('Authentication system changed. Please re-login.');
- auth_logoff();
+ msg('Authentication system changed. Please re-login.');
+ auth_logoff();
}
- return true;
+
+ $this->_local = $input;
+ return true;
}
}
}