1<?php
2// must be run within Dokuwiki
3if(!defined('DOKU_INC')) die();
4
5/**
6 * Authentication backend using generic SSO
7 * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
8 * @author     Etienne Meleard <etienne.meleard AT renater.fr>
9 **/
10
11class action_plugin_genericsso extends DokuWiki_Action_Plugin {
12    public function register(&$controller) {
13        global $conf;
14
15        if($conf['authtype'] != 'genericsso') return;
16
17        $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_login_form', array());
18    }
19
20    public function handle_login_form(&$event, $param) {
21        foreach($event->data->_content as $i => $field) {
22            if(!is_array($field)) continue;
23            if(!array_key_exists('name', $field)) continue;
24            if(!in_array($field['name'], array('u', 'p', 'r'))) continue;
25            unset($event->data->_content[$i]);
26        }
27    }
28}
29