Commit 44740785 authored by Dries's avatar Dries

- Patch #518750 by Damien Tournoud: rethink system settings form.

parent 436fc4f8
......@@ -293,8 +293,7 @@ function color_scheme_form_submit($form, &$form_state) {
}
// Don't render the default colorscheme, use the standard theme instead.
if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)
|| $form_state['values']['op'] == t('Reset to defaults')) {
if (implode(',', color_get_palette($theme, TRUE)) == implode(',', $palette)) {
variable_del('color_' . $theme . '_palette');
variable_del('color_' . $theme . '_stylesheets');
variable_del('color_' . $theme . '_logo');
......
......@@ -229,13 +229,6 @@ function node_type_form(&$form_state, $type = NULL) {
);
}
}
else {
$form['reset'] = array(
'#type' => 'submit',
'#value' => t('Reset to defaults'),
'#weight' => 50,
);
}
return $form;
}
......@@ -310,10 +303,7 @@ function node_type_form_submit($form, &$form_state) {
$type->modified = TRUE;
$type->locked = $form_state['values']['locked'];
if ($op == t('Reset to defaults')) {
node_type_reset($type);
}
elseif ($op == t('Delete content type')) {
if ($op == t('Delete content type')) {
$form_state['redirect'] = 'admin/build/node-type/' . str_replace('_', '-', $type->old_type) . '/delete';
return;
}
......@@ -337,29 +327,19 @@ function node_type_form_submit($form, &$form_state) {
$variable_new = $key . '_' . $type->type;
$variable_old = $key . '_' . $type->old_type;
if ($op == t('Reset to defaults')) {
variable_del($variable_old);
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
else {
if (is_array($value)) {
$value = array_keys(array_filter($value));
}
variable_set($variable_new, $value);
variable_set($variable_new, $value);
if ($variable_new != $variable_old) {
variable_del($variable_old);
}
if ($variable_new != $variable_old) {
variable_del($variable_old);
}
}
node_types_rebuild();
$t_args = array('%name' => $type->name);
if ($op == t('Reset to defaults')) {
drupal_set_message(t('The content type %name has been reset to its default values.', $t_args));
return;
}
if ($status == SAVED_UPDATED) {
drupal_set_message(t('The content type %name has been updated.', $t_args));
}
......
......@@ -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();
}
......
......@@ -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();
}
......
......@@ -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.'));
......
......@@ -91,18 +91,14 @@ function update_settings_validate($form, &$form_state) {
function update_settings_submit($form, $form_state) {
$op = $form_state['values']['op'];
if ($op == t('Reset to defaults')) {
unset($form_state['notify_emails']);
if (empty($form_state['notify_emails'])) {
variable_del('update_notify_emails');
}
else {
if (empty($form_state['notify_emails'])) {
variable_del('update_notify_emails');
}
else {
variable_set('update_notify_emails', $form_state['notify_emails']);
}
unset($form_state['notify_emails']);
unset($form_state['values']['update_notify_emails']);
variable_set('update_notify_emails', $form_state['notify_emails']);
}
unset($form_state['notify_emails']);
unset($form_state['values']['update_notify_emails']);
system_settings_form_submit($form, $form_state);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment