Hallo Forum,
ich benutze dieses plugin schon sehr, sehr lange für meine Community. Nun wollte ich mein WIKI von Greebo auf Igor updaten, nur leider funktioniert das plugin aus bekannten Gründen nicht mehr. Ich habe mir die Hinweise von splitbrain dazu angesehen (hier: https://github.com/Eole-dev/authphpbb3/issues/12 und hier: https://www.patreon.com/posts/better-forms-58551930). Ich habe mir auch die anderen plugins angesehen, die FORM_LOGIN_OUTPUT benutzen. Auf dieser Grundlage habe ich versucht, die action.php anzupassen. Ich verstehe aber nicht wirklich die Hintergründe, wie das alles zusammenhängt und funktioniert. Da verlassen mich dann auch die speziellen Kenntnisse über Dokuwiki.
Das plugin funktioniert soweit, wenn man beim phpbb3 angemeldet ist und man besucht das WIKI, wird man richtig erkannt. Aber die Login Funktion über das WIKI funktioniert so überhaupt nicht. Es passiert gar nichts, wenn man auf "Anmelden" klickt. Das Formular wird überhaupt nicht angepasst mit replaceElement usw.
Könnt ihr mir dabei helfen, dass grundsätzliche Problem zu erkennen? Ich wäre euch sehr dankbar.
MfG
Martin
<?php
/**
* Action Plugin for authphpbb3.
*
* @license GPL 2 (http://www.gnu.org/licenses/gpl.html)
* @author Eole <eole.dev@outlook.com>
*/
if (!defined('DOKU_INC')) {
die();
}
/**
* Action class for authphpbb3 plugin.
*/
class action_plugin_authphpbb3 extends DokuWiki_Action_Plugin {
/**
* Registers a callback function for a given event.
*
* @param Doku_Event_Handler $controller.
*/
public function register(Doku_Event_Handler $controller) {
$controller->register_hook('HTML_LOGINFORM_OUTPUT', 'BEFORE', $this, 'handle_login_form'); //old
$controller->register_hook('FORM_LOGIN_OUTPUT', 'BEFORE', $this, 'handle_login_form'); //new
$controller->register_hook('COMMON_USER_LINK', 'AFTER', $this, 'handle_user_link');
}
/**
* Replaces the DokuWiki form by the phpBB login form.
*
* @param Doku_Event $event Event.
* @param object $param Parameters.
*/
public function handle_login_form(Doku_Event $event, $param) {
$form = $event->data;
$form = new \dokuwiki\Form\Form();
global $auth;
global $ID;
$use_inline_css = $this->getConf('phpbb_inline_style');
$inline_css1 = '';
$inline_css2 = '';
$phpbb_url = '';
$cache = null;
$elem = '';
$pos = 0;
if (!is_a($auth, 'auth_plugin_authphpbb3')) {
return;
}
$phpbb_url = $auth->get_phpbb_url();
if ($phpbb_url === false) {
return ;
}
$phpbb_url = rtrim($phpbb_url, '/');
// Form's PHP script.
$form->params['action'] = $phpbb_url . '/ucp.php?mode=login';
// Username field.
$inline_css1 = ($use_inline_css ? ' style="padding-right:10px"' : '');
$elem = '<label class="block" for="username">' .
'<span' . $inline_css1 . '>' . $this->getLang('login_login') . '</span>' .
'<input type="text" tabindex="1" name="username" id="username" class="edit">' .
'</label><br/>';
if (is_a($form, \dokuwiki\Form\Form::class)) {
$pos = $form->findPositionByAttribute('name', 'u'); //new
} else {
$pos = $form->findElementByAttribute('name', 'u'); //old
}
if ($pos === false) {
return;
}
echo "Col";
$form->replaceElement($pos, null);
echo "Cool";
$form->addElement($pos, $elem);
echo "Coool";
// Password field.
$inline_css1 = ($use_inline_css ? ' style="padding-right:10px"' : '');
$elem = '<label class="block" for="password">' .
'<span' . $inline_css1 . '>' . $this->getLang('login_password') . '</span>' .
'<input type="password" tabindex="2" name="password" id="password" class="edit">' .
'</label><br/>';
if (is_a($form, \dokuwiki\Form\Form::class)) {
$pos = $form->findPositionByAttribute('name', 'p'); //new
} else {
$pos = $form->findElementByAttribute('name', 'p'); //old
}
if ($pos === false) {
return ;
}
$form->replaceElement($pos, null);
$form->addElement($pos, $elem);
// Remember me check box.
$inline_css1 = ($use_inline_css ? ' style="margin-left:20%;margin-bottom:10px;"' : '');
$inline_css2 = ($use_inline_css ? ' style="padding-left:5px"' : '');
$elem = '<label class="simple"' . $inline_css1 . ' for="autologin">' .
'<input type="checkbox" name="autologin" id="autologin" tabindex="3">' .
'<span' . $inline_css2 . '>' . $this->getLang('login_remember') . '</span>' .
'</label>';
if (is_a($form, \dokuwiki\Form\Form::class)) {
$pos = $form->findPositionByAttribute('name', 'r'); //new
} else {
$pos = $form->findElementByAttribute('name', 'r'); //old
}
if ($pos === false) {
return ;
}
$form->replaceElement($pos, null);
$form->addElement($pos, $elem);
// View online check box.
$inline_css1 = ($use_inline_css ? ' style="margin-left:20%;margin-bottom:10px;"' : '');
$inline_css2 = ($use_inline_css ? ' style="padding-left:5px"' : '');
$elem = '<label class="simple"' . $inline_css1 . ' for="viewonline">' .
'<input type="checkbox" name="viewonline" id="viewonline" tabindex="4">' .
'<span' . $inline_css2 . '>' . $this->getLang('login_viewonline') . '</span>' .
'</label>';
$form->addElement($pos + 1, $elem);
// Log in button.
$elem = '<button type="submit" name="login" tabindex="5" value="' . $this->getLang('login_button') . '">' .
$this->getLang('login_button') .
'</button>';
$pos = $form->findPositionByType('button');
if ($pos === false) {
return ;
}
$form->replaceElement($pos, null);
$form->addElement($pos, $elem);
// Hidden field for redirection.
$elem = '<input type="hidden" name="redirect" value="' . wl($ID, '', true) . '">';
$form->addElement($pos - 1, $elem);
// Forum URL.
$form->addElement('<p>' . sprintf($this->getLang('login_bottom_text'), $phpbb_url) . '</p>');
}
/**
* Adds a link to phpBB profile on all users' names.
*
* @param Doku_Event $event Event.
* @param object $param Parameters.
*/
public function handle_user_link(&$event, $param) {
global $auth, $conf;
$profile = '<a href="%s" class="interwiki iw_user" rel="nofollow" target="_blank">%s</a>';
if (!is_a($auth, 'auth_plugin_authphpbb3')) {
return;
}
if (($conf['showuseras'] !== 'username_link') || $event->data['textonly']) {
return ;
}
if (empty($event->data['name'])) {
$event->data['name'] = $event->data['username'];
}
$data = $auth->getUserData($event->data['username']);
if (is_array($data) &&
array_key_exists('phpbb_profile', $data) &&
array_key_exists('name', $data) &&
!empty($data['phpbb_profile']) &&
!empty($data['name'])) {
$profile = sprintf($profile, $data['phpbb_profile'], $data['name']);
} else {
$profile = sprintf($profile, '#', $event->data['name']);
}
$event->data = array(
'username' => $event->data['username'],
'name' => $event->data['name'],
'link' => $event->data['link'],
'userlink' => $profile,
'textonly' => $event->data['textonly']
);
}
}