From f73ca10b6c93021caec8c006308c22cd617b9d5d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Eric=20Espi=C3=A9?= Date: Tue, 2 Jan 2018 13:08:14 +0000 Subject: [PATCH] =?UTF-8?q?N=C2=B01070:=20Enhance=20ergonomics=20of=20"Add?= =?UTF-8?q?=20To=20Dashboard..."=20popup=20window=20*=20Larger=20window=20?= =?UTF-8?q?to=20avoid=20the=20scrollbar.=20*=20Check=20the=20dashboards=20?= =?UTF-8?q?root=20parent=20access=20rights=20to=20generate=20the=20dashboa?= =?UTF-8?q?rds=20list=20proposed=20in=20the=20popup.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SVN:trunk[5185] --- application/dashboard.class.inc.php | 65 ++++++++++++++++++++--------- 1 file changed, 45 insertions(+), 20 deletions(-) diff --git a/application/dashboard.class.inc.php b/application/dashboard.class.inc.php index ee52afc4ed..f9f3c4b44f 100644 --- a/application/dashboard.class.inc.php +++ b/application/dashboard.class.inc.php @@ -765,27 +765,52 @@ EOF $sRootMenuId = ApplicationMenu::GetRootMenuId($sContextMenuId); $aAllowedDashboards = array(); $sDefaultDashboard = null; - foreach($aAllMenus as $idx => $aMenu) + + // Store the parent menus for acces check + $aParentMenus = array(); + foreach($aAllMenus as $idx => $aMenu) + { + /** @var MenuNode $oMenu */ + $oMenu = $aMenu['node']; + if (count(ApplicationMenu::GetChildren($oMenu->GetIndex())) > 0) + { + $aParentMenus[$oMenu->GetMenuId()] = $aMenu; + } + } + + foreach($aAllMenus as $idx => $aMenu) { $oMenu = $aMenu['node']; - $sParentId = $aMenu['parent']; - if (($oMenu instanceof DashboardMenuNode) && ($oMenu->IsEnabled())) - { - $sMenuLabel = $oMenu->GetTitle(); - $sParentLabel = Dict::S('Menu:'.$sParentId); - if ($sParentLabel != $sMenuLabel) - { - $aAllowedDashboards[$oMenu->GetMenuId()] = $sParentLabel.' - '.$sMenuLabel; - } - else - { - $aAllowedDashboards[$oMenu->GetMenuId()] = $sMenuLabel; - } - if (empty($sDefaultDashboard) && ($sRootMenuId == ApplicationMenu::GetRootMenuId($oMenu->GetMenuId()))) - { - $sDefaultDashboard = $oMenu->GetMenuId(); - } - } + if ($oMenu instanceof DashboardMenuNode) + { + // Get the root parent for access check + $sParentId = $aMenu['parent']; + $aParentMenu = $aParentMenus[$sParentId]; + while (isset($aParentMenus[$aParentMenu['parent']])) + { + // grand parent exists + $sParentId = $aParentMenu['parent']; + $aParentMenu = $aParentMenus[$sParentId]; + } + $oParentMenu = $aParentMenu['node']; + if ($oMenu->IsEnabled() && $oParentMenu->IsEnabled()) + { + $sMenuLabel = $oMenu->GetTitle(); + $sParentLabel = Dict::S('Menu:'.$sParentId); + if ($sParentLabel != $sMenuLabel) + { + $aAllowedDashboards[$oMenu->GetMenuId()] = $sParentLabel.' - '.$sMenuLabel; + } + else + { + $aAllowedDashboards[$oMenu->GetMenuId()] = $sMenuLabel; + } + if (empty($sDefaultDashboard) && ($sRootMenuId == ApplicationMenu::GetRootMenuId($oMenu->GetMenuId()))) + { + $sDefaultDashboard = $oMenu->GetMenuId(); + } + } + } } asort($aAllowedDashboards); @@ -849,7 +874,7 @@ EOF $oPage->add_ready_script( <<