From 44740785fe811c86a64890e37faacf5cdf52e4ea Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 16 Jul 2009 10:44:21 +0000 Subject: - Patch #518750 by Damien Tournoud: rethink system settings form. --- modules/system/system.admin.inc | 18 ++++-------------- modules/system/system.module | 20 +++++--------------- modules/system/system.test | 11 ++++++++--- 3 files changed, 17 insertions(+), 32 deletions(-) (limited to 'modules/system') diff --git a/modules/system/system.admin.inc b/modules/system/system.admin.inc index 4bb1129bd..6ac8d2fe8 100644 --- a/modules/system/system.admin.inc +++ b/modules/system/system.admin.inc @@ -227,10 +227,6 @@ function system_themes_form() { '#type' => 'submit', '#value' => t('Save configuration'), ); - $form['buttons']['reset'] = array( - '#type' => 'submit', - '#value' => t('Reset to defaults'), - ); return $form; } @@ -513,16 +509,10 @@ function system_theme_settings_submit($form, &$form_state) { $values = $form_state['values']; $key = $values['var']; - if ($values['op'] == t('Reset to defaults')) { - variable_del($key); - drupal_set_message(t('The configuration options have been reset to their default values.')); - } - else { - // Exclude unnecessary elements before saving. - unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']); - variable_set($key, $values); - drupal_set_message(t('The configuration options have been saved.')); - } + // Exclude unnecessary elements before saving. + unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']); + variable_set($key, $values); + drupal_set_message(t('The configuration options have been saved.')); cache_clear_all(); } diff --git a/modules/system/system.module b/modules/system/system.module index e05e27e5d..ccfce5370 100644 --- a/modules/system/system.module +++ b/modules/system/system.module @@ -2033,7 +2033,6 @@ function _system_settings_form_automatic_defaults($form) { */ function system_settings_form($form, $automatic_defaults = TRUE) { $form['buttons']['submit'] = array('#type' => 'submit', '#value' => t('Save configuration') ); - $form['buttons']['reset'] = array('#type' => 'submit', '#value' => t('Reset to defaults') ); if ($automatic_defaults) { $form = _system_settings_form_automatic_defaults($form); @@ -2060,23 +2059,14 @@ function system_settings_form_submit($form, &$form_state) { unset($form_state['values']['submit'], $form_state['values']['reset'], $form_state['values']['form_id'], $form_state['values']['op'], $form_state['values']['form_token'], $form_state['values']['form_build_id']); foreach ($form_state['values'] as $key => $value) { - if ($op == t('Reset to defaults')) { - variable_del($key); + if (is_array($value) && isset($form_state['values']['array_filter'])) { + $value = array_keys(array_filter($value)); } - else { - if (is_array($value) && isset($form_state['values']['array_filter'])) { - $value = array_keys(array_filter($value)); - } - variable_set($key, $value); - } - } - if ($op == t('Reset to defaults')) { - drupal_set_message(t('The configuration options have been reset to their default values.')); - } - else { - drupal_set_message(t('The configuration options have been saved.')); + variable_set($key, $value); } + drupal_set_message(t('The configuration options have been saved.')); + cache_clear_all(); drupal_theme_rebuild(); } diff --git a/modules/system/system.test b/modules/system/system.test index 78f5634a7..4d40465ef 100644 --- a/modules/system/system.test +++ b/modules/system/system.test @@ -539,7 +539,7 @@ class AccessDeniedTestCase extends DrupalWebTestCase { // Log back in and remove the custom 403 page. $this->drupalLogin($this->admin_user); - $this->drupalPost('admin/settings/site-information', array(), t('Reset to defaults')); + $this->drupalPost('admin/settings/site-information', array('site_403' => ''), t('Save configuration')); // Logout and check that the user login block is shown on default 403 pages. $this->drupalLogout(); @@ -600,7 +600,7 @@ class PageNotFoundTestCase extends DrupalWebTestCase { // Log back in and remove the custom 404 page. $this->drupalLogin($this->admin_user); - $this->drupalPost('admin/settings/site-information', array(), t('Reset to defaults')); + $this->drupalPost('admin/settings/site-information', array('site_404' => ''), t('Save configuration')); // Logout and check that the user login block is not shown on default 404 pages. $this->drupalLogout(); @@ -961,7 +961,12 @@ class SystemThemeFunctionalTest extends DrupalWebTestCase { $this->assertRaw('themes/stark', t('Site default theme used on the add content page.')); // Reset to the default theme settings. - $this->drupalPost('admin/build/themes', array(), t('Reset to defaults')); + $edit = array( + 'theme_default' => 'garland', + 'admin_theme' => '0', + 'node_admin_theme' => FALSE, + ); + $this->drupalPost('admin/build/themes', $edit, t('Save configuration')); $this->drupalGet('admin'); $this->assertRaw('themes/garland', t('Site default theme used on administration page.')); -- cgit v1.2.3