You are here

function webform_menu in Webform 5

Same name and namespace in other branches
  1. 5.2 webform.module \webform_menu()
  2. 6.3 webform.module \webform_menu()
  3. 6.2 webform.module \webform_menu()
  4. 7.4 webform.module \webform_menu()
  5. 7.3 webform.module \webform_menu()

Implementation of hook_menu().

File

./webform.module, line 66

Code

function webform_menu($may_cache) {
  global $user;
  $items = array();
  if ($may_cache) {

    // Submissions listing.
    $items[] = array(
      'path' => 'admin/content/webform',
      'title' => t('Webforms'),
      'callback' => 'webform_page',
      'access' => user_access('access webform results'),
      'description' => t('View and edit all the available webforms on your site.'),
      'type' => MENU_NORMAL_ITEM,
    );

    // Admin Settings.
    $items[] = array(
      'path' => 'admin/settings/webform',
      'title' => t('Webform'),
      'callback' => 'drupal_get_form',
      'callback arguments' => 'webform_admin_settings',
      'access' => user_access('administer site configuration'),
      'description' => t('Global configuration of webform functionality.'),
      'type' => MENU_NORMAL_ITEM,
    );
    return $items;
  }
  elseif (arg(0) == 'node' && is_numeric(arg(1))) {
    $node = node_load(arg(1));
    if ($node->nid && $node->type == 'webform') {
      $items[] = array(
        'path' => 'node/' . $node->nid . '/done',
        'title' => t('webform'),
        'callback' => '_webform_confirmation',
        'callback arguments' => array(
          arg(1),
        ),
        'access' => true,
        'type' => MENU_CALLBACK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results',
        'title' => t('Results'),
        'callback' => 'webform_results',
        'access' => user_access('access webform results'),
        'weight' => 2,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/submissions',
        'title' => t('Submissions'),
        'callback' => 'webform_results',
        'access' => user_access('access webform results'),
        'weight' => 4,
        'type' => MENU_DEFAULT_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/analysis',
        'title' => t('Analysis'),
        'callback' => 'webform_results',
        'access' => user_access('access webform results'),
        'weight' => 5,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/table',
        'title' => t('Table'),
        'callback' => 'webform_results',
        'access' => user_access('access webform results'),
        'weight' => 6,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/download',
        'title' => t('Download'),
        'callback' => 'webform_results',
        'access' => user_access('access webform results'),
        'weight' => 7,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/clear',
        'title' => t('Clear'),
        'callback' => 'webform_results',
        'access' => user_access('clear webform results'),
        'weight' => 8,
        'type' => MENU_LOCAL_TASK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/delete',
        'title' => t('Webform'),
        'callback' => 'webform_results',
        'access' => user_access('clear webform results'),
        'type' => MENU_CALLBACK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/view',
        'title' => t('View'),
        'callback' => 'webform_results',
        'access' => true,
        // Access checked in webform_submission_view().
        'type' => MENU_CALLBACK,
      );
      $items[] = array(
        'path' => 'node/' . $node->nid . '/results/edit',
        'title' => t('Edit'),
        'callback' => 'webform_results',
        'access' => true,
        // Access checked in webform_submission_edit().
        'type' => MENU_CALLBACK,
      );
    }
  }
  return $items;
}