1<?php 2 3/** 4 * DokuWiki Plugin authdiscourse (Action Component) 5 * 6 * Replaces the login form. 7 * 8 * Based on the action.php from the authsaml plugin with the following 9 * authors and license: 10 * 11 * @author Sixto Martin <sixto.martin.garcia@gmail.com> 12 * @author Andreas Aakre Solberg, UNINETT, http://www.uninett.no 13 * @author François Kooman 14 * @author Thijs Kinkhorst, Universiteit van Tilburg 15 * @author Jorge Hervás <jordihv@gmail.com>, Lukas Slansky <lukas.slansky@upce.cz> 16 17 * @license GPL2 http://www.gnu.org/licenses/gpl.html 18 * @link https://github.com/pitbulk/dokuwiki-saml 19 */ 20 21// must be run within Dokuwiki 22if (!defined('DOKU_INC')) 23 die(); 24 25class action_plugin_authdiscourse extends DokuWiki_Action_Plugin 26{ 27 28 /** 29 * Register event handlers 30 */ 31 public function register(Doku_Event_Handler $controller) { 32 global $conf; 33 if ($conf['authtype'] == 'authdiscourse') { 34 $controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_login_form'); 35 } 36 } 37 38 function handle_login_form(&$event, $param) 39 { 40 global $auth, $lang; 41 42 $loginurl = $auth->getLoginURL(); 43 44 // Replace the whole existing form as we can't handle username/password. 45 $event->data->_content = array(); 46 $event->data->insertElement(0, '<a href="'.$loginurl.'" style="border: 5px solid; font-size: 200%; padding: 0.2em 0.5em;">'.$lang['btn_login'].'</a>'); 47 } 48 49} 50