hook_domainbatch()Allows modules to expose batch editing functions.
This hook makes it easier for site administrators to perform bulk updates. It is most useful for handling settings changes caused by moving from a staging to a production server.
The function works by defining a $batch array that serves as a combination of menu hook and form element. The $batch array contains all the information needed to create an administrative page and form that will process your settings.
For a basic example, see domain_domainbatch().
For a more complex example, with custom processing, see domain_theme_domainbatch().
The $batch array is formatted according to the following rules:
values defined by the FormsAPI. Do not, however, pass the #default_value element here. That value will be computed dynamically for each domain when the hook is processed.
Typically, this will be the result of a variable_get(). For domain_delete operations, this value should be set to zero (0).
Use this when complex variables do not allow a normal usage.
--- 'domain' == writes the value to the {domain} table. Normally, contributed modules will not use this option. --- 'domain_conf' == writes the value to the {domain_conf} table. Use in connection with hook_domainconf(). --- 'domain_delete' == used to delete rows from specific tables. If this is used, the #table value must be present. --- 'custom' == used if you need your own submit handler. Must be paired with a #submit parameter.
should be a valid function name. It will be passed the $form_values array for processing.
should be a valid function name. It will be passed the $form_values array for processing.
This value should be a valid function name. Your function must accept the $domain array as a parameter.
This value may be a string or an array, if you need to perform multiple deletes. Deletes are performed against the domain_id of the selected domains.
value is not set, the root domain will not be exposed for batch editing.
--- 'string' == the query will use '%s' to insert the data. --- 'integer' == the query will use %d to insert the data. --- 'float' == the query will use %f to insert the data. --- 'binary' == the query will use %b to insert the data. For more information, see db_query() in the Drupal API documentation.
are reserved for use by the core Domain Access module. The following values are in use: --- (-10) items used by Domain Access core. --- (-8) items used by Domain Configuration. --- (-6) items used by Domain Theme. --- (-2) items reserved for batch delete actions.
set to TRUE in most cases. If your value must be unique per domain, set this to FALSE or leave empty.
./API.php, line 516
<?php
function hook_domainbatch() {
// A simple function to rename my setting in Domain Configuration.
$batch = array();
$batch['mysetting'] = array(
'#form' => array(
'#title' => t('My Settings'),
'#type' => 'textfield',
'#size' => 40,
'#maxlength' => 80,
'#description' => t('A description for the form'),
'#required' => TRUE,
),
'#domain_action' => 'domain_conf',
'#meta_description' => t('Edit my setting value.'),
'#variable' => 'domain_mysetting',
'#validate' => 'domain_mysetting_validate',
'#data_type' => 'string',
'#weight' => 0,
'#group' => t('My settings'),
'#update_all' => TRUE,
'#module' => t('Domain Access'),
);
return $batch;
}
?>
Buy your copy of Drupal 7 Module Development today!
It includes my detailed chapter on Node Access in Drupal 7.