Skip to content

Commit

Permalink
support UI\Login form modification in AuthAD
Browse files Browse the repository at this point in the history
authad plugin will insert domain selector in the Ui\Login form during the  event HTML_LOGINFORM_OUTPUT
  • Loading branch information
ssahara committed Jul 23, 2020
1 parent fd76e02 commit 8549e2b
Showing 1 changed file with 23 additions and 7 deletions.
30 changes: 23 additions & 7 deletions lib/plugins/authad/action.php
Expand Up @@ -73,17 +73,33 @@ public function handleHtmlLoginformOutput(Doku_Event $event, $param)

// update user field value
if ($dom) {
$usr = $auth->getUserName($usr);
$pos = $form->findElementByAttribute('name', 'u');
$ele =& $form->getElementAt($pos);
$ele['value'] = $usr;
$usr = $auth->getUserName($usr);
if (is_a($form, 'dokuwiki\Form\Form')) {
if (($pos = $form->findPositionByAttribute('name', 'u')) !== false) {
$element = $form->getElementAt($pos);
$element->val($usr);
} else {
return;
}
} else {
$pos = $form->findElementByAttribute('name', 'u');
$ele =& $form->getElementAt($pos);
$ele['value'] = $usr;
}
}
}

// add select box
$element = form_makeListboxField('dom', $domains, $dom, $this->getLang('domain'), '', 'block');
$pos = $form->findElementByAttribute('name', 'p');
$form->insertElement($pos + 1, $element);
if (is_a($form, 'dokuwiki\Form\Form')) {
$element = new \dokuwiki\Form\DropdownElement('dom', $domains, $this->getLang('domain'));
$element->addClass('block');
// locate domain selector just after the username input box
$form->addElement($element, $pos +1);
} else {
$element = form_makeListboxField('dom', $domains, $dom, $this->getLang('domain'), '', 'block');
$pos = $form->findElementByAttribute('name', 'p');
$form->insertElement($pos + 1, $element);
}
}
}

Expand Down

0 comments on commit 8549e2b

Please sign in to comment.