From d32c54a10fb3369c1dde6dfa791d89e2453f6645 Mon Sep 17 00:00:00 2001
From: Julian Rother <julian@cccv.de>
Date: Mon, 26 Dec 2022 02:43:19 +0100
Subject: [PATCH] Update form events for Dokuwiki Igor compatability

---
 action.php      | 22 +++++++++++++++-------
 plugin.info.txt |  2 +-
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/action.php b/action.php
index ad88c1b..4258948 100644
--- a/action.php
+++ b/action.php
@@ -10,10 +10,23 @@ class action_plugin_authuffd extends DokuWiki_Action_Plugin
 		if($conf['authtype'] != 'authuffd')
 			return;
 		$conf['profileconfirm'] = false; /* password confirmation doesn't work with SSO users */
-		$controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_loginform');
+		$controller->register_hook('FORM_LOGIN_OUTPUT', 'BEFORE', $this, 'handle_loginform');
+		$controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_loginform_old');
 	}
 
-	function handle_loginform(Doku_Event &$event, $param)
+	function handle_loginform(Doku_Event &$event)
+	{
+		$form = $event->data;
+		do {
+			$form->removeElement(0);
+		} while ($form->elementCount() > 0);
+		$form->addFieldsetOpen('Login with:');
+		$form->setHiddenField('oauth2_login', '1');
+		$form->addButton('', $this->getConf('name'))->attr('type', 'submit');
+		$form->addFieldsetClose();
+	}
+
+	function handle_loginform_old(Doku_Event &$event, $param)
 	{
 		$event->data->_content = array(
 			form_openfieldset(array('_legend' => 'Login with:', 'class' => 'plugin_authuffd')),
@@ -22,9 +35,4 @@ class action_plugin_authuffd extends DokuWiki_Action_Plugin
 			form_closefieldset()
 		);
 	}
-
-	function handle_dologin(Doku_Event &$event, $param)
-	{
-		msg('handle_dologin');
-	}
 }
diff --git a/plugin.info.txt b/plugin.info.txt
index 75c481f..336f363 100644
--- a/plugin.info.txt
+++ b/plugin.info.txt
@@ -1,7 +1,7 @@
 base   authuffd
 author Julian Rother
 email  julian@cccv.de
-date   2022-02-19
+date   2022-12-26
 name   Authentication with Uffd
 desc   Auth plugin for login via uffd
 url    https://git.cccv.de/uffd/dokuwiki-plugin-authuffd
-- 
GitLab