Properly show dropdown for limited access users

This commit is contained in:
Mike Koch 2016-12-29 12:56:50 -05:00
parent 3f7a57fd66
commit 76dab03bc3

View File

@ -230,198 +230,221 @@ $mails = mfh_get_mail_headers_for_dropdown($_SESSION['id'], $hesk_settings, $hes
<span class="hidden-xs"><?php echo hesk_SESSION('name'); ?></span> <span class="hidden-xs"><?php echo hesk_SESSION('name'); ?></span>
</a> </a>
</li> </li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">
<i class="fa fa-cogs"></i>
</a>
<ul class="dropdown-menu">
<?php <?php
if (hesk_checkPermission('can_man_users', 0)): $number_of_settings = 0;
$markup = '';
if (hesk_checkPermission('can_man_users', 0)) {
$number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_USERS') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_USERS') {
$active = 'active '; $active = 'active ';
} }
?> $markup .= '
<li class="<?php echo $active; ?>"> <li class="' . $active . '">
<a href="manage_users.php"> <a href="manage_users.php">
<i class="fa fa-fw fa-users" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-users" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['manage_users']; ?></span> <span>' . $hesklang['manage_users'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_permission_tpl', 0)) {
if (hesk_checkPermission('can_man_permission_tpl', 0)) : $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_PERMISSION_TPL') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_PERMISSION_TPL') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="manage_permission_templates.php"> <a href="manage_permission_templates.php">
<i class="fa fa-fw fa-users" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-users" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['permission_templates']; ?></span> <span>' . $hesklang['permission_templates'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_cat', 0)) {
if (hesk_checkPermission('can_man_cat', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_CATEGORIES') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_CATEGORIES') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="manage_categories.php"> <a href="manage_categories.php">
<i class="fa fa-fw fa-pie-chart" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-pie-chart" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['menu_cat']; ?></span> <span>' . $hesklang['menu_cat'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_canned', 0)) {
if (hesk_checkPermission('can_man_canned', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_CANNED') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_CANNED') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="manage_canned.php"> <a href="manage_canned.php">
<i class="fa fa-fw fa-file-text-o" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-file-text-o" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['canned_responses_dropdown_title']; ?></span> <span>' . $hesklang['canned_responses_dropdown_title'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_ticket_tpl', 0)) {
if (hesk_checkPermission('can_man_ticket_tpl', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_TICKET_TPL') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_TICKET_TPL') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="manage_ticket_templates.php"> <a href="manage_ticket_templates.php">
<i class="fa fa-fw fa-ticket" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-ticket" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['ticket_tpl']; ?></span> <span>' . $hesklang['ticket_tpl'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_ban_emails', 0)) {
if (hesk_checkPermission('can_ban_emails', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_BANNED_EMAILS') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_BANNED_EMAILS') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="banned_emails.php"> <a href="banned_emails.php">
<i class="fa fa-fw fa-ban" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-ban" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['manage_banned_emails']; ?></span> <span>' . $hesklang['manage_banned_emails'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_ban_ips', 0)) {
if (hesk_checkPermission('can_ban_ips', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_BANNED_IPS') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_BANNED_IPS') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="banned_ips.php"> <a href="banned_ips.php">
<i class="fa fa-fw fa-ban" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-ban" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['manage_banned_ips']; ?></span> <span>' . $hesklang['manage_banned_ips'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_service_msg', 0)) {
if (hesk_checkPermission('can_service_msg', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_SERVICE_MESSAGES') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_SERVICE_MESSAGES') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="service_messages.php"> <a href="service_messages.php">
<i class="fa fa-fw fa-sticky-note-o" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-sticky-note-o" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['sm_title']; ?></span> <span>' . $hesklang['sm_title'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_email_tpl', 0)) {
if (hesk_checkPermission('can_man_email_tpl', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_EMAIL_TEMPLATES') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_EMAIL_TEMPLATES') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="manage_email_templates.php"> <a href="manage_email_templates.php">
<i class="fa fa-fw fa-envelope-o" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-envelope-o" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['manage_email_templates']; ?></span> <span>' . $hesklang['manage_email_templates'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_ticket_statuses', 0)) {
if (hesk_checkPermission('can_man_ticket_statuses', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_STATUSES') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_STATUSES') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="manage_statuses.php"> <a href="manage_statuses.php">
<i class="fa fa-fw fa-exchange" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-exchange" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['manage_statuses']; ?></span> <span>' . $hesklang['manage_statuses'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_settings', 0)) {
if (hesk_checkPermission('can_man_settings', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_CUSTOM_FIELDS') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_CUSTOM_FIELDS') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="custom_fields.php"> <a href="custom_fields.php">
<i class="fa fa-fw fa-plus-square-o" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-plus-square-o" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['manage_custom_fields']; ?></span> <span>' . $hesklang['manage_custom_fields'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if ($number_of_settings > 0 &&
echo '<li class="divider"></li>'; (hesk_checkPermission('can_view_logs', 0) || hesk_checkPermission('can_man_settings', 0))) {
if (hesk_checkPermission('can_view_logs', 0)): $markup .= '<li class="divider"></li>';
}
if (hesk_checkPermission('can_view_logs', 0)) {
$number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_LOGS') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_LOGS') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?>"> $markup .= '
<li class="' . $active . '">
<a href="view_message_log.php"> <a href="view_message_log.php">
<i class="fa fa-fw fa-heartbeat" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-heartbeat" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['view_message_log']; ?></span> <span>' . $hesklang['view_message_log'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif; if (hesk_checkPermission('can_man_settings', 0)) {
if (hesk_checkPermission('can_man_settings', 0)): $number_of_settings++;
$active = ''; $active = '';
if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_SETTINGS') { if (defined('PAGE_TITLE') && PAGE_TITLE == 'ADMIN_SETTINGS') {
$active = 'active'; $active = 'active';
} }
?>
<li class="<?php echo $active; ?> treeview"> $markup .= '
<li class="' . $active . '">
<a href="admin_settings.php"> <a href="admin_settings.php">
<i class="fa fa-fw fa-cog" <?php echo $iconDisplay; ?>></i> <i class="fa fa-fw fa-cog" ' . $iconDisplay . '></i>
<span><?php echo $hesklang['helpdesk_settings']; ?></span> <span>' . $hesklang['helpdesk_settings'] . '</span>
</a> </a>
</li> </li>';
<?php }
endif;
?> if ($number_of_settings == 1) :
echo $markup;
elseif ($number_of_settings > 1): ?>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button">
<i class="fa fa-cogs"></i> <?php echo $hesklang['settings']; ?>
</a>
<ul class="dropdown-menu">
<?php echo $markup; ?>
</ul> </ul>
</li> </li>
<?php endif; ?>
<li> <li>
<a href="index.php?a=logout&amp;token=<?php echo hesk_token_echo(); ?>"> <a href="index.php?a=logout&amp;token=<?php echo hesk_token_echo(); ?>">
<i class="octicon octicon-sign-out"></i> <i class="octicon octicon-sign-out"></i>