blob: 3a6df6fe55b573e65c940aef6ab052d7f16b99d0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<?php
namespace dokuwiki\plugin\config\core\Setting;
/**
* Class setting_authtype
*/
class SettingAuthtype extends SettingMultichoice {
/** @inheritdoc */
public function initialize($default = null, $local = null, $protected = null) {
/** @var $plugin_controller \dokuwiki\Extension\PluginController */
global $plugin_controller;
// retrieve auth types provided by plugins
foreach($plugin_controller->getList('auth') as $plugin) {
$this->choices[] = $plugin;
}
parent::initialize($default, $local, $protected);
}
/** @inheritdoc */
public function update($input) {
/** @var $plugin_controller \dokuwiki\Extension\PluginController */
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();
}
$this->local = $input;
return true;
}
}
|