summaryrefslogtreecommitdiff
path: root/lib/plugins/config/settings/extra.class.php
diff options
context:
space:
mode:
authorChristopher Smith <chris@jalakai.co.uk>2013-02-17 16:54:23 +0000
committerChristopher Smith <chris@jalakai.co.uk>2013-02-17 16:54:23 +0000
commitaae735fc981470a44856ec34a838c4910ac68062 (patch)
treef1da8ad916bda65df64f1864bad994688ee2710d /lib/plugins/config/settings/extra.class.php
parent0fc50f81064736071e053d874b60a990fd1af8c2 (diff)
downloadrpg-aae735fc981470a44856ec34a838c4910ac68062.tar.gz
rpg-aae735fc981470a44856ec34a838c4910ac68062.tar.bz2
tidy up authtype setting class (incl. fix issue with auth change/logoff occurring when only one auth plugin is enabled and other settings are updated)
Diffstat (limited to 'lib/plugins/config/settings/extra.class.php')
-rw-r--r--lib/plugins/config/settings/extra.class.php74
1 files changed, 34 insertions, 40 deletions
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;
}
}
}