You are here

function domain_batch_form in Domain Access 5

Same name and namespace in other branches
  1. 6.2 domain.admin.inc \domain_batch_form()
  2. 7.3 domain.admin.inc \domain_batch_form()
  3. 7.2 domain.admin.inc \domain_batch_form()

Generate the form data for a batch update.

Parameters

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

$batch: The batch data for this $action, as defined by hook_domainbatch().

Return value

A themed table of links and descriptions for batch actions.

1 string reference to 'domain_batch_form'
domain_batch in ./domain_admin.inc
Allows for the batch update of certain elements.

File

./domain_admin.inc, line 845
Administration functions for the domain module.

Code

function domain_batch_form($action, $batch, $domains) {
  $default = array();
  drupal_set_title($batch['#form']['#title']);
  $form = array();
  $form['message'] = array(
    '#type' => 'markup',
    '#value' => theme('domain_batch_title', $batch),
  );
  $form['domain_batch'] = array(
    '#tree' => TRUE,
    '#title' => $batch['#form']['#title'],
    '#description' => $batch['#meta_description'],
  );
  foreach ($domains as $domain) {

    // Set the current value according to the stored values.
    $default[$domain['domain_id']] = $domain[$action];
    if ($batch['#domain_action'] == 'domain_conf') {

      // Set the default value to the main settings.
      $default[$domain['domain_id']] = variable_get($action, $batch['#system_default']);

      // Check for domain-specific settings.
      $result = db_result(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $domain['domain_id']));
      $settings = unserialize($result);
      if (isset($settings[$action])) {
        $default[$domain['domain_id']] = $settings[$action];
      }
    }
    else {
      if ($batch['#domain_action'] == 'custom' && isset($batch['#lookup'])) {
        $default[$domain['domain_id']] = $batch['#system_default'];
        $func = $batch['#lookup'];
        $setting = $func($domain);
        if ($setting != -1) {
          $default[$domain['domain_id']] = $setting;
        }
      }
    }

    // Take the settings from the $batch array.
    $form['domain_batch'][$domain['domain_id']] = $batch['#form'];

    // Add the domain-specific elements.
    $form['domain_batch'][$domain['domain_id']]['#sitename'] = $domain['sitename'];
    $form['domain_batch'][$domain['domain_id']]['#default_value'] = $default[$domain['domain_id']];
  }
  $form['handler'] = array(
    '#type' => 'value',
    '#value' => $batch['#domain_action'],
  );
  $form['variable'] = array(
    '#type' => 'value',
    '#value' => $batch['#variable'],
  );
  $form['table'] = array(
    '#type' => 'value',
    '#value' => $batch['#table'],
  );
  $form['submit_handler'] = array(
    '#type' => 'value',
    '#value' => $batch['#submit'],
  );
  $form['validate_handler'] = array(
    '#type' => 'value',
    '#value' => $batch['#validate'],
  );
  $form['data_type'] = array(
    '#type' => 'value',
    '#value' => $batch['#data_type'],
  );
  $form['batch_item'] = array(
    '#type' => 'value',
    '#value' => $action,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Update domain settings'),
  );
  return $form;
}