From 585c1ef8e04a77b983e6b31ab9fcfbdae36f5f46 Mon Sep 17 00:00:00 2001 From: Craig Heydenburg Date: Mon, 22 Jun 2015 11:28:37 -0400 Subject: [PATCH] use capabilities array to set 'default' admin link where possible. refs #2500 --- .../viewplugins/function.adminpanelmenu.php | 11 ++++---- .../Controller/AdminController.php | 25 +++++++++++-------- .../AdminModule/Controller/AjaxController.php | 5 +++- .../Module/BlocksModule/Api/MenutreeApi.php | 20 +++++++-------- 4 files changed, 33 insertions(+), 28 deletions(-) diff --git a/src/lib/legacy/viewplugins/function.adminpanelmenu.php b/src/lib/legacy/viewplugins/function.adminpanelmenu.php index 307b8cb31e..fb28ad7f54 100644 --- a/src/lib/legacy/viewplugins/function.adminpanelmenu.php +++ b/src/lib/legacy/viewplugins/function.adminpanelmenu.php @@ -43,6 +43,7 @@ function smarty_function_adminpanelmenu($params, Zikula_View $view) // add override for panel width created from .scss file PageUtil::addVar('stylesheet', '@ZikulaAdminModule/Resources/public/css/mmenu-hiddenpanel-customwidth.css'); + $router = $view->getContainer()->get('router'); $modules = ModUtil::getModulesCapableOf('admin'); // sort modules by displayname $moduleNames = array(); @@ -60,11 +61,9 @@ function smarty_function_adminpanelmenu($params, Zikula_View $view) if (SecurityUtil::checkPermission("module[name]::", '::', ACCESS_EDIT)) { // first-level list - list modules with general 'index' link $img = ModUtil::getModuleImagePath($module['name']); - try { - $url = ModUtil::url($module['name'], 'admin', 'index'); - } catch (\Exception $e) { - $url = '#'; - } + $url = isset($module['capabilities']['admin']['url']) + ? $module['capabilities']['admin']['url'] + : $router->generate($module['capabilities']['admin']['route']); $moduleSelected = empty($moduleSelected) && strpos($view->getRequest()->getUri(), $module['url']) ? " class='Selected'" : ""; $htmlContent .= "\"\" " . $module['displayname'] . ""; try { @@ -72,7 +71,7 @@ function smarty_function_adminpanelmenu($params, Zikula_View $view) } catch (\Exception $e) { $links = array(); } - if (count($links) > 0) { + if ((count($links) > 0) && ($links[0] != false)) { // create second-level list from module adminLinks $htmlContent .= '