'Fabian Bircher', 'email' => 'fabian@esn.org', 'date' => '2013-06-13', 'name' => 'plain CAS Plugin', 'desc' => 'Authenticate DokuWiki users via CAS', ); } function register (Doku_Event_Handler $controller) { $controller->register_hook ('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_login_form'); $controller->register_hook ('ACTION_ACT_PREPROCESS', 'BEFORE', $this, 'handle_action'); $controller->register_hook ('ACTION_ACT_PREPROCESS', 'AFTER', $this, 'handle_action_after'); $controller->register_hook ('TPL_ACT_UNKNOWN', 'BEFORE', $this, 'handle_template'); } function _self () { global $ID; return wl($ID, '', true, ''); } function _selfdo ($do) { global $ID; return wl($ID, 'do=' . $do, true, '&'); } function _redirect ($url) { header ('Location: ' . $url); exit; } function handle_login_form (&$event, $param) { global $auth; global $conf; global $lang; global $ID; if($conf['authtype'] == 'authplaincas') { if ($this->getConf('logourl') != '') { $caslogo = ' '; } else { $caslogo = ''; } //var_dump($event->data->_content); $event->data->_content = array(); // remove the login form $event->data->insertElement(0,'
'.$this->getConf('name').''); $event->data->insertElement(1,'

'.$caslogo.'
'.$lang['btn_login'].'

'); $event->data->insertElement(2,'
'); //instead of removing, one could implement a local login here... // if ($this->getConf('jshidelocal')) { // $event->data->insertElement(3,'

Only use this if you cannot use the '.$this->getConf('name').' above.

'); // $event->data->replaceElement(4,'
'.$this->getConf('localname').''); // } else { // $event->data->replaceElement(3,'
'.$this->getConf('localname').''); // } $insertElement = 3; if ($auth && $auth->canDo('modPass') && actionOK('resendpwd')) { $event->data->insertElement($insertElement,'

'.$lang['pwdforget'].': '.$lang['btn_resendpwd'].'

'); } } } function handle_caslogin () { global $auth; $auth->logIn(); } function handle_caslogout () { auth_logoff(); } function handle_action (&$event, $param) { if ($event->data == 'caslogin') { $event->preventDefault(); $this->handle_caslogin(); } if ($event->data == 'logout') { $this->handle_caslogout(); } } function handle_action_after (&$event, $param){ global $ACT, $auth, $USERINFO, $MSG; if( (($ACT == 'denied' && empty($USERINFO)) || $ACT == 'login') && $this->getConf('force_redirect') && !($auth && $auth->canDo('modPass') && actionOK('resendpwd')) ){ // check $MSG if(is_array($MSG)){ foreach ($MSG as $m) { if($m && info_msg_allowed($m)){ return; // Has messages, don't execute the redirector below } } } $this->handle_caslogin(); // will jump out if redirect is required } } function handle_template (&$event, $param) { if ($event->data == 'caslogin') { $event->preventDefault(); } } }