diff options
Diffstat (limited to 'modules/trigger/trigger.module')
-rw-r--r-- | modules/trigger/trigger.module | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/modules/trigger/trigger.module b/modules/trigger/trigger.module index 82d117272..aeb1211c9 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,25 @@ function trigger_menu() { } /** + * Access callback: Determines if triggers can be unassigned. + * + * @return bool + * TRUE if there are triggers that the user can unassign, FALSE otherwise. + * + * @see trigger_menu() + */ +function trigger_menu_unassign_access() { + if (!user_access('administer actions')) { + return FALSE; + } + $count = db_select('trigger_assignments') + ->countQuery() + ->execute() + ->fetchField(); + return $count > 0; +} + +/** * Implements hook_trigger_info(). * * Defines all the triggers that this module implements triggers for. |