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