Skip to content

Commit 0ad5a1d

Browse files
authored
Clean up code in navbar (hestiacp#2912)
* Cleaned up code in navbar - Replaced many ifs with the 'in_array' native PHP function to set item in navbar active or not * Fix Log item not being set as active in navbar - Log item is never set as active in navbar. When using the `admin` account the `server` item is set as active (when accessing logs via Server -> Logs) because it uses a query string setting the user as `system`. Now it will keep this behavior but when no user is set via query string the Log item will be set as active.
1 parent b5fbb21 commit 0ad5a1d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

web/templates/includes/panel.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<!-- Left Menu -->
1515
<div class="l-menu clearfix noselect">
1616
<!-- Records tab -->
17-
<div class="l-menu__item <?php if($TAB == 'WEB') echo 'l-menu__item--active' ?> <?php if($TAB == 'DNS') echo 'l-menu__item--active' ?> <?php if($TAB == 'MAIL') echo 'l-menu__item--active' ?> <?php if($TAB == 'DB') echo 'l-menu__item--active' ?> <?php if($TAB == 'BACKUP') echo 'l-menu__item--active' ?> <?php if($TAB == 'CRON') echo 'l-menu__item--active' ?><?php if($TAB == 'PACKAGE') echo 'l-menu__item--active' ?> <?php if($TAB == 'USER') echo 'l-menu__item--active' ?><?php if($TAB == 'LOG') echo 'l-menu__item--active' ?>"><a href="<?=htmlspecialchars($home_url)?>"><i class="fas fa-tasks panel-icon"></i><?=_('Records');?></a></div>
17+
<div class="l-menu__item <?php if(in_array($TAB, ['WEB', 'DNS', 'MAIL', 'DB', 'BACKUP', 'CRON', 'PACKAGE', 'USER', 'LOG'])) echo 'l-menu__item--active' ?>"><a href="<?=htmlspecialchars($home_url)?>"><i class="fas fa-tasks panel-icon"></i><?=_('Records');?></a></div>
1818

1919
<!-- File Manager tab -->
2020
<?php if ((isset($_SESSION['FILE_MANAGER'])) && (!empty($_SESSION['FILE_MANAGER'])) && ($_SESSION['FILE_MANAGER'] == "true")) {?>
@@ -65,14 +65,14 @@
6565
<?php if (($_SESSION['userContext'] === 'admin') && (!empty($_SESSION['look']))) {?>
6666
<!-- Hide 'Server Settings' button when impersonating 'admin' or other users -->
6767
<?php } else { ?>
68-
<div class="l-menu__item <?php if($TAB == 'SERVER') echo 'l-menu__item--active' ?> <?php if($TAB == 'IP') echo 'l-menu__item--active' ?> <?php if($TAB == 'RRD') echo 'l-menu__item--active' ?> <?php if($TAB == 'FIREWALL') echo 'l-menu__item--active' ?>"><a href="/list/server/" class="l-profile__serversettings" title="<?=_('Server');?>"><i class="fas fa-cog"></i></a></div>
68+
<div class="l-menu__item <?php if(in_array($TAB, ['SERVER', 'IP', 'RRD', 'FIREWALL'])) echo 'l-menu__item--active' ?>"><a href="/list/server/" class="l-profile__serversettings" title="<?=_('Server');?>"><i class="fas fa-cog"></i></a></div>
6969
<?php } ?>
7070
<?php } ?>
7171

7272
<!-- Edit User -->
7373
<?php if (($_SESSION['userContext'] === 'admin') && (isset($_SESSION['look']) && ($user == 'admin'))) {?>
7474
<!-- Hide 'edit user' entry point from other administrators for default 'admin' account-->
75-
<div class="l-menu__item"><a href="/list/log/" title="<?_('Logs');?>" class="l-profile__username"><i class="fas fa-history"></i></a></div>
75+
<div class="l-menu__item <?php if($TAB == 'LOG') echo 'l-menu__item--active' ?>"><a href="/list/log/" title="<?_('Logs');?>" class="l-profile__username"><i class="fas fa-history"></i></a></div>
7676
<?php } else { ?>
7777
<?php if ($panel[$user]['SUSPENDED'] === 'no') {?>
7878
<div class="l-menu__item"><a href="/edit/user/?user=<?=$user; ?>&token=<?=$_SESSION['token']?>" title="<?=htmlspecialchars($user)?> (<?=htmlspecialchars($panel[$user]['NAME'])?>)" class="l-profile__username"><i class="fas fa-user-circle"></i></a></div>
@@ -106,7 +106,7 @@
106106
$user_count = $panel[$user]['U_USERS'];
107107
}
108108
?>
109-
<div class="l-stat__col <?php if($TAB == 'USER') echo 'l-stat__col--active' ?><?php if($TAB == 'LOG') echo 'l-stat__col--active' ?>">
109+
<div class="l-stat__col <?php if(in_array($TAB, ['USER', 'LOG'])) echo 'l-stat__col--active' ?>">
110110
<a href="/list/user/" title="<?=_('Users');?>: <?=$user_count;?>&#13;<?=_('Suspended');?>: <?=$panel[$user]['SUSPENDED_USERS']?>">
111111
<div class="l-stat__col-title"><?=_('USER');?>&nbsp;&nbsp;<i class="fas fa-users"></i></div>
112112
<ul>

0 commit comments

Comments
 (0)