You are here

function rules_link_menu in Rules Link 7

Same name and namespace in other branches
  1. 7.2 rules_link.module \rules_link_menu()

Implements hook_menu().

File

./rules_link.module, line 388
Rules Link - module file.

Code

function rules_link_menu() {
  $item = array();
  foreach (rules_link_get_links() as $name => $link) {
    $first_arg = count(explode('/', $link->path));
    switch ($link->settings['link_type']) {
      case 'javascript':
        $item[$link->path . '/%/%'] = array(
          'page callback' => 'rules_link_trigger_js',
          'page arguments' => array(
            $link,
            $first_arg,
          ),
          'access arguments' => array(
            $link,
            $first_arg,
            $first_arg + 1,
          ),
          'access callback' => 'rules_link_access_link',
          'type' => MENU_CALLBACK,
        );
        break;
      case 'token':
        $item[$link->path . '/%/%'] = array(
          'page callback' => 'rules_link_trigger_token',
          'page arguments' => array(
            $link,
            $first_arg,
          ),
          'access arguments' => array(
            $link,
            $first_arg,
            $first_arg + 1,
          ),
          'access callback' => 'rules_link_access_link',
          'type' => MENU_CALLBACK,
        );
        break;
      case 'confirm':
        $item[$link->path . '/%'] = array(
          'page callback' => 'drupal_get_form',
          'page arguments' => array(
            'rules_link_trigger_form',
            $link,
            $first_arg,
          ),
          'access arguments' => array(
            $link,
            $first_arg,
          ),
          'access callback' => 'rules_link_access_link_confirm',
          'type' => MENU_CALLBACK,
        );
        break;
    }
  }
  return $item;
}