function domain_batch_form in Domain Access 6.2
Same name and namespace in other branches
- 5 domain_admin.inc \domain_batch_form()
- 7.3 domain.admin.inc \domain_batch_form()
- 7.2 domain.admin.inc \domain_batch_form()
Generate the form data for a batch update.
Parameters
$form_state: The current form state, passed by FormsAPI.
$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().
$domains: The current settings for each domain.
Return value
A themed table of links and descriptions for batch actions.
2 string references to 'domain_batch_form'
- domain_batch in ./
domain.admin.inc - Allows for the batch update of certain elements.
- domain_warning_check in ./
domain.module - Sets a message to the site admin.
File
- ./
domain.admin.inc, line 783 - Administration functions for the domain module.
Code
function domain_batch_form($form_state, $action, $batch, $domains) {
$default = array();
drupal_set_title($batch['#form']['#title']);
$form = array();
$form['message'] = array(
'#type' => 'markup',
'#value' => theme('domain_batch_title', $batch),
);
// For some values, allow every record to be updated.
if (!empty($batch['#update_all'])) {
$form['domain_batch_all'] = array(
'#type' => 'fieldset',
'#title' => t('Update value for all domains'),
'#weight' => -10,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
'#description' => t('By entering a value below and checking the <strong>Apply to all domains</strong> option, you can set the desired value for all domains.'),
);
$form['domain_batch_all']['batch_all_setting'] = $batch['#form'];
$form['domain_batch_all']['batch_all_setting']['#default_value'] = $batch['#system_default'];
$form['domain_batch_all']['batch_override'] = array(
'#type' => 'checkbox',
'#title' => t('Apply to all domains'),
);
$form['domain_batch_all']['submit'] = array(
'#type' => 'submit',
'#value' => t('Update all domain settings'),
);
}
$form['domain_batch'] = array(
'#tree' => TRUE,
'#title' => $batch['#form']['#title'],
'#description' => $batch['#meta_description'],
);
if ($batch['#domain_action'] == 'domain_conf' && $batch['#form']['#type'] == 'select') {
$batch['#form']['#options'] = array(
'domain-conf-ignore' => t('Use primary domain settings'),
) + $batch['#form']['#options'];
}
foreach ($domains as $domain) {
// Set the current value according to the stored values.
if (isset($domain[$action])) {
$default[$domain['domain_id']] = $domain[$action];
}
if ($batch['#domain_action'] == 'domain_conf') {
// Set the default value to the main settings.
// In rare cases, variable_get() returns unusable data, so we override it.
if (empty($batch['#override_default'])) {
$default[$domain['domain_id']] = variable_get($action, $batch['#system_default']);
}
else {
$default[$domain['domain_id']] = $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 = domain_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'] = check_plain($domain['sitename']);
$form['domain_batch'][$domain['domain_id']]['#subdomain'] = check_plain($domain['subdomain']);
if (isset($default[$domain['domain_id']])) {
$form['domain_batch'][$domain['domain_id']]['#default_value'] = $default[$domain['domain_id']];
}
}
$api_keys = array(
'variable',
'table',
'data_type',
);
// These are optional elements, only passed if present.
foreach ($api_keys as $key) {
if (isset($batch['#' . $key])) {
$form[$key] = array(
'#type' => 'value',
'#value' => $batch['#' . $key],
);
}
}
// Custom submit and validate handlers.
foreach (array(
'submit',
'validate',
) as $key) {
if (isset($batch['#' . $key])) {
$form[$key . '_handler'] = array(
'#type' => 'value',
'#value' => $batch['#' . $key],
);
}
}
$form['handler'] = array(
'#type' => 'value',
'#value' => $batch['#domain_action'],
);
$form['batch_item'] = array(
'#type' => 'value',
'#value' => $action,
);
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Update domain settings'),
);
return $form;
}