domain_batch_form($action, $batch, $domains)
domain_admin.inc, line 827
Generate the form data for a batch update.
$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().
A themed table of links and descriptions for batch actions.
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;
}