? 252877-execute.patch
? 319876-views.patch
? 405148-conf.patch
? 412156-no-switch.patch
Index: API.php
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/API.php,v
retrieving revision 1.45
diff -u -p -r1.45 API.php
--- API.php 21 Feb 2009 23:11:12 -0000 1.45
+++ API.php 25 Mar 2009 20:01:19 -0000
@@ -449,6 +449,9 @@ function hook_domainconf() {
* --- (-6) items used by Domain Theme.
* --- (-2) items reserved for batch delete actions.
*
+ * - '#group' [optional] Used to place elements into fieldsets for the main domain configuration page. If not set, any
+ * new element will be added to the 'Site configuration' fieldset.
+ *
* @ingroup domain_hooks
*/
function hook_domainbatch() {
@@ -469,6 +472,7 @@ function hook_domainbatch() {
'#validate' => 'domain_mysetting_validate',
'#data_type' => 'string',
'#weight' => 0,
+ '#group' => t('My settings'),
);
return $batch;
}
Index: domain_conf/domain_conf.admin.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_conf/domain_conf.admin.inc,v
retrieving revision 1.7
diff -u -p -r1.7 domain_conf.admin.inc
--- domain_conf/domain_conf.admin.inc 25 Mar 2009 17:31:44 -0000 1.7
+++ domain_conf/domain_conf.admin.inc 25 Mar 2009 20:01:20 -0000
@@ -28,7 +28,7 @@ function domain_conf_page($domain) {
$output = theme_domain_conf_reset($domain);
if ($domain['domain_id'] > 0) {
drupal_set_title(t('!site : Domain site settings', array('!site' => $domain['sitename'])));
- return $output . drupal_get_form('system_site_information_settings');
+ return $output . drupal_get_form('domain_conf_form', $domain);
}
else if ($domain['domain_id'] == 0) {
return $output . drupal_get_form('domain_conf_default', $domain);
@@ -36,6 +36,76 @@ function domain_conf_page($domain) {
}
/**
+ * Custom form to generate domain-specific site settings.
+ *
+ * The items on this form are taken from hook_domainbatch() and hook_domainconf().
+ * See the API for more information.
+ *
+ * @param $domain
+ * The domain currently being updated.
+ */
+function domain_conf_form($form_state, $domain) {
+ $form = array();
+ $batch = module_invoke_all('domainbatch');
+ $settings = array();
+ $data = db_result(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $domain['domain_id']));
+ if (!empty($data)) {
+ $settings = unserialize($data);
+ }
+ $default_group = t('Site configuration');
+ foreach ($batch as $key => $action) {
+ if ($action['#domain_action'] != 'domain_conf') {
+ continue;
+ }
+ if ($action['#form']['#type'] == 'select') {
+ $action['#form']['#options'] = array_merge(array(NULL => t('Use primary domain settings')), $action['#form']['#options']);
+ }
+ $group = isset($action['#group']) ? $action['#group'] : $default_group;
+ if (!isset($form[$group])) {
+ $form[$group] = array(
+ '#type' => 'fieldset',
+ '#title' => $group,
+ '#collapsible' => TRUE,
+ );
+ }
+ $form[$group][$key] = $action['#form'];
+ $form[$group][$key]['#default_value'] = isset($settings[$key]) ? $settings[$key] : $action['#system_default'];
+ // Change the path for the frontpage.
+ if ($key == 'site_frontpage') {
+ global $base_url;
+ $prefix = $base_url .'/';
+ $_path = parse_url($prefix);
+ $str = $_path['host'];
+ $fix = preg_replace("/$str/", $domain['subdomain'], $prefix, 1);
+ $form[$default_group]['site_frontpage']['#field_prefix'] = $fix;
+ }
+ }
+ $form['domain_id'] = array('#type' => 'value', '#value' => $domain['domain_id']);
+ // Site name must be edited at the domain creation screen.
+ $form[$default_group]['site_name'] = array(
+ '#disabled' => TRUE,
+ '#title' => t('Site name'),
+ '#description' => t('The name of this web site, as entered in the domain-specific settings.', array('!url' => url('admin/build/domain/edit/'. $domain['domain_id']))),
+ '#type' => 'textfield',
+ '#default_value' => $domain['sitename'],
+ '#weight' => -100,
+ );
+
+ // Grab any extra elements defined by other modules.
+ $extra = domain_conf_api(TRUE);
+ // Merge the $extra and $form arrays.
+ $form = array_merge($form, $extra);
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save domain settings'),
+ '#weight' => 10
+ );
+
+ return $form;
+}
+
+/**
* Special configuration options for the main domain.
*
* @param $domain
@@ -74,189 +144,16 @@ function domain_conf_default($domain) {
}
/**
- * The bulk of our hook_form_alter implementation.
- */
-function domain_conf_system(&$form, &$form_state, $form_id) {
- // We use the system_site_information_settings form as a base, and add the elements we need
- // from other forms. The default values are altered based on stored settings.
- $domain_id = arg(4);
- $domain = domain_lookup($domain_id);
- $data = db_result(db_query("SELECT settings FROM {domain_conf} WHERE domain_id = %d", $domain['domain_id']));
- if (!empty($data)) {
- $settings = unserialize($data);
- }
- else {
- $settings = array();
- }
- $unset = array('buttons', '#submit');
- foreach ($unset as $key) {
- unset($form[$key]);
- }
- $form['main'] = array(
- '#type' => 'fieldset',
- '#title' => t('Domain information'),
- '#collapsible' => TRUE,
- '#weight' => -10
- );
- // Put the defaults in the fieldset
- $fields = array('site_name', 'site_mail', 'site_slogan', 'site_mission', 'site_footer', 'site_frontpage', 'anonymous');
- foreach ($fields as $field) {
- $form['main'][$field] = $form[$field];
- unset($form[$field]);
- }
-
- // Change the path for the frontpage.
- $prefix = $form['main']['site_frontpage']['#field_prefix'];
- $_path = parse_url($prefix);
- $str = $_path['host'];
- $fix = preg_replace("/$str/", $domain['subdomain'], $prefix, 1);
- $form['main']['site_frontpage']['#field_prefix'] = $fix;
-
- // Admin theme settings
- $themes = list_themes();
- ksort($themes);
- $options[] = t('Use domain default theme');
- foreach ($themes as $key => $value) {
- $options[$key] = $key;
- }
- $form['main']['admin_theme'] = array(
- '#type' => 'select',
- '#title' => t('Administrative theme'),
- '#options' => $options,
- '#default_value' => variable_get('admin_theme', '0'),
- );
-
- // Menu settings: primary and secondary links.
- $form['menu'] = array(
- '#type' => 'fieldset',
- '#title' => t('Menu settings'),
- '#collapsible' => TRUE,
- '#weight' => -6
- );
-
- $menus = menu_get_menus();
-
- $form['menu']['menu_default_node_menu'] = array(
- '#type' => 'select',
- '#title' => t('Default menu for content'),
- '#default_value' => isset($settings['menu_default_node_menu']) ? $settings['menu_default_node_menu'] : variable_get('menu_default_node_menu', 'primary-links'),
- '#options' => $menus,
- '#description' => t('Choose the menu to be the default in the menu options in the content authoring form.'),
- );
-
- $menus[0] = t('Do not use for this site');
- $form['menu']['menu_primary_links_source'] = array(
- '#type' => 'select',
- '#title' => t('Primary links menu'),
- '#default_value' => isset($settings['menu_primary_links_source']) ? $settings['menu_primary_links_source'] : variable_get('menu_primary_links_source', 'primary-links'),
- '#options' => $menus,
- '#description' => t('Select the primary links for this site.')
- );
-
- $form['menu']['menu_secondary_links_source'] = array(
- '#type' => 'select',
- '#title' => t('Secondary links menu'),
- '#default_value' => isset($settings['menu_secondary_links_source']) ? $settings['menu_secondary_links_source'] : variable_get('menu_secondary_links_source', 'secondary-links'),
- '#options' => $menus,
- '#description' => t('Select the secondary links for this site.')
- );
-
- // Date settings: set the default timezone
- $form['date'] = array(
- '#type' => 'fieldset',
- '#title' => t('Timezone settings'),
- '#collapsible' => TRUE,
- '#weight' => -5
- );
- $zones = _system_zonelist();
- $form['date']['date_default_timezone'] = array(
- '#type' => 'select',
- '#title' => t('Default time zone'),
- '#default_value' => isset($settings['date_default_timezone']) ? $settings['date_default_timezone'] : variable_get('date_default_timezone', 0),
- '#options' => $zones,
- '#description' => t('Select the default site time zone.')
- );
-
- // Language settings, if needed.
- if (module_exists('locale') && variable_get('language_count', 1) > 1) {
- $form['language'] = array(
- '#type' => 'fieldset',
- '#title' => t('Language settings'),
- '#collapsible' => TRUE,
- '#weight' => 0,
- );
- $options = domain_conf_language_options();
- $default = language_default();
- $form['language']['language_default'] = array(
- '#type' => 'radios',
- '#title' => t('Default language'),
- '#options' => $options,
- '#default_value' => isset($settings['language_default']) ? $settings['language_default'] : $default->language,
- '#description' => t('The default language to use for this domain. Note: This setting only works with path-based language switching.'),
- );
- }
-
- // Offline notices.
- $form['offline'] = array(
- '#type' => 'fieldset',
- '#title' => t('Maintenance settings'),
- '#collapsible' => TRUE,
- '#weight' => 5
- );
- $form['offline']['site_offline'] = array(
- '#type' => 'radios',
- '#title' => t('Site status'),
- '#default_value' => isset($settings['site_offline']) ? $settings['site_offline'] : variable_get('site_offline', 0),
- '#options' => array(t('Online'), t('Off-line')),
- '#description' => t('When set to "Online", all visitors will be able to browse your site normally. When set to "Off-line", only users with the "administer site configuration" permission will be able to access your site to perform maintenance; all other visitors will see the site off-line message configured below. Authorized users can log in during "Off-line" mode directly via the user login page.', array('@user-login' => url('user'))),
- );
-
- $form['offline']['site_offline_message'] = array(
- '#type' => 'textarea',
- '#title' => t('Site off-line message'),
- '#default_value' => isset($settings['site_offline_message']) ? $settings['site_offline_message'] : variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => $domain['sitename']))),
- '#description' => t('Message to show visitors when the site is in off-line mode.')
- );
-
- // Site name must be edited at the domain creation screen.
- $form['main']['site_name']['#disabled'] = TRUE;
- $form['main']['site_name']['#description'] = t('The name of this web site, as entered in the domain-specific settings.', array('!url' => url('admin/build/domain/edit/'. $domain['domain_id'])));
-
- // Reset the provided form defaults, if needed
- $form['main']['site_name']['#value'] = $domain['sitename'];
- $form['main']['site_mail']['#default_value'] = isset($settings['site_mail']) ? $settings['site_mail'] : variable_get('site_mail', ini_get('sendmail_from'));
- $form['main']['site_slogan']['#default_value'] = isset($settings['site_slogan']) ? $settings['site_slogan'] : variable_get('site_slogan', '');
- $form['main']['site_mission']['#default_value'] = isset($settings['site_mission']) ? $settings['site_mission'] : variable_get('site_mission', '');
- $form['main']['site_footer']['#default_value'] = isset($settings['site_footer']) ? $settings['site_footer'] : variable_get('site_footer', '');
- $form['main']['site_frontpage']['#default_value'] = isset($settings['site_frontpage']) ? $settings['site_frontpage'] : variable_get('site_frontpage', 'node');
- $form['main']['anonymous']['#default_value'] = isset($settings['anonymous']) ? $settings['anonymous'] : variable_get('anonymous', t('Guest'));
-
- // Domain information, for saving.
- $form['domain_id'] = array('#type' => 'value', '#value' => $domain['domain_id']);
-
- // Grab any extra elements defined by other modules.
- $extra = domain_conf_api(TRUE);
- // Merge the $extra and $form arrays.
- $form = array_merge($form, $extra);
-
- // Submit functions
- $form['#submit'][] = 'domain_conf_form_submit';
- $form['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save domain settings'),
- '#weight' => 10
- );
-}
-
-/**
* FormsAPI for domain_conf_form().
*/
function domain_conf_form_submit($form, &$form_state) {
// Throw away what we don't need.
- $settings = $form_state['values'];
- $unset = array('form_token', 'form_id', 'form_build_id', 'op', 'submit');
- foreach ($unset as $key) {
- unset($settings[$key]);
+ $ignore = array('form_token', 'form_id', 'form_build_id', 'op', 'submit', 'domain_id');
+ foreach ($form_state['values'] as $key => $value) {
+ if (in_array($key, $ignore) || empty($value)) {
+ continue;
+ }
+ $settings[$key] = $value;
}
// INSERT or UPDATE?
$check = 0;
Index: domain_conf/domain_conf.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/domain/domain_conf/domain_conf.module,v
retrieving revision 1.39
diff -u -p -r1.39 domain_conf.module
--- domain_conf/domain_conf.module 25 Mar 2009 13:54:55 -0000 1.39
+++ domain_conf/domain_conf.module 25 Mar 2009 20:01:21 -0000
@@ -125,23 +125,6 @@ function domain_conf_domainlinks($domain
}
/**
- * Implements hook_form_alter()
- *
- * Since this function is only loaded at the path admin/build/domain/conf, we
- * don't have to worry about hook_form_alter() being called when not wanted.
- */
-function domain_conf_form_alter(&$form, &$form_state, $form_id) {
- // TODO: Replace with hook_domainbatch()?
- // Check to be certain that we are on the right form page.
- $module = arg(2);
- $action = arg(3);
- // If we are making the form, load our alterations.
- if ($form_id == 'system_site_information_settings' && $module == 'domain' && $action == 'conf') {
- domain_conf_system($form, $form_state, $form_id);
- }
-}
-
-/**
* Implements hook_domainwarnings()
*/
function domain_conf_domainwarnings() {
@@ -191,6 +174,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the email address for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Site configuration'),
);
// Change the site slogan.
$batch['site_slogan'] = array(
@@ -207,6 +191,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the site slogan for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Site configuration'),
);
// Change the site slogan.
$batch['site_mission'] = array(
@@ -223,6 +208,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the site mission for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Site configuration'),
);
// Change the site footer.
$batch['site_footer'] = array(
@@ -239,6 +225,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the site footer for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Site configuration'),
);
// Change the site frontpage.
$batch['site_frontpage'] = array(
@@ -255,6 +242,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the site frontpage for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Site configuration'),
);
// Change the anonymous user name.
$batch['anonymous'] = array(
@@ -271,6 +259,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the anonymous user label for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Site configuration'),
);
// Change the administrative theme.
$themes = list_themes();
@@ -292,6 +281,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the administrative theme for all domains.'),
'#data_type' => 'string',
'#weight' => -8,
+ '#group' => t('Administrative theme'),
);
// Change the menus
$menus = menu_get_menus();
@@ -308,6 +298,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the default menu options for the content authoring form in all domains.'),
'#data_type' => 'string',
'#weight' => -6,
+ '#group' => t('Menu settings'),
);
$menus[0] = t('Do not use for this site');
$batch['menu_primary_links_source'] = array(
@@ -323,6 +314,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the primary links menu in all domains.'),
'#data_type' => 'string',
'#weight' => -6,
+ '#group' => t('Menu settings'),
);
$batch['menu_secondary_links_source'] = array(
'#form' => array(
@@ -337,6 +329,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the secondary links menu in all domains.'),
'#data_type' => 'string',
'#weight' => -6,
+ '#group' => t('Menu settings'),
);
// Change the timezone.
$zones = _system_zonelist();
@@ -353,6 +346,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the default timezone for all domains.'),
'#data_type' => 'string',
'#weight' => -4,
+ '#group' => t('Timezone settings'),
);
// Change the default language.
$languages = domain_conf_language_options();
@@ -371,6 +365,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the default language for all domains.'),
'#data_type' => 'string',
'#weight' => -3,
+ '#group' => t('Language settings'),
);
// Toggle the site offline status.
$batch['site_offline'] = array(
@@ -386,6 +381,7 @@ function domain_conf_domainbatch() {
'#meta_description' => t('Set the online / offline status for all domains.'),
'#data_type' => 'integer',
'#weight' => -2,
+ '#group' => t('Site status'),
);
// Change the site offline message.
$batch['site_offline_message'] = array(
@@ -397,11 +393,12 @@ function domain_conf_domainbatch() {
'#description' => t('Message to show visitors when this domain is in off-line mode.'),
),
'#domain_action' => 'domain_conf',
- '#system_default' => variable_get('site_offline_message', ''),
+ '#system_default' => t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))),
'#variable' => 'site_offline_message',
'#meta_description' => t('Set the site offline message for all domains.'),
'#data_type' => 'string',
'#weight' => -2,
+ '#group' => t('Site status'),
);
return $batch;
}