function casetracker_menu in Case Tracker 5
Same name and namespace in other branches
- 6 casetracker.module \casetracker_menu()
- 7.2 casetracker.module \casetracker_menu()
- 7 casetracker.module \casetracker_menu()
Implementation of hook_menu().
File
- ./
casetracker.module, line 61 - Enables the handling of projects and their cases.
Code
function casetracker_menu($may_cache) {
global $user;
$items = array();
if ($may_cache) {
/* -- user accessible menu items ---------------------------------------- */
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_projects_overview',
'path' => 'casetracker',
'title' => t('Case Tracker'),
);
// these two menu items hook into the normal project overview
// display that starts at /project. the hope is that they will
// eventually become more "dashboardy" and unique.
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_projects_overview',
'path' => 'casetracker/list',
'type' => MENU_DEFAULT_LOCAL_TASK,
'title' => t('List'),
'weight' => -10,
);
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_projects_overview',
'callback arguments' => array(
'my',
),
'path' => 'casetracker/my',
'type' => MENU_LOCAL_TASK,
'title' => t('My Projects'),
);
// our regular projects/(all)? and projects/my menus.
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_projects_overview',
'path' => 'casetracker/projects',
'title' => t('Projects'),
);
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_projects_overview',
'path' => 'casetracker/projects/list',
'type' => MENU_DEFAULT_LOCAL_TASK,
'title' => t('List'),
'weight' => -10,
);
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_projects_overview',
'callback arguments' => array(
'my',
),
'path' => 'casetracker/projects/my',
'type' => MENU_LOCAL_TASK,
'title' => t('My Projects'),
);
// cases. all handled by the callback, there's a zillion of em.
// see also the code in !$may_cache though. may fiddle with this.
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_cases_overview',
'path' => 'casetracker/cases',
'title' => t('Cases'),
);
/* -- administrative menu items ----------------------------------------- */
$items[] = array(
'access' => user_access('administer case tracker'),
'callback' => 'casetracker_case_state_overview',
'path' => 'admin/content/casetracker',
'title' => t('Case states'),
'description' => t('Add, edit and delete Case States, Types and Priorities'),
);
$items[] = array(
'access' => user_access('administer case tracker'),
'path' => 'admin/content/casetracker/state/list',
'callback' => 'casetracker_case_state_overview',
'type' => MENU_DEFAULT_LOCAL_TASK,
'title' => t('List'),
'weight' => -10,
);
$items[] = array(
'access' => user_access('administer case tracker'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'casetracker_case_state_edit',
),
'path' => 'admin/content/casetracker/state/add',
'title' => t('Add case state'),
'type' => MENU_LOCAL_TASK,
);
$items[] = array(
'access' => user_access('administer case tracker'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'casetracker_case_state_edit',
),
'path' => 'admin/content/casetracker/state/edit',
'title' => t('Edit case state'),
'type' => MENU_CALLBACK,
);
$items[] = array(
'access' => user_access('administer case tracker'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'casetracker_case_state_confirm_delete',
),
'path' => 'admin/content/casetracker/state/delete',
'title' => t('Delete case state'),
'type' => MENU_CALLBACK,
);
/* -- potpourri menu items ---------------------------------------------- */
$items[] = array(
'access' => user_access('administer case tracker'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'casetracker_settings',
),
'description' => t('Configure the various Case Tracker options with these settings.'),
'path' => 'admin/settings/casetracker',
'title' => t('Case Tracker'),
);
$items[] = array(
'access' => user_access('administer case tracker'),
'callback' => 'drupal_get_form',
'callback arguments' => array(
'casetracker_settings',
),
'description' => t('Configure the various Case Tracker options with these settings.'),
'path' => 'admin/settings/casetracker/settings',
'title' => t('General'),
'type' => MENU_DEFAULT_LOCAL_TASK,
'weight' => -10,
);
$items[] = array(
'access' => user_access('access case tracker'),
'callback' => 'casetracker_autocomplete',
'path' => 'casetracker/autocomplete',
'title' => t('Case Tracker autocomplete'),
'type' => MENU_CALLBACK,
);
}
else {
// normally, access would be handled via 'access case tracker', but
// we want the user "Cases" tab, and specifically the state filtering,
// to work if the user has just the "show cases user tab" permission.
// we also want the 'cases' menu item to be removable via admin/menu
// (which is why it is also defined under $may_cache above). these
// two feature requirements mean we have to futz with the global $_menu,
// since we can't simply override already-defined menus by redeclaring.
if (!user_access('access case tracker') && arg(0) == 'casetracker' && arg(1) == 'cases' && preg_match('/all\\/assigned:' . $user->uid . ' author:' . $user->uid . ' /', arg(2) . '/' . arg(3))) {
if (user_access('show cases user tab')) {
global $_menu;
// make the baby druplicon cry.
$mid = $_menu['path index']['casetracker/cases'];
$_menu['items'][$mid]['access'] = TRUE;
}
}
// the 'cases' tab that shows up under /user.
if (arg(0) == 'user' && is_numeric(arg(1)) && arg(1) > 0) {
$items[] = array(
'access' => user_access('show cases user tab'),
'callback' => 'casetracker_cases_overview',
'callback arguments' => array(
'all',
'assigned:' . arg(1) . ' author:' . arg(1),
),
'path' => 'user/' . arg(1) . '/cases',
'title' => t('Cases'),
'type' => MENU_LOCAL_TASK,
'weight' => 1,
);
}
}
return $items;
}