function module_grants_monitor_menu in Module Grants 6.4
Same name and namespace in other branches
- 6.3 module_grants_monitor/module_grants_monitor.module \module_grants_monitor_menu()
Implementation of hook_menu().
Define new menu items and local tasks (tabs). Existing menu items are modified through hook_menu_alter().
File
- module_grants_monitor/
module_grants_monitor.module, line 95
Code
function module_grants_monitor_menu() {
$items = array();
// Create an 'Acessible content' menu item in the navigation menu.
// Add tabs: 'I created', 'I last modified', 'I can edit', 'I can view', each
// with sub tabs 'Published', 'Unpublished', 'All'
// There's an issue w.r.t assigning default tab selections for the
// 'Accessible content' menu item. Core insists that each row of tabs has
// exactly one tab defined with type=MENU_DEFAULT_LOCAL_TASK, the other tabs
// having type=MENU_LOCAL_TASK.
// The default we set needs to be part of the subset of tabs that the user
// is permitted to see. The problem is that the user permissions are evaluated
// when the menu and its tabs are about to be rendered (in menu.inc,
// function theme_menu_local_tasks()), whereas the type must be defined
// upfront when the menu structure is created, i.e. in the lines below.
// The way we get around this problem is to first load the page with content
// according to the user permissions, by calling this module's function
// _module_grants_monitor_accessible_content_summary(). Then we take advantage
// of the Smart menus module, which overrides theme_menu_local_tasks(), to
// highlight as 'current' the tabs matching the content shown.
$items['accessible-content'] = array(
'title' => 'Accessible content',
'page callback' => '_module_grants_monitor_accessible_content_summary',
'page arguments' => array(),
// tabs default based on user permissions
'access callback' => 'user_tools_user_any_access',
'access arguments' => array(
module_grants_monitor_perm(),
),
'weight' => 2,
);
// 'I created' and sub tabs
$items['accessible-content/i-created'] = array(
'title' => 'I created',
'page callback' => '_module_grants_monitor_accessible_content_summary',
'page arguments' => array(
'access I Created tab',
),
// 2nd tab defaults
'access callback' => 'user_access',
'access arguments' => array(
'access I Created tab',
),
'type' => MENU_LOCAL_TASK,
'weight' => 0,
);
$items['accessible-content/i-created/published'] = array(
'title' => 'Published',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'1',
I_CREATED,
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Created tab',
'access Published tab',
),
),
'type' => MENU_LOCAL_TASK,
);
$items['accessible-content/i-created/not-published'] = array(
'title' => 'Unpublished',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'0',
I_CREATED,
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Created tab',
'access Unpublished tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items['accessible-content/i-created/all'] = array(
'title' => 'All',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'-1',
I_CREATED,
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Created tab',
'access All tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
// 'I last modified' and sub tabs
$items['accessible-content/i-last-modified'] = array(
'title' => 'I last modified',
'page callback' => '_module_grants_monitor_accessible_content_summary',
// 2nd tab defaults
'page arguments' => array(
'access I Last Modified tab',
),
'access callback' => 'user_access',
'access arguments' => array(
'access I Last Modified tab',
),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
$items['accessible-content/i-last-modified/published'] = array(
'title' => 'Published',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'1',
I_LAST_MODIFIED,
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Last Modified tab',
'access Published tab',
),
),
'type' => MENU_LOCAL_TASK,
);
$items['accessible-content/i-last-modified/not-published'] = array(
'title' => 'Unpublished',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'0',
I_LAST_MODIFIED,
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Last Modified tab',
'access Unpublished tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items['accessible-content/i-last-modified/all'] = array(
'title' => 'All',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'-1',
I_LAST_MODIFIED,
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Last Modified tab',
'access All tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
// 'I can edit' and sub tabs
$items['accessible-content/i-can-edit'] = array(
'title' => 'I can edit',
'page callback' => '_module_grants_monitor_accessible_content_summary',
// 2nd tab defaults
'page arguments' => array(
'access I Can Edit tab',
),
'access callback' => 'user_access',
'access arguments' => array(
'access I Can Edit tab',
),
'type' => MENU_LOCAL_TASK,
'weight' => 10,
);
$items['accessible-content/i-can-edit/published'] = array(
'title' => 'Published',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'update',
'1',
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Can Edit tab',
'access Published tab',
),
),
'type' => MENU_LOCAL_TASK,
);
$items['accessible-content/i-can-edit/not-published'] = array(
'title' => 'Unpublished',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'update',
'0',
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Can Edit tab',
'access Unpublished tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items['accessible-content/i-can-edit/all'] = array(
'title' => 'All',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'update',
'-1',
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Can Edit tab',
'access All tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
// 'I can view' and sub tabs
$items['accessible-content/i-can-view'] = array(
'title' => 'I can view',
'page callback' => '_module_grants_monitor_accessible_content_summary',
// 2nd tab defaults
'page arguments' => array(
'access I Can View tab',
),
'access callback' => 'user_access',
'access arguments' => array(
'access I Can View tab',
),
'type' => MENU_LOCAL_TASK,
'weight' => 15,
);
$items['accessible-content/i-can-view/published'] = array(
'title' => 'Published',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'1',
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Can View tab',
'access Published tab',
),
),
'type' => MENU_LOCAL_TASK,
);
$items['accessible-content/i-can-view/not-published'] = array(
'title' => 'Unpublished',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'0',
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Can View tab',
'access Unpublished tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
$items['accessible-content/i-can-view/all'] = array(
'title' => 'All',
'page callback' => 'module_grants_monitor_accessible_content_summary',
// both tabs known
'page arguments' => array(
'view',
'-1',
),
'access callback' => 'user_tools_user_all_access',
'access arguments' => array(
array(
'access I Can View tab',
'access All tab',
),
),
'type' => MENU_LOCAL_TASK,
'weight' => 5,
);
return $items;
}