diff --git a/modules/trigger/trigger.admin.inc b/modules/trigger/trigger.admin.inc index 447d0dc..5b607c8 100644 --- a/modules/trigger/trigger.admin.inc +++ b/modules/trigger/trigger.admin.inc @@ -53,7 +53,7 @@ function trigger_assign($module_to_display = NULL) { * @ingroup forms */ function trigger_unassign($form, $form_state, $module, $hook = NULL, $aid = NULL) { - if (!($hook && $aid)) { + if (!isset($hook, $aid)) { drupal_goto('admin/structure/trigger'); } diff --git a/modules/trigger/trigger.module b/modules/trigger/trigger.module index 82d1172..1c869c2 100644 --- a/modules/trigger/trigger.module +++ b/modules/trigger/trigger.module @@ -65,7 +65,10 @@ function trigger_menu() { 'description' => 'Unassign an action from a trigger.', 'page callback' => 'drupal_get_form', 'page arguments' => array('trigger_unassign'), - 'access arguments' => array('administer actions'), + // Only accessible if there are any actions that can be unassigned. + 'access callback' => 'trigger_menu_unassign_access', + // Only output in the breadcrumb, not in menu trees. + 'type' => MENU_VISIBLE_IN_BREADCRUMB, 'file' => 'trigger.admin.inc', ); @@ -73,6 +76,17 @@ function trigger_menu() { } /** + * Menu access callback for admin/structure/trigger/unassign. + */ +function trigger_menu_unassign_access() { + if (!user_access('administer actions')) { + return FALSE; + } + $actions = actions_get_all_actions(); + return !empty($actions); +} + +/** * Implements hook_trigger_info(). * * Defines all the triggers that this module implements triggers for.