function power_menu_get_menu in Power Menu 6
Same name and namespace in other branches
- 7 power_menu.module \power_menu_get_menu()
Get the menu which is defined as the power menu
4 calls to power_menu_get_menu()
- power_menu_get_breadcrumbs in ./
power_menu.module - Set Breadcrumbs based on active menu trail. I borrowed this function from the menutrails module
- power_menu_get_menu_tree in ./
power_menu.module - power_menu_get_mlid in ./
power_menu.module - power_menu_node_location in ./
power_menu.module - Determine the menu location of a node.
File
- ./
power_menu.module, line 222 - This module provides some additional menu features. The features are not actually new, but are part of other modules. it's though very cumbersome to creating a new menu item, because one has to go to all the different places to configure these…
Code
function power_menu_get_menu() {
global $user, $language;
$menus = array_filter(variable_get('power_menu_menu', array()));
if (empty($menus)) {
drupal_set_message(t("You have not chosen any power menu. Please visit the power menu settings"));
return NULL;
}
$rids = array_keys($user->roles);
$current_theme = variable_get('theme_default', 'none');
$args[] = $current_theme;
$args = array_merge($args, $menus);
$args = array_merge($args, $rids);
$result = db_query("SELECT b.* FROM {blocks} as b LEFT JOIN {blocks_roles} AS r ON b.delta = r.delta\n WHERE b.module='menu'\n AND theme='%s' AND b.delta IN (" . db_placeholders($menus, 'varchar') . ")\n AND (r.rid IN (" . db_placeholders($rids, 'int') . ") OR r.rid IS NULL) ", $args);
while ($block = db_fetch_object($result)) {
if (module_exists('i18nblocks')) {
$i18n_block = i18nblocks_load($block->module, $block->delta);
if ($i18n_block->language != $language->language && $i18n_block->language != '') {
continue;
}
}
// Match path if necessary
if ($block->pages) {
if ($block->visibility < 2) {
$path = drupal_get_path_alias($_GET['q']);
// Compare with the internal and path alias (if any).
$page_match = drupal_match_path($path, $block->pages);
if ($path != $_GET['q']) {
$page_match = $page_match || drupal_match_path($_GET['q'], $block->pages);
}
// When $block->visibility has a value of 0, the block is displayed on
// all pages except those listed in $block->pages. When set to 1, it
// is displayed only on those pages listed in $block->pages.
$page_match = !($block->visibility xor $page_match);
if ($page_match) {
return $block->delta;
}
}
else {
$page_match = drupal_eval($block->pages);
if ($page_match) {
return $block->delta;
}
}
}
else {
return $block->delta;
}
}
}