You are here

function domain_delete_form in Domain Access 7.3

Same name and namespace in other branches
  1. 5 domain_admin.inc \domain_delete_form()
  2. 6.2 domain.admin.inc \domain_delete_form()
  3. 7.2 domain.admin.inc \domain_delete_form()

A delete confirmation form.

Parameters

$form_state: The current form state, passed by FormsAPI.

$domain: An array containing the record from the {domain} table.

$arguments: An array of additional hidden key/value pairs to pass to the form. Used by child modules to control behaviors. Currently supported arguments are: 'user_submitted' => TRUE Indicates that a form should not process administrative messages and paths upon form submit. Used by the Domain User module.

1 string reference to 'domain_delete_form'
domain_menu in ./domain.module
Implements hook_menu().

File

./domain.admin.inc, line 610
Administration functions for the domain module.

Code

function domain_delete_form($form, &$form_state, $domain, $arguments = array()) {

  // This action should be performed from the primary domain.
  domain_check_primary();
  drupal_set_title(t('Delete !domain', array(
    '!domain' => $domain['sitename'],
  )));
  $form = array();

  // The $arguments array allows other modules to pass values to change the behavior
  // of submit and validate functions.
  if (!empty($arguments)) {
    $form['domain_arguments'] = array(
      '#type' => 'value',
      '#value' => $arguments,
    );
  }
  $form['domain'] = array(
    '#type' => 'value',
    '#value' => $domain,
  );
  if (!empty($domain['is_default'])) {
    drupal_set_message(t('The primary domain may not be deleted. <a href="!url">Select a new primary domain</a> before deleting this record.', array(
      '!url' => url('admin/structure/domain'),
    )), 'warning');
    return $form;
  }

  // Allow for data resets.
  $domains = domain_domains();
  $options = array(
    'none' => t('Do not reassign'),
  );
  foreach ($domains as $record) {
    if ($record['domain_id'] != $domain['domain_id']) {
      $options[$record['domain_id']] = $record['sitename'];
    }
  }
  $form['domain_access'] = array(
    '#title' => t('Reassign content'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => domain_default_id(),
    '#description' => t('All content assigned to %domain will be re-assigned to your selection.', array(
      '%domain' => $domain['sitename'],
    )),
  );
  $form['domain_editor'] = array(
    '#title' => t('Reassign editors'),
    '#type' => 'select',
    '#options' => $options,
    '#default_value' => domain_default_id(),
    '#description' => t('All users assigned to %domain will be re-assigned to your selection.', array(
      '%domain' => $domain['sitename'],
    )),
  );
  return confirm_form($form, t('Are you sure you wish to delete the domain record for <strong>%domain</strong>?', array(
    '%domain' => $domain['subdomain'],
  )), 'admin/structure/domain/view', NULL, t('Delete domain record'), t('Cancel'));
}