You are here

function trigger_menu in Drupal 6

Same name and namespace in other branches
  1. 7 modules/trigger/trigger.module \trigger_menu()

Implementation of hook_menu().

File

modules/trigger/trigger.module, line 36
Enables functions to be stored and executed at a later time when triggered by other modules or by one of Drupal's core API hooks.

Code

function trigger_menu() {
  $items['admin/build/trigger'] = array(
    'title' => 'Triggers',
    'description' => 'Tell Drupal when to execute actions.',
    'page callback' => 'trigger_assign',
    'access callback' => 'trigger_access_check',
    'access arguments' => array(
      'node',
    ),
    'file' => 'trigger.admin.inc',
  );

  // We don't use a menu wildcard here because these are tabs,
  // not invisible items.
  $items['admin/build/trigger/node'] = array(
    'title' => 'Content',
    'page callback' => 'trigger_assign',
    'page arguments' => array(
      'node',
    ),
    'access callback' => 'trigger_access_check',
    'access arguments' => array(
      'node',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'trigger.admin.inc',
  );
  $items['admin/build/trigger/user'] = array(
    'title' => 'Users',
    'page callback' => 'trigger_assign',
    'page arguments' => array(
      'user',
    ),
    'access callback' => 'trigger_access_check',
    'access arguments' => array(
      'user',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'trigger.admin.inc',
  );
  $items['admin/build/trigger/comment'] = array(
    'title' => 'Comments',
    'page callback' => 'trigger_assign',
    'page arguments' => array(
      'comment',
    ),
    'access callback' => 'trigger_access_check',
    'access arguments' => array(
      'comment',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'trigger.admin.inc',
  );
  $items['admin/build/trigger/taxonomy'] = array(
    'title' => 'Taxonomy',
    'page callback' => 'trigger_assign',
    'page arguments' => array(
      'taxonomy',
    ),
    'access callback' => 'trigger_access_check',
    'access arguments' => array(
      'taxonomy',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'trigger.admin.inc',
  );
  $items['admin/build/trigger/cron'] = array(
    'title' => 'Cron',
    'page callback' => 'trigger_assign',
    'page arguments' => array(
      'cron',
    ),
    'access arguments' => array(
      'administer actions',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'trigger.admin.inc',
  );

  // We want contributed modules to be able to describe
  // their hooks and have actions assignable to them.
  $hooks = module_invoke_all('hook_info');
  foreach ($hooks as $module => $hook) {

    // We've already done these.
    if (in_array($module, array(
      'node',
      'comment',
      'user',
      'system',
      'taxonomy',
    ))) {
      continue;
    }
    $info = db_result(db_query("SELECT info FROM {system} WHERE name = '%s'", $module));
    $info = unserialize($info);
    $nice_name = $info['name'];
    $items["admin/build/trigger/{$module}"] = array(
      'title' => $nice_name,
      'page callback' => 'trigger_assign',
      'page arguments' => array(
        $module,
      ),
      'access callback' => 'trigger_access_check',
      'access arguments' => array(
        $module,
      ),
      'type' => MENU_LOCAL_TASK,
      'file' => 'trigger.admin.inc',
    );
  }
  $items['admin/build/trigger/unassign'] = array(
    'title' => 'Unassign',
    'description' => 'Unassign an action from a trigger.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'trigger_unassign',
    ),
    'access arguments' => array(
      'administer actions',
    ),
    'type' => MENU_CALLBACK,
    'file' => 'trigger.admin.inc',
  );
  return $items;
}