diff --git a/module/common/model.php b/module/common/model.php index 26572a3a59..4551e4e96f 100644 --- a/module/common/model.php +++ b/module/common/model.php @@ -815,10 +815,19 @@ class commonModel extends model if(isset($dropMenuItem->hidden) and $dropMenuItem->hidden) continue; /* Parse drop menu link. */ - $dropMenuLink = zget($dropMenuItem, 'link', $dropMenuItem); + if(!empty($dropMenuItem['links'])) + { + $dropMenuLink = common::getHasPrivLink($dropMenuItem); + if(empty($dropMenuLink)) continue; - list($subLabel, $subModule, $subMethod, $subParams) = explode('|', $dropMenuLink); - if(!common::hasPriv($subModule, $subMethod)) continue; + list($subLabel, $subModule, $subMethod, $subParams) = $dropMenuLink; + } + else + { + $dropMenuLink = zget($dropMenuItem, 'link', $dropMenuItem); + list($subLabel, $subModule, $subMethod, $subParams) = explode('|', $dropMenuLink); + if(!common::hasPriv($subModule, $subMethod)) continue; + } $activeMainMenu = false; if($currentModule == strtolower($subModule) and $currentMethod == strtolower($subMethod)) @@ -843,6 +852,41 @@ class commonModel extends model return $activeMenu; } + /** + * 获取有权限的链接。 + * Get the authorized link. + * + * @param array $menu + * @access public + * @return array + */ + public static function getHasPrivLink(array $menu): array + { + $link = array(); + if(!empty($menu['link'])) + { + list($label, $module, $method, $params) = explode('|', $menu['link']); + if(common::hasPriv($module, $method)) + { + $link = array($label, $module, $method, $params); + } + elseif(!empty($menu['links'])) + { + foreach($menu['links'] as $menuLink) + { + list($module, $method, $params) = explode('|', $menuLink); + if(common::hasPriv($module, $method)) + { + $link = array($label, $module, $method, $params); + break; + } + } + } + } + + return $link; + } + /** * 当对象编辑后,比较前后差异。 * Create changes of one object. @@ -2298,6 +2342,10 @@ eof; $link = sprintf($menu['link'], $objectID); $menu['link'] = vsprintf($link, $params); + if(!empty($menu['links'])) + { + foreach($menu['links'] as $key => $link) $menu['links'][$key] = sprintf($link, $objectID); + } } else {