defend against unavailable login mechanism

This commit is contained in:
Andreas Gohr 2021-07-21 10:47:15 +02:00
commit a80089cadd

View file

@ -7,15 +7,14 @@
<h6 class="sr-only" role="heading" aria-level="2"><?php echo $lang['user_tools']; ?></h6>
<ul>
<li class="log"><?php
if (file_exists(DOKU_INC . 'inc/Menu/Item/Login.php')) {
try {
if (empty($_SERVER['REMOTE_USER'])) {
echo (new \dokuwiki\Menu\Item\Login())->asHtmlLink();
} else {
echo (new \dokuwiki\Menu\Item\Login())->asHtmlButton();
}
} else {
//Pre-Greebo Backwards compatibility
tpl_actionlink('login');
} catch (\RuntimeException $ignored) {
// item not available
}
?>
</li>
@ -26,26 +25,15 @@
}?>
<?php /* dokuwiki user tools */
if (file_exists(DOKU_INC . 'inc/Menu/Item/Admin.php')) {
try{
echo '<li class="admin">' . (new \dokuwiki\Menu\Item\Admin())->asHtmlLink() . '</li>';
} catch(\RuntimeException $ignored) {
// item not available
}
try{
echo '<li class="register">' . (new \dokuwiki\Menu\Item\Register())->asHtmlLink() . '</li>';
} catch(\RuntimeException $ignored) {
// item not available
}
} else {
//Pre-Greebo Backwards compatibility
tpl_toolsevent(
'usertools',
array(
'admin' => tpl_action('admin', 1, 'li', 1),
'register' => tpl_action('register', 1, 'li', 1),
)
);
try{
echo '<li class="admin">' . (new \dokuwiki\Menu\Item\Admin())->asHtmlLink() . '</li>';
} catch(\RuntimeException $ignored) {
// item not available
}
try{
echo '<li class="register">' . (new \dokuwiki\Menu\Item\Register())->asHtmlLink() . '</li>';
} catch(\RuntimeException $ignored) {
// item not available
}
?>