You are here

function support_menu in Support Ticketing System 6

Same name and namespace in other branches
  1. 7 support.module \support_menu()

Implementation of hook_menu().

File

./support.module, line 82
support.module

Code

function support_menu() {
  $items['support'] = array(
    'title' => 'Support tickets',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'support_page_form',
    ),
    'access callback' => 'support_access_clients',
    'access arguments' => array(),
  );
  $items['support/fetch'] = array(
    'type' => MENU_CALLBACK,
    'page callback' => 'support_fetch_client_mail',
    'access arguments' => array(
      'download mail via support/fetch',
    ),
  );

  // Autocomplete paths
  $items['support/autocomplete/assigned'] = array(
    'title' => 'Autocomplete support assigned user',
    'page callback' => 'support_autocomplete_assigned',
    'access callback' => 'support_access_clients',
    'access arguments' => array(),
    'type' => MENU_CALLBACK,
  );
  $items['support/autocomplete/autosubscribe'] = array(
    'title' => 'Autocomplete support autosubscribed user',
    'page callback' => 'support_autocomplete_autosubscribe',
    'access callback' => '_support_autosubscribe_access',
    'type' => MENU_CALLBACK,
  );
  $states = array(
    'all' => 'all',
    'all open' => 'all open',
    'my open' => 'my open',
  ) + _support_states();
  $result = db_query('SELECT clid, path, name FROM {support_client} WHERE status = 1 AND parent = 0');
  $clients = array();
  while ($client = db_fetch_object($result)) {
    $clients[] = $client;
  }
  if (count($clients) > 1) {
    $combined = new stdClass();
    $combined->clid = SUPPORT_ALL_CLIENTS;

    // @todo: use reserved path
    $combined->path = '_all_';
    $combined->name = '** All Tickets **';
    $clients[] = $combined;
  }
  foreach ($clients as $client) {
    $items['support/' . $client->path] = array(
      'title' => check_plain($client->name),
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'support_page_form',
        $client->clid,
      ),
      'access callback' => 'support_access_clients',
      'access arguments' => array(
        $client,
      ),
    );
    foreach ($states as $sid => $state) {
      $items["support/{$client->path}/{$state}"] = array(
        'title' => "{$state}",
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'support_page_form',
          $client->clid,
          $state,
        ),
        'access callback' => 'support_access_clients',
        'access arguments' => array(
          $client,
        ),
        'weight' => $sid,
        'type' => $sid == 'all open' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
      );
    }
    $result2 = db_query('SELECT clid, path, name FROM {support_client} WHERE status = 1 AND parent = %d', $client->clid);
    while ($subclient = db_fetch_object($result2)) {
      $items["support/{$client->path}/{$subclient->path}"] = array(
        'title' => check_plain($subclient->name),
        'page callback' => 'drupal_get_form',
        'page arguments' => array(
          'support_page_form',
          $subclient->clid,
        ),
        'access callback' => 'support_access_clients',
        'access arguments' => array(
          $subclient,
        ),
      );
      foreach ($states as $sid => $state) {
        $items["support/{$client->path}/{$subclient->path}/{$state}"] = array(
          'title' => "{$state}",
          'page callback' => 'drupal_get_form',
          'page arguments' => array(
            'support_page_form',
            $subclient->clid,
            $state,
          ),
          'access callback' => 'support_access_clients',
          'access arguments' => array(
            $subclient,
          ),
          'weight' => $sid,
          'type' => $sid == 'all open' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
        );
      }
    }
  }
  $items['support/user/%user'] = array(
    'page callback' => 'support_page_user',
    'page arguments' => array(
      2,
    ),
    'access callback' => 'support_access_user_tickets',
    'access arguments' => array(
      2,
    ),
    'type' => MENU_CALLBACK,
    'file' => 'support.user.inc',
  );
  $items['support/%user_uid_optional/assigned'] = array(
    'title' => 'My tickets',
    'page callback' => 'support_page_user',
    'page arguments' => array(
      1,
      TRUE,
    ),
    'access callback' => 'support_page_user_access',
    'access arguments' => array(
      1,
    ),
    'file' => 'support.user.inc',
  );
  unset($states['my open']);
  foreach ($states as $sid => $state) {
    $items["support/%user_uid_optional/assigned/{$state}"] = array(
      'title' => "{$state}",
      'page callback' => 'support_page_user',
      'page arguments' => array(
        1,
        TRUE,
        $state,
      ),
      'access callback' => 'support_access_clients',
      'access arguments' => array(
        $client,
      ),
      'file' => 'support.user.inc',
      'weight' => $sid,
      'type' => $sid == 'all open' ? MENU_DEFAULT_LOCAL_TASK : MENU_LOCAL_TASK,
    );
  }
  $items['support/%node/unsubscribe/%user/%'] = array(
    'page callback' => 'support_unsubscribe_user',
    'page arguments' => array(
      1,
      3,
      4,
    ),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['support/all/unsubscribe/%user/%'] = array(
    'page callback' => 'support_unsubscribe_user',
    'page arguments' => array(
      'all',
      3,
      4,
    ),
    'access callback' => TRUE,
    'type' => MENU_CALLBACK,
  );
  $items['admin/support'] = array(
    'title' => 'Support ticketing system',
    'description' => 'Manage the support ticket system.',
    'position' => 'right',
    'weight' => 5,
    'page callback' => 'support_admin_menu_block_page',
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/clients'] = array(
    'title' => 'Clients',
    'description' => 'Manage clients.',
    'page callback' => 'support_admin_client_overview',
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/clients/list'] = array(
    'title' => 'List',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/support/clients/%support_client/edit'] = array(
    'title' => 'Edit',
    'type' => MENU_CALLBACK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'support_admin_client',
      3,
    ),
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/clients/%support_client/delete'] = array(
    'title' => 'Delete',
    'type' => MENU_CALLBACK,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'support_admin_client_delete',
      3,
    ),
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/clients/%support_client/fetch'] = array(
    'title' => 'Fetch mail',
    'type' => MENU_CALLBACK,
    'page callback' => 'support_client_fetch',
    'page arguments' => array(
      3,
    ),
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/clients/add'] = array(
    'title' => 'Add client',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'support_admin_client',
    ),
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/settings'] = array(
    'title' => 'Settings',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'support_admin_settings',
    ),
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  $items['admin/support/settings/general'] = array(
    'title' => 'General settings',
    'type' => MENU_DEFAULT_LOCAL_TASK,
  );
  $items['admin/support/settings/mail'] = array(
    'title' => 'Mail text settings',
    'type' => MENU_LOCAL_TASK,
    'weight' => 2,
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'support_admin_mail_settings',
    ),
    'access arguments' => array(
      'administer support',
    ),
    'file' => 'support.admin.inc',
  );
  return $items;
}