Skip to content
This repository has been archived by the owner on Sep 13, 2024. It is now read-only.

Snenko hide top menu items #12365

Open
wants to merge 2 commits into
base: developer
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions layouts/basic/modules/Vtiger/menu/Label.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
{else}
{assign var=ACTIVE value='false'}
{/if}

{if $MENU_MODULE=='Settings::Vtiger'}
{assign var=SHOWITEMMENU value='true'}
{else}
{assign var=SHOWITEMMENU value=Vtiger_Menu_Model::isShowTopLevelMenuItem($MENU, $MENU_MODULE)}
{/if}

{if $SHOWITEMMENU=='true'}
<li class="tpl-menu-Label c-menu__item js-menu__item nav-item menuLabel {if !$HASCHILDS}hasParentMenu{/if}" data-id="{$MENU['id']}"
data-js="mouseenter mouseleave">
<a class="nav-link {if $ACTIVE=='true'}active{else}collapsed{/if}{if $ICON} hasIcon{/if}{if $HASCHILDS == 'true'} js-submenu-toggler is-submenu-toggler{/if}" href="#"
Expand All @@ -18,4 +26,5 @@
</a>
{include file=\App\Layout::getTemplatePath('menu/SubMenu.tpl', $MODULE)}
</li>
{/if}
{/strip}
29 changes: 29 additions & 0 deletions modules/Vtiger/models/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,4 +218,33 @@ public static function getMenuIcon($menu, $title = '')
}
return '';
}

/**
* @param $menu
*
* @return bool
*/
public static function isShowTopLevelMenuItem($menu)
{
if(isset($menu['childs']) && count($menu['childs'])>0) {
foreach ($menu['childs'] as $id=>$subMenu) {

$privilegesModel = Users_Privileges_Model::getCurrentUserPrivilegesModel();
if(\App\Module::isModuleActive($subMenu['mod'])==false) {
continue;
}

if ($privilegesModel->isAdminUser() ||
$privilegesModel->hasGlobalReadPermission() ||
$privilegesModel->hasModulePermission($subMenu['tabid']) ) {
return true;
}

}

return false;
}

return true;
}
}