Index: modules/trigger/trigger.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/trigger/trigger.module,v
retrieving revision 1.58
diff -u -r1.58 trigger.module
--- modules/trigger/trigger.module	26 Dec 2009 16:50:09 -0000	1.58
+++ modules/trigger/trigger.module	12 Jan 2010 18:46:44 -0000
@@ -11,20 +11,21 @@
  * Implements hook_help().
  */
 function trigger_help($path, $arg) {
-  $explanation = '<p>' . t('Triggers are events on your site, such as new content being added or a user logging in. The Trigger module associates these triggers with actions (functional tasks), such as unpublishing content containing certain keywords or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure advanced actions (actions requiring configuration, such as an e-mail address or a list of banned words).', array('@url' => url('admin/config/system/actions'))) . '</p>';
-  switch ($path) {
-    case 'admin/structure/trigger/comment':
-      return $explanation . '<p>' . t('Below you can assign actions to run when certain comment-related triggers happen. For example, you could promote a post to the front page when a comment is added.') . '</p>';
-    case 'admin/structure/trigger/node':
-      return $explanation . '<p>' . t('Below you can assign actions to run when certain content-related triggers happen. For example, you could send an e-mail to an administrator when content is created or updated.') . '</p>';
-    case 'admin/structure/trigger/system':
-      return $explanation . '<p>' . t('Below you can assign actions to run during each pass of a <a href="@cron">cron maintenance task</a>.', array('@cron' => url('admin/reports/status'))) . '</p>';
-    case 'admin/structure/trigger/taxonomy':
-      return $explanation . '<p>' . t('Below you can assign actions to run when certain taxonomy-related triggers happen. For example, you could send an e-mail to an administrator when a term is deleted.') . '</p>';
-    case 'admin/structure/trigger/user':
-      return $explanation . '<p>' . t("Below you can assign actions to run when certain user-related triggers happen. For example, you could send an e-mail to an administrator when a user account is deleted.") . '</p>';
+  // Generate help text for admin/structure/trigger/(module) tabs.
+  $matches = array();
+  if (preg_match('|^admin/structure/trigger/(.*)$|', $path, $matches)) {
+    $explanation = '<p>' . t('Triggers are events on your site, such as new content being added or a user logging in. The Trigger module associates these triggers with actions (functional tasks), such as unpublishing content containing certain keywords or e-mailing an administrator. The <a href="@url">Actions settings page</a> contains a list of existing actions and provides the ability to create and configure advanced actions (actions requiring configuration, such as an e-mail address or a list of banned words).', array('@url' => url('admin/config/system/actions'))) . '</p>';
+
+    $module = $matches[1];
+    $trigger_info = _trigger_tab_information();
+    if ($trigger_info[$module]) {
+      $explanation .= '<p>' . t('There is a tab on this page for each module that defines triggers. On this tab you can assign actions to run when triggers from the <a href="@module-help">@module-name module</a> happen.', array('@module-help' => url('admin/help/' . $module), '@module-name' => $trigger_info[$module])) . '</p>';
+    }
+
+    return $explanation;
+  }
 
-    case 'admin/help#trigger':
+  if ($path == 'admin/help#trigger') {
       $output = '';
       $output .= '<h3>' . t('About') . '</h3>';
       $output .= '<p>' . t('The Trigger module provides the ability to cause <em>actions</em> to run when certain <em>triggers</em> take place on your site. Triggers are events, such as new content being added to your site or a user logging in, and actions are tasks, such as unpublishing content or e-mailing an administrator. For more information, see the online handbook entry for <a href="@trigger">Trigger module</a>.', array('@trigger' => 'http://drupal.org/handbook/modules/trigger/')) . '</p>';
@@ -49,31 +50,18 @@
     'file' => 'trigger.admin.inc',
   );
 
-  // We want contributed modules to be able to describe
-  // their hooks and have actions assignable to them.
-  $trigger_info = module_invoke_all('trigger_info');
-  drupal_alter('trigger_info', $trigger_info);
-
-  foreach ($trigger_info as $module => $hooks) {
-    $info = db_select('system')
-      ->fields('system', array('info'))
-      ->condition('name', $module)
-      ->condition('status', 1)
-      ->execute()
-      ->fetchField();
-    if ($info) {
-      $info = unserialize($info);
-      $nice_name = $info['name'];
-      $items["admin/structure/trigger/$module"] = array(
-        'title' => $nice_name,
-        'page callback' => 'trigger_assign',
-        'page arguments' => array($module),
-        'access arguments' => array('administer actions'),
-        'type' => MENU_LOCAL_TASK,
-        'file' => 'trigger.admin.inc',
-      );
-    }
+  $trigger_info = _trigger_tab_information();
+  foreach ($trigger_info as $module => $nice_name) {
+    $items["admin/structure/trigger/$module"] = array(
+      'title' => $nice_name,
+      'page callback' => 'trigger_assign',
+      'page arguments' => array($module),
+      'access arguments' => array('administer actions'),
+      'type' => MENU_LOCAL_TASK,
+      'file' => 'trigger.admin.inc',
+    );
   }
+
   $items['admin/structure/trigger/unassign'] = array(
     'title' => 'Unassign',
     'description' => 'Unassign an action from a trigger.',
@@ -619,3 +607,33 @@
   return $triggers;
 }
 
+/**
+ * Gathers information about tabs on the triggers administration screen.
+ *
+ * @return
+ *    Array of modules that have triggers, with the keys being the
+ *    machine-readable name of the module, and the values being the
+ *    human-readable name of the module.
+ */
+function _trigger_tab_information() {
+
+  // Gather the trigger information.
+  $trigger_info = module_invoke_all('trigger_info');
+  drupal_alter('trigger_info', $trigger_info);
+
+  $return_info = array();
+  foreach ($trigger_info as $module => $hooks) {
+    $info = db_select('system')
+      ->fields('system', array('info'))
+      ->condition('name', $module)
+      ->condition('status', 1)
+      ->execute()
+      ->fetchField();
+    if ($info) {
+      $info = unserialize($info);
+      $return_info[$module] = $info['name'];
+    }
+  }
+
+  return $return_info;
+}
