domain_configure_form($user_submitted = FALSE)
domain_admin.inc, line 121
FormsAPI for configuring the domain module.
function domain_configure_form($user_submitted = FALSE) {
$form = array();
$form['domain'] = array(
'#type' => 'fieldset',
'#title' => t('Default domain settings'),
'#collapsible' => TRUE
);
$form['#redirect'] = 'admin/build/domain';
$sitename = variable_get('sitename', 'Drupal');
$form['domain']['domain_root'] = array(
'#type' => 'textfield',
'#title' => t('Primary domain name'),
'#size' => 40,
'#maxlength' => 80,
'#required' => TRUE,
'#default_value' => variable_get('domain_root', ''),
'#description' => t('The primary domain for your site. Typically <em>example.com</em> or <em>www.example.com</em>. Do not use http or slashes.
<br />This domain will be used as the default URL for your site.
<br />If an invalid domain is requested, users will be sent to the primary domain.')
);
$form['domain']['domain_sitename'] = array(
'#type' => 'textfield',
'#title' => t('Site name'),
'#size' => 40,
'#maxlength' => 80,
'#required' => TRUE,
'#default_value' => variable_get('domain_sitename', $sitename),
'#description' => t('The site name to display for this domain.')
);
$form['domain']['domain_scheme'] = array(
'#type' => 'radios',
'#title' => t('Domain URL scheme'),
'#required' => TRUE,
'#options' => array('http' => 'http://', 'https' => 'https://'),
'#default_value' => variable_get('domain_scheme', 'http'),
'#description' => t('The URL scheme for accessing the primary domain.')
);
$form['domain_behavior'] = array(
'#type' => 'fieldset',
'#title' => t('Domain module behaviors'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['domain_behavior']['domain_behavior'] = array(
'#type' => 'radios',
'#title' => t('New content settings'),
'#required' => TRUE,
'#default_value' => variable_get('domain_behavior', DOMAIN_INSTALL_RULE),
'#options' => array(1 => t('Show on all affiliate sites'), 2 => t('Only show on selected sites')),
'#description' => t('If set, this value will automatically assign new content to all sites. <a href="!url">Node-type specific settings</a> are also available.', array('!url' => url('admin/build/domain/advanced')))
);
$form['domain_behavior']['domain_options'] = array(
'#type' => 'radios',
'#title' => t('Content editing forms'),
'#required' => TRUE,
'#default_value' => variable_get('domain_options', 0),
'#options' => array(
0 => t('Pass the default form values as hidden fields'),
1 => t('Take user to the default domain'),
2 => t('Take user to their assigned domain'),
3 => t('Show user their publishing options')),
'#description' => t('Controls the behavior of forms for users with the <em>view domain publishing</em> permission when creating or editing content. See the README for more details.')
);
$form['domain_behavior']['domain_debug'] = array(
'#type' => 'radios',
'#title' => t('Debugging status'),
'#required' => TRUE,
'#default_value' => variable_get('domain_debug', 0),
'#options' => array(0 => t('Do not show debugging output'), 1 => t('Show debugging output on node view')),
'#description' => t('If set, users with the <em>set domain access</em> permission will be able to view the node access rules for each node. See the README for more details.')
);
$options = array(
'id' => t('Creation order, oldest > newest'),
'rid' => t('Creation order, newest > oldest'),
'name' => t('Sitename, A > Z'),
'rname' => t('Sitename, Z > A'),
'url' => t('URL, A > Z'),
'rurl' => t('URL, Z > A')
);
$form['domain_behavior']['domain_sort'] = array(
'#type' => 'radios',
'#title' => t('Sort domain lists'),
'#required' => TRUE,
'#default_value' => variable_get('domain_sort', 'id'),
'#options' => $options,
'#description' => t('Controls the display of domain lists to end users.')
);
$form['domain_advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced settings'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['domain_advanced']['domain_editors'] = array(
'#type' => 'radios',
'#title' => t('Domain-based editing controls'),
'#default_value' => variable_get('domain_editors', intval(DOMAIN_EDITOR_RULE)),
'#options' => array(0 => t('Do not use access control for editors'), 1 => t('Use access control for editors')),
'#description' => t('If set, users with the <em>edit domain nodes</em> permission will be able to edit all nodes assigned to their domain.')
);
// When turning on and off editing rules, we rebuild part of the node_access table.
$form['#submit']['domain_admin_editor_form'] = array();
$form['domain_editors_status'] = array('#type' => 'value', '#value' => variable_get('domain_editors', 0));
// Adding this submit behavior disabled the default, so we add that explictly.
$form['#submit']['system_settings_form_submit'] = array();
// Check to see if the node_access patch is enabled. If it is, then
// we need to know if more than one node_access module is running.
$modules = count(module_implements('node_grants'));
if (!function_exists('node_access_grants_sql') || $modules < 2) {
$disabled = TRUE;
variable_set('domain_access_rules', 0);
}
// Do not show this form element unless it is necessary
if ($modules > 1) {
$form['domain_advanced']['domain_access_rules'] = array(
'#type' => 'radios',
'#title' => t('Node access settings'),
'#disabled' => $disabled,
'#default_value' => variable_get('domain_access_rules', 0),
'#options' => array(0 => t('Use the default Drupal behavior (OR)'), 1 => t('Check Domain Access in addition to other modules (AND)')),
'#description' => t('Controls how Domain Access interacts with access control modules such as Organic Groups. Requires the multiple_node_access patch.')
);
}
// Check to see if the hook_url_alter() patch is installed.
$disabled = FALSE;
if (url('domain_access_test_path') != url('domain_access_path_test')) {
$disabled = TRUE;
variable_set('domain_search', 0);
variable_set('domain_seo', 0);
}
$form['domain_advanced']['domain_search'] = array(
'#type' => 'radios',
'#title' => t('Search settings'),
'#disabled' => $disabled,
'#default_value' => variable_get('domain_search', 0),
'#options' => array(0 => t('Search content for the current domain only'), 1 => t('Search all domains from any URL')),
'#description' => t('Options for content searching. This feature requires the hook_url_alter() patch.')
);
$form['domain_advanced']['domain_seo'] = array(
'#type' => 'radios',
'#title' => t('Search engine optimization'),
'#disabled' => $disabled,
'#default_value' => variable_get('domain_seo', 0),
'#options' => array(0 => t('Do not rewrite URLs'), 1 => t('Rewrite all URLs to point to a single source')),
'#description' => t('If rewrite is turned on, all node links will point to a single instance of the node. This
option reduces the chance that search engines will recognize duplicate content.
This feature requires the hook_url_alter() patch.')
);
$options = array();
foreach (domain_domains() as $data) {
// The domain must be valid.
if ($data['valid']) {
$options[$data['domain_id']] = $data['sitename'];
}
}
$form['domain_advanced']['domain_default_source'] = array(
'#type' => 'select',
'#title' => t('Default source domain'),
'#options' => $options,
'#default_value' => variable_get('domain_default_source', 0),
'#description' => t('When rewriting urls, nodes assigned to all affiliates will be sent to this domain.'),
);
$form['domain_advanced']['domain_www'] = array(
'#type' => 'radios',
'#title' => t('WWW prefix handling'),
'#default_value' => variable_get('domain_www', 0),
'#options' => array(0 => t('Process all host requests normally'), 1 => t('Treat www.*.example.com as an alias of *.example.com')),
'#description' => t('If set, calls to www.* will be treated as if the www. did not exist.')
);
$form['domain_all'] = array(
'#type' => 'fieldset',
'#title' => t('Special page requests'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['domain_all']['domain_grant_all'] = array(
'#type' => 'textarea',
'#rows' => 5,
'#cols' => 40,
'#default_value' => variable_get('domain_grant_all', "user/*/track"),
'#description' => t('Content on these pages should be viewable on any domain. Enter one path per line.
You may use the * as a wildcard. Use this for aggregate pages like those provided by <a href="!url">MySite</a> or if you
intend to show all user posts on a specific page. See the README for more details.', array('!url' => 'http://drupal.org/project/mysite'))
);
$form['domain_all']['domain_cron_rule'] = array(
'#type' => 'checkbox',
'#default_value' => variable_get('domain_cron_rule', 1),
'#title' => t('Treat cron.php as a special page request.'),
'#description' => t('Normally, you should leave this setting active. See the README for more information.')
);
// The hook_url_alter() patch must be present for these settings to be applied.
if (!$disabled) {
$form['domain_paths'] = array(
'#type' => 'fieldset',
'#title' => t('Node link patterns'),
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['domain_paths']['domain_paths'] = array(
'#type' => 'textarea',
'#rows' => 5,
'#cols' => 40,
'#default_value' => variable_get('domain_paths', "node/%n\r\nnode/%n/edit\r\ncomment/reply/%n\r\nnode/add/book/parent/%n\r\nbook/export/html/%n"),
'#description' => t('When using SEO or other path rewrites, the following link paths should be turned into absolute URLs. Enter
the Drupal path of the link, using the <em>%n</em> placeholder to represent the node id.
Enter one path per line. See the README for more details.')
);
}
// Allow submodules to add elements to the form.
$modules = module_implements('domainform');
if (!empty($modules)) {
foreach ($modules as $module) {
$func = $module .'_domainform';
$func($form);
}
}
return system_settings_form($form);
}