You are here

function domain_batch in Domain Access 7.3

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

Allows for the batch update of certain elements.

Parameters

$action: The name of the action to perform; corresponds to the keys of the $batch array returned by hook_domain_batch().

Return value

The appropriate form, or a list of actions, or an error.

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

File

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

Code

function domain_batch($action = NULL) {

  // We must have the module configured correctly.
  $domains = domain_domains();
  if (empty($domains)) {
    return t('There are no domains configured for this site.');
  }
  $batch = domain_batch_actions();

  // We must have some actions, otherwise, no point.
  if (empty($batch)) {
    return t('There are no batch actions configured.');
  }

  // If we are on the main page, just list the actions.
  if (empty($action)) {
    return domain_batch_list($batch);
  }

  // If we are doing a delete action, only valid domains can be acted upon.
  $allowed = array();
  if (!empty($batch[$action]['#table'])) {
    $table = db_escape_table($batch[$action]['#table']);
    $result = db_query("SELECT domain_id FROM {$table}");
    foreach ($result as $test) {
      $allowed[] = $domains[$test->domain_id];
    }
    if (empty($allowed)) {
      return t('There are no valid domains on which to perform this action.  The likely reason is that no records exist in the specified table.');
    }
  }
  else {
    $allowed = $domains;
  }

  // If we passed all the checks, generate the form.
  return drupal_get_form('domain_batch_form', $action, $batch[$action], $allowed);
}