1<?php 2use dokuwiki\Extension\ActionPlugin; 3 4class action_plugin_authserversso extends ActionPlugin { 5 /* 6 public function __construct() { 7 global $active; 8 9 //dbglog("authserversso: Action constructor: {$authClass}"); 10 //dbglog('authserversso: Disable login'); 11 $disableactions = explode(',', $conf['disableactions']); 12 $disableactions = array_map('trim', $disableactions); 13 if (!in_array('login', $disableactions)) { 14 $disableactions[] = 'login'; 15 } 16 $conf['disableactions'] = implode(',', $disableactions); 17 $conf['autopasswd'] = 0; 18 } 19 */ 20 function register(Doku_Event_Handler $controller){ 21 // dbglog('authserversso: Register hooks'); 22 $controller->register_hook('ACTION_ACT_PREPROCESS', 'AFTER', $this, 'skip_login_action', NULL); 23 //$controller->register_hook('HTML_REGISTERFORM_OUTPUT', 'BEFORE', $this, 'modify_register_form', NULL); 24 } 25 26 function skip_login_action(&$event, $param) { 27 global $ID; 28 if ($event->data == 'login') { 29 send_redirect($ID, 'show'); 30 } 31 } 32 33 function modify_register_form(&$event, $param) { 34 $pos = $event->data->findElementByAttribute('name','login'); 35 if (!$pos) 36 return; 37 38 $elem = $event->data->getElementAt($pos); 39 $elem['value'] = $_SERVER['REMOTE_USER']; 40 $elem['readonly'] = 'readonly'; 41 $event->data->replaceElement($pos, $elem); 42 43 $pwd = auth_pwgen(); 44 foreach (array('pass', 'passchk') as $name) { 45 $pos = $event->data->findElementByAttribute('name', $name); 46 $event->data->replaceElement($pos, NULL); 47 $event->data->addHidden($name, $pwd); 48 } 49 } 50}