You are here

function hosting_task_confirm_form in Hosting 7.4

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

Implements hook_form().

2 string references to 'hosting_task_confirm_form'
hosting_site_form_alter in site/hosting_site.form.inc
Implements hook_form_alter().
hosting_task_menu in task/hosting_task.module
Implements hook_menu().

File

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

Code

function hosting_task_confirm_form($form, $form_state, $node, $task) {
  drupal_add_js(drupal_get_path('module', 'hosting_task') . '/hosting_task.js');
  $tasks = hosting_available_tasks($node->type);
  if (!isset($tasks[$task]['dialog']) || !$tasks[$task]['dialog']) {
    hosting_add_task($node->nid, $task);
    if ($task == 'delete') {

      // We're deleting a Hosting object, and thus its corresponding node. If
      // we stay on the current page, we'll end up with a 404, so redirect to
      // the home page.
      drupal_set_message(t(':title has been queued for deletion.', array(
        ':title' => $node->title,
      )));
      drupal_goto();
    }
    drupal_goto('node/' . $node->nid);
  }
  $form['help'] = array(
    '#value' => $tasks[$task]['description'],
  );
  $form['nid'] = array(
    '#type' => 'value',
    '#value' => $node->nid,
  );
  $form['task'] = array(
    '#type' => 'value',
    '#value' => $task,
  );
  $form['parameters'] = array(
    '#tree' => TRUE,
  );

  // Invoke hosting_task_TASK_TYPE_form.
  $func = 'hosting_task_' . str_replace('-', '_', $task) . '_form';
  if (function_exists($func)) {
    $form['parameters'] += $func($node);
  }

  // Invoke hosting_task_TASK_TYPE_form_validate.
  $func = $func . '_validate';
  if (function_exists($func)) {
    $form['#validate'][] = $func;
    $form['#func_param_1'] = $node;
    $form['#func_param_2'] = $task;
  }
  $question = t("Are you sure you want to @task @object?", array(
    '@task' => $task,
    '@object' => $node->title,
  ));
  $path = !empty($_REQUEST['destination']) ? $_REQUEST['destination'] : 'node/' . $node->nid;
  $form = confirm_form($form, $question, $path, '', $tasks[$task]['title']);

  // Add an extra class to the actions to allow us to
  // disable the cancel link via javascript for the modal dialog.
  $form['actions']['#prefix'] = '<div id="hosting-task-confirm-form-actions" class="container-inline">';
  $form['actions']['#suffix'] = '</div>';
  return $form;
}