You are here

function domain_batch in Domain Access 6.2

Same name and namespace in other branches
  1. 5 domain_admin.inc \domain_batch()
  2. 7.3 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_domainbatch().

Return value

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

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

File

./domain.admin.inc, line 678
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 = module_invoke_all('domainbatch');

  // 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 #variable is not set, eliminate the root domain.
  if (empty($batch[$action]['#variable'])) {
    unset($domains[0]);
  }

  // If we are doing a delete action, only valid domains can be acted upon.
  $allowed = array();
  if (!empty($batch[$action]['#table'])) {
    $data = db_query("SELECT domain_id FROM {%s}", $batch[$action]['#table']);
    while ($test = db_result($data)) {
      $allowed[] = $domains[$test];
    }
    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);
}