-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.php
50 lines (44 loc) · 1.5 KB
/
action.php
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
<?php
use dokuwiki\Extension\ActionPlugin;
class action_plugin_authserversso extends ActionPlugin {
/*
public function __construct() {
global $active;
//dbglog("authserversso: Action constructor: {$authClass}");
//dbglog('authserversso: Disable login');
$disableactions = explode(',', $conf['disableactions']);
$disableactions = array_map('trim', $disableactions);
if (!in_array('login', $disableactions)) {
$disableactions[] = 'login';
}
$conf['disableactions'] = implode(',', $disableactions);
$conf['autopasswd'] = 0;
}
*/
function register(Doku_Event_Handler $controller){
// dbglog('authserversso: Register hooks');
$controller->register_hook('ACTION_ACT_PREPROCESS', 'AFTER', $this, 'skip_login_action', NULL);
//$controller->register_hook('HTML_REGISTERFORM_OUTPUT', 'BEFORE', $this, 'modify_register_form', NULL);
}
function skip_login_action(&$event, $param) {
global $ID;
if ($event->data == 'login') {
send_redirect($ID, 'show');
}
}
function modify_register_form(&$event, $param) {
$pos = $event->data->findElementByAttribute('name','login');
if (!$pos)
return;
$elem = $event->data->getElementAt($pos);
$elem['value'] = $_SERVER['REMOTE_USER'];
$elem['readonly'] = 'readonly';
$event->data->replaceElement($pos, $elem);
$pwd = auth_pwgen();
foreach (array('pass', 'passchk') as $name) {
$pos = $event->data->findElementByAttribute('name', $name);
$event->data->replaceElement($pos, NULL);
$event->data->addHidden($name, $pwd);
}
}
}