function domain_prefix_configure_form in Domain Access 5
Same name and namespace in other branches
- 6.2 domain_prefix/domain_prefix.admin.inc \domain_prefix_configure_form()
FormsAPI for generating the configuration form
2 string references to 'domain_prefix_configure_form'
- domain_prefix_form in domain_prefix/
domain_prefix.module - The table prefixing page for a domain.
- domain_prefix_menu in domain_prefix/
domain_prefix.module - Implement hook_menu()
File
- domain_prefix/
domain_prefix.module, line 151 - Interface for selective table prefixing for use with Domain Access. For this module to work correctly, you will need to follow the INSTALL.txt instructions for editing your settings.php file.
Code
function domain_prefix_configure_form() {
// We must be on the root domain!
$default = domain_default();
domain_goto($default);
// Get the tables for the root installation.
$tables = domain_prefix_get_tables($prefix);
// Remove the disallowed tables.
$disallow = domain_prefix_disallow();
// Get the current settings.
$info = unserialize(variable_get('domain_prefix', NULL));
$settings = $info['settings'];
$source_defaults = $info['sources'];
$form = array();
$form['domain'] = array(
'#type' => 'fieldset',
'#title' => t('Domain creation rules'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
);
$form['domain']['domain_prefix_options'] = array(
'#type' => 'radios',
'#title' => t('Domain creation options'),
'#description' => t('Determines what actions to take when creating new domain records.'),
'#options' => array(
1 => t('Generate tables as defined below'),
0 => t('Do not generate any tables'),
),
'#default_value' => variable_get('domain_prefix_options', 1),
'#required' => TRUE,
);
$last = '';
// Flag for module grouping.
// Get the source table data.
$root = domain_default();
foreach ($tables as $table => $info) {
if (!in_array($table, $disallow) && substr($table, 0, 7) != 'domain_') {
if (empty($settings[$table])) {
$settings[$table] = DOMAIN_PREFIX_IGNORE;
$source_defaults['_source_' . $table] = 0;
}
$module = $info['module'];
if ($last != $module) {
$last = $module;
}
else {
$module = '';
}
$options = array();
$options[DOMAIN_PREFIX_IGNORE] = t('ignore');
$options[DOMAIN_PREFIX_CREATE] = t('create');
$options[DOMAIN_PREFIX_COPY] = t('copy');
$form['domain_prefix'][$table] = array(
'#type' => 'radios',
'#title' => $table,
'#options' => $options,
'#default_value' => $settings[$table],
'#description' => $module,
);
// Get the table copying options for this entry.
// Can't pass a zero through FormAPI select.
$sources = array();
$sources[0] = $root['sitename'];
// Check to see if other table prefixes have been created.
$result = db_query("SELECT dp.domain_id, d.sitename FROM {domain_prefix} dp INNER JOIN {domain} d ON dp.domain_id = d.domain_id WHERE dp.tablename = '%s' AND dp.status > 1", $table);
while ($data = db_fetch_array($result)) {
$sources[$data['domain_id']] = $data['sitename'];
}
$form['domain_source']['_source_' . $table] = array(
'#type' => 'select',
'#title' => '',
'#options' => $sources,
'#default_value' => $source_defaults['_source_' . $table],
);
}
}
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Save prefix settings'),
);
$form['restore'] = array(
'#type' => 'submit',
'#value' => t('Restore defaults'),
);
return $form;
}