Skip to content
Snippets Groups Projects
Commit c2bc267a authored by Sebastian Paul's avatar Sebastian Paul
Browse files

open links in overlay add parent to link name add check for menu permission add navigation menu

parent 157b7fb1
No related branches found
No related tags found
No related merge requests found
......@@ -13,21 +13,39 @@
* @return array
* Array with links.
*/
function unity_webapp_menu_walk($tree) {
function unity_webapp_menu_walk($tree, $parent=null) {
$processedlink = array();
foreach ($tree as $obj) {
if ($obj['link'] && $obj['link']['link_title']) {
$processedlink['name'] = $obj['link']['link_title'];
if ($parent) {
$link_title = $parent . "/" . $obj['link']['link_title'];
}
else {
$link_title = $obj['link']['link_title'];
}
$processedlink['name'] = $link_title;
$processedlink['href'] = $obj['link']['href'];
$links[] = $processedlink;
}
if ($obj['below']) {
$links = array_merge($links, unity_webapp_menu_walk($obj['below']));
$links[] = $processedlink;
if ($obj['below']) {
$links = array_merge($links, unity_webapp_menu_walk($obj['below'],$link_title));
}
}
}
return $links;
}
/**
* Add overlay to all links in links array
*
* @param object $links
*/
function unity_webapp_menu_add_overlay(&$links) {
foreach ($links as &$link) {
$link['href'] = '#overlay=' . $link['href'];
}
}
/**
* Implements hook_unityapi_addlinks().
*
......@@ -35,6 +53,25 @@ function unity_webapp_menu_walk($tree) {
* Array with links.
*/
function unity_webapp_menu_unity_webapp_addlinks() {
$links = unity_webapp_menu_walk(menu_tree_all_data("management"));
// TOOD: decide if that permission should be checked here
if (! user_access('access administration pages')) {
return (array());
}
// Todo: evaluate more menus
// dsm(menu_get_names());
$links = array();
$management_links = unity_webapp_menu_walk(menu_tree_all_data("management"));
// As these links are all "management" they should be opened in overlay
if (module_exists("overlay")) {
unity_webapp_menu_add_overlay($management_links);
}
$user_links = unity_webapp_menu_walk(menu_tree_all_data("user-menu"));
$nav_links = unity_webapp_menu_walk(menu_tree_all_data("navigation"));
$links = array_merge($nav_links, $management_links, $user_links);
return $links;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment