You are here

function hosting_task_menu in Hosting 7.4

Same name and namespace in other branches
  1. 5 task/hosting_task.module \hosting_task_menu()
  2. 6.2 task/hosting_task.module \hosting_task_menu()
  3. 7.3 task/hosting_task.module \hosting_task_menu()

Implements hook_menu().

File

task/hosting_task.module, line 23
Web server node type is defined here.

Code

function hosting_task_menu() {
  $items = array();
  $tasks = hosting_available_tasks();
  foreach ($tasks as $type => $type_tasks) {
    if (empty($type_tasks)) {

      // This is to workaround problems in the upgrade path where the
      // hook returns nothing (e.g. for server).
      continue;
    }
    foreach ($type_tasks as $task => $info) {
      if (empty($info['hidden'])) {
        $path = sprintf("hosting_confirm/%%hosting_%s_wildcard/%s_%s", $type, $type, $task);
        $items[$path] = array(
          'title' => $info['title'],
          'description' => $info['description'],
          'page callback' => 'drupal_get_form',
          'page arguments' => array(
            'hosting_task_confirm_form',
            1,
            $task,
          ),
          'access callback' => 'hosting_task_menu_access_csrf',
          'access arguments' => array(
            1,
            $task,
          ),
          'type' => MENU_CALLBACK,
        );

        // Complement the $items array with attributes from the task definition
        // e.g. a custom access callback.
        $items[$path] = array_merge($items[$path], $info);
      }
    }
  }
  $items['hosting/tasks/%node/list'] = array(
    'title' => 'Task list',
    'description' => 'AJAX callback for refreshing task list',
    'page callback' => 'hosting_task_ajax_list',
    'page arguments' => array(
      2,
    ),
    'access callback' => 'node_access',
    'access arguments' => array(
      'view',
      2,
    ),
    'type' => MENU_CALLBACK,
  );
  $items['hosting/tasks/%node/cancel'] = array(
    'title' => 'Task list',
    'description' => 'Callback for stopping tasks',
    'page callback' => 'hosting_task_cancel',
    'page arguments' => array(
      2,
    ),
    'access callback' => 'hosting_task_cancel_access',
    'access arguments' => array(
      2,
    ),
    'type' => MENU_CALLBACK,
  );
  $items['hosting/tasks/queue'] = array(
    'title' => 'Task list',
    'description' => 'AJAX callback for refreshing task queue',
    'page callback' => 'hosting_task_ajax_queue',
    'access arguments' => array(
      'access task logs',
    ),
    'type' => MENU_CALLBACK,
  );

  // Custom path to task node views for overlay.
  // See hosting_task_overlay_paths().
  $items['hosting/task/%node'] = array(
    'page callback' => 'node_page_view',
    'page arguments' => array(
      2,
    ),
    'access arguments' => array(
      'access task logs',
    ),
  );
  $items['hosting/task/log/ajax/%node/%/%'] = array(
    'page callback' => 'hosting_task_log_ajax',
    'page arguments' => array(
      4,
      5,
      6,
    ),
    'access arguments' => array(
      'access task logs',
    ),
    'delivery callback' => 'ajax_deliver',
  );
  return $items;
}