=== modified file 'modules/blogapi/blogapi.module' --- modules/blogapi/blogapi.module 2008-12-08 22:00:03 +0000 +++ modules/blogapi/blogapi.module 2008-12-25 09:25:57 +0000 @@ -805,7 +805,7 @@ ); } - return system_settings_form($form); + return system_settings_form($form, FALSE); } /** === modified file 'modules/book/book.admin.inc' --- modules/book/book.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/book/book.admin.inc 2008-12-25 09:27:21 +0000 @@ -31,7 +31,7 @@ $form['book_allowed_types'] = array( '#type' => 'checkboxes', '#title' => t('Allowed book outline types'), - '#default_value' => variable_get('book_allowed_types', array('book')), + '#default_value' => array('book'), '#options' => $types, '#description' => t('Select content types which users with the %add-perm permission will be allowed to add to the book hierarchy. Users with the %outline-perm permission can add all content types.', array('%add-perm' => t('add content to books'), '%outline-perm' => t('administer book outlines'))), '#required' => TRUE, @@ -39,7 +39,7 @@ $form['book_child_type'] = array( '#type' => 'radios', '#title' => t('Default child page type'), - '#default_value' => variable_get('book_child_type', 'book'), + '#default_value' => 'book', '#options' => $types, '#description' => t('The content type for the %add-child link must be one of those selected as an allowed book outline type.', array('%add-child' => t('Add child page'))), '#required' => TRUE, @@ -47,7 +47,7 @@ $form['array_filter'] = array('#type' => 'value', '#value' => TRUE); $form['#validate'][] = 'book_admin_settings_validate'; - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** === modified file 'modules/contact/contact.admin.inc' --- modules/contact/contact.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/contact/contact.admin.inc 2008-12-25 09:35:33 +0000 @@ -146,20 +146,20 @@ function contact_admin_settings() { $form['contact_form_information'] = array('#type' => 'textarea', '#title' => t('Additional information'), - '#default_value' => variable_get('contact_form_information', t('You can leave a message using the contact form below.')), + '#default_value' => t('You can leave a message using the contact form below.'), '#description' => t('Information to show on the contact page. Can be anything from submission guidelines to your postal address or telephone number.', array('@form' => url('contact'))), ); $form['contact_hourly_threshold'] = array('#type' => 'select', '#title' => t('Hourly threshold'), '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50)), - '#default_value' => variable_get('contact_hourly_threshold', 3), + '#default_value' => 3, '#description' => t('The maximum number of contact form submissions a user can perform per hour.'), ); $form['contact_default_status'] = array( '#type' => 'checkbox', '#title' => t('Enable personal contact form by default'), - '#default_value' => variable_get('contact_default_status', 1), + '#default_value' => 1, '#description' => t('Default status of the personal contact form for new users.'), ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } === modified file 'modules/dblog/dblog.admin.inc' --- modules/dblog/dblog.admin.inc 2008-12-24 11:00:04 +0000 +++ modules/dblog/dblog.admin.inc 2008-12-25 09:31:08 +0000 @@ -16,12 +16,12 @@ $form['dblog_row_limit'] = array( '#type' => 'select', '#title' => t('Discard log entries above the following row limit'), - '#default_value' => variable_get('dblog_row_limit', 1000), + '#default_value' => 1000, '#options' => drupal_map_assoc(array(100, 1000, 10000, 100000, 1000000)), '#description' => t('The maximum number of rows to keep in the database log. Older entries will be automatically discarded. (Requires a correctly configured cron maintenance task.)', array('@cron' => url('admin/reports/status'))) ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** === modified file 'modules/filter/filter.admin.inc' --- modules/filter/filter.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/filter/filter.admin.inc 2008-12-25 09:31:41 +0000 @@ -324,7 +324,7 @@ } if (!empty($form)) { - $form = system_settings_form($form); + $form = system_settings_form($form, TRUE); } else { $form['error'] = array('#markup' => t('No settings are available.')); === modified file 'modules/forum/forum.admin.inc' --- modules/forum/forum.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/forum/forum.admin.inc 2008-12-25 09:26:45 +0000 @@ -191,25 +191,25 @@ $number = drupal_map_assoc(array(5, 10, 15, 20, 25, 30, 35, 40, 50, 60, 80, 100, 150, 200, 250, 300, 350, 400, 500)); $form['forum_hot_topic'] = array('#type' => 'select', '#title' => t('Hot topic threshold'), - '#default_value' => variable_get('forum_hot_topic', 15), + '#default_value' => 15, '#options' => $number, '#description' => t('The number of posts a topic must have to be considered "hot".'), ); $number = drupal_map_assoc(array(10, 25, 50, 75, 100)); $form['forum_per_page'] = array('#type' => 'select', '#title' => t('Topics per page'), - '#default_value' => variable_get('forum_per_page', 25), + '#default_value' => 25, '#options' => $number, '#description' => t('Default number of forum topics displayed per page.'), ); $forder = array(1 => t('Date - newest first'), 2 => t('Date - oldest first'), 3 => t('Posts - most active first'), 4 => t('Posts - least active first')); $form['forum_order'] = array('#type' => 'radios', '#title' => t('Default order'), - '#default_value' => variable_get('forum_order', '1'), + '#default_value' => '1', '#options' => $forder, '#description' => t('Default display order for topics.'), ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** === modified file 'modules/menu/menu.admin.inc' --- modules/menu/menu.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/menu/menu.admin.inc 2008-12-25 09:34:43 +0000 @@ -607,7 +607,7 @@ $form['menu_default_node_menu'] = array( '#type' => 'select', '#title' => t('Default menu for content'), - '#default_value' => variable_get('menu_default_node_menu', 'main-menu'), + '#default_value' => 'main-menu', '#options' => $menu_options, '#description' => t('Choose the menu to be the default in the menu options in the content authoring form.'), ); @@ -627,11 +627,11 @@ $form["menu_secondary_links_source"] = array( '#type' => 'select', '#title' => t('Source for the Secondary links'), - '#default_value' => variable_get('menu_secondary_links_source', 'secondary-menu'), + '#default_value' => 'secondary-menu', '#options' => $secondary_options, '#tree' => FALSE, '#description' => t("Select the source for the Secondary links. An advanced option allows you to use the same source for both Main links (currently %main) and Secondary links: if your source menu has two levels of hierarchy, the top level menu links will appear in the Main links, and the children of the active link will appear in the Secondary links." , array('%main' => $main_options[$main])), ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } === modified file 'modules/node/node.admin.inc' --- modules/node/node.admin.inc 2008-12-20 19:00:05 +0000 +++ modules/node/node.admin.inc 2008-12-25 09:28:55 +0000 @@ -30,12 +30,14 @@ } $form['default_nodes_main'] = array( - '#type' => 'select', '#title' => t('Number of posts on main page'), '#default_value' => variable_get('default_nodes_main', 10), + '#type' => 'select', '#title' => t('Number of posts on main page'), + '#default_value' => 10, '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), '#description' => t('The default maximum number of posts to display per page on overview pages such as the main page.') ); $form['teaser_length'] = array( - '#type' => 'select', '#title' => t('Length of trimmed posts'), '#default_value' => variable_get('teaser_length', 600), + '#type' => 'select', '#title' => t('Length of trimmed posts'), + '#default_value' => 600, '#options' => drupal_map_assoc(array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000), '_node_characters'), '#description' => t("The maximum number of characters used in the trimmed version of a post. Drupal will use this setting to determine at which offset long posts should be trimmed. The trimmed version of a post is typically used as a teaser when displaying the post on the main page, in XML feeds, etc. To disable teasers, set to 'Unlimited' . Note that this setting will only affect new or updated content and will not affect existing teasers.") ); @@ -43,12 +45,12 @@ $form['node_preview'] = array( '#type' => 'radios', '#title' => t('Preview post'), - '#default_value' => variable_get('node_preview', 0), + '#default_value' => 0, '#options' => array(t('Optional'), t('Required')), '#description' => t('Must users preview posts before submitting?'), ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** === modified file 'modules/search/search.admin.inc' --- modules/search/search.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/search/search.admin.inc 2008-12-25 09:38:33 +0000 @@ -53,19 +53,45 @@ $items = drupal_map_assoc(array(10, 20, 50, 100, 200, 500)); // Indexing throttle: - $form['indexing_throttle'] = array('#type' => 'fieldset', '#title' => t('Indexing throttle')); - $form['indexing_throttle']['search_cron_limit'] = array('#type' => 'select', '#title' => t('Number of items to index per cron run'), '#default_value' => variable_get('search_cron_limit', 100), '#options' => $items, '#description' => t('The maximum number of items indexed in each pass of a cron maintenance task. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status')))); + $form['indexing_throttle'] = array( + '#type' => 'fieldset', + '#title' => t('Indexing throttle') + ); + $form['indexing_throttle']['search_cron_limit'] = array( + '#type' => 'select', + '#title' => t('Number of items to index per cron run'), + '#default_value' => 100, + '#options' => $items, + '#description' => t('The maximum number of items indexed in each pass of a cron maintenance task. If necessary, reduce the number of items to prevent timeouts and memory errors while indexing.', array('@cron' => url('admin/reports/status'))) + ); // Indexing settings: - $form['indexing_settings'] = array('#type' => 'fieldset', '#title' => t('Indexing settings')); - $form['indexing_settings']['info'] = array('#markup' => t('

Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.

The default settings should be appropriate for the majority of sites.

')); - $form['indexing_settings']['minimum_word_size'] = array('#type' => 'textfield', '#title' => t('Minimum word length to index'), '#default_value' => variable_get('minimum_word_size', 3), '#size' => 5, '#maxlength' => 3, '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).')); - $form['indexing_settings']['overlap_cjk'] = array('#type' => 'checkbox', '#title' => t('Simple CJK handling'), '#default_value' => variable_get('overlap_cjk', TRUE), '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.')); + $form['indexing_settings'] = array( + '#type' => 'fieldset', + '#title' => t('Indexing settings') + ); + $form['indexing_settings']['info'] = array( + '#markup' => t('

Changing the settings below will cause the site index to be rebuilt. The search index is not cleared but systematically updated to reflect the new settings. Searching will continue to work but new content won\'t be indexed until all existing content has been re-indexed.

The default settings should be appropriate for the majority of sites.

') + ); + $form['indexing_settings']['minimum_word_size'] = array( + '#type' => 'textfield', + '#title' => t('Minimum word length to index'), + '#default_value' => 3, + '#size' => 5, + '#maxlength' => 3, + '#description' => t('The number of characters a word has to be to be indexed. A lower setting means better search result ranking, but also a larger database. Each search query must contain at least one keyword that is this size (or longer).') + ); + $form['indexing_settings']['overlap_cjk'] = array( + '#type' => 'checkbox', + '#title' => t('Simple CJK handling'), + '#default_value' => TRUE, + '#description' => t('Whether to apply a simple Chinese/Japanese/Korean tokenizer based on overlapping sequences. Turn this off if you want to use an external preprocessor for this instead. Does not affect other languages.') + ); $form['#validate'] = array('search_admin_settings_validate'); // Per module settings $form = array_merge($form, module_invoke_all('search', 'admin')); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** === modified file 'modules/statistics/statistics.admin.inc' --- modules/statistics/statistics.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/statistics/statistics.admin.inc 2008-12-25 09:27:58 +0000 @@ -189,14 +189,14 @@ $form['access']['statistics_enable_access_log'] = array( '#type' => 'radios', '#title' => t('Enable access log'), - '#default_value' => variable_get('statistics_enable_access_log', 0), + '#default_value' => 0, '#options' => $options, '#description' => t('Log each page access. Required for referrer statistics.')); $period = drupal_map_assoc(array(3600, 10800, 21600, 32400, 43200, 86400, 172800, 259200, 604800, 1209600, 2419200, 4838400, 9676800), 'format_interval'); $form['access']['statistics_flush_accesslog_timer'] = array( '#type' => 'select', '#title' => t('Discard access logs older than'), - '#default_value' => variable_get('statistics_flush_accesslog_timer', 259200), + '#default_value' => 259200, '#options' => $period, '#description' => t('Older access log entries (including referrer statistics) will be automatically discarded. (Requires a correctly configured cron maintenance task.)', array('@cron' => url('admin/reports/status')))); @@ -207,9 +207,9 @@ $form['content']['statistics_count_content_views'] = array( '#type' => 'radios', '#title' => t('Count content views'), - '#default_value' => variable_get('statistics_count_content_views', 0), + '#default_value' => 0, '#options' => $options, '#description' => t('Increment a counter each time content is viewed.')); - return system_settings_form($form); + return system_settings_form($form, TRUE); } === modified file 'modules/syslog/syslog.module' --- modules/syslog/syslog.module 2008-12-06 09:01:58 +0000 +++ modules/syslog/syslog.module 2008-12-25 09:29:27 +0000 @@ -41,12 +41,12 @@ $form['syslog_facility'] = array( '#type' => 'select', '#title' => t('Send events to this syslog facility'), - '#default_value' => variable_get('syslog_facility', DEFAULT_SYSLOG_FACILITY), + '#default_value' => DEFAULT_SYSLOG_FACILITY, '#options' => syslog_facility_list(), '#description' => t('Select the syslog facility code under which Drupal\'s messages should be sent. On UNIX/Linux systems, Drupal can flag its messages with the code LOG_LOCAL0 through LOG_LOCAL7; for Microsoft Windows, all messages are flagged with the code LOG_USER. Depending on the system configuration, syslog and other logging tools use this code to identify or filter Drupal messages from within the entire system log. For more information on syslog, see Syslog help.', array( '@syslog_help' => url('admin/help/syslog'))), ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } function syslog_facility_list() { === modified file 'modules/system/system.admin.inc' --- modules/system/system.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/system/system.admin.inc 2008-12-25 09:24:48 +0000 @@ -153,18 +153,18 @@ '#options' => $options, '#title' => t('Administration theme'), '#description' => t('Choose which theme the administration pages should display in. If you choose "System default" the administration pages will use the same theme as the rest of the site.'), - '#default_value' => variable_get('admin_theme', '0'), + '#default_value' => '0', ); $form['node_admin_theme'] = array( '#type' => 'checkbox', '#title' => t('Use administration theme for content editing'), '#description' => t('Use the administration theme when editing existing posts or creating new ones.'), - '#default_value' => variable_get('node_admin_theme', '0'), + '#default_value' => '0', ); $form['#submit'][] = 'system_admin_theme_submit'; - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -519,7 +519,7 @@ } $form['#attributes'] = array('enctype' => 'multipart/form-data'); - $form = system_settings_form($form); + $form = system_settings_form($form, FALSE); // We don't want to call system_settings_form_submit(), so change #submit. $form['#submit'] = array('system_theme_settings_submit'); return $form; @@ -1197,46 +1197,46 @@ $form['site_name'] = array( '#type' => 'textfield', '#title' => t('Name'), - '#default_value' => variable_get('site_name', 'Drupal'), + '#default_value' => 'Drupal', '#description' => t('The name of this website.'), '#required' => TRUE ); $form['site_mail'] = array( '#type' => 'textfield', '#title' => t('E-mail address'), - '#default_value' => variable_get('site_mail', ini_get('sendmail_from')), + '#default_value' => ini_get('sendmail_from'), '#description' => t("The From address in automated e-mails sent during registration and new password requests, and other notifications. (Use an address ending in your site's domain to help prevent this e-mail being flagged as spam.)"), '#required' => TRUE, ); $form['site_slogan'] = array( '#type' => 'textfield', '#title' => t('Slogan'), - '#default_value' => variable_get('site_slogan', ''), + '#default_value' => '', '#description' => t("Your site's motto, tag line, or catchphrase (often displayed alongside the title of the site).") ); $form['site_mission'] = array( '#type' => 'textarea', '#title' => t('Mission'), - '#default_value' => variable_get('site_mission', ''), + '#default_value' => '', '#description' => t("Your site's mission or focus statement (often prominently displayed on the front page).") ); $form['site_footer'] = array( '#type' => 'textarea', '#title' => t('Footer message'), - '#default_value' => variable_get('site_footer', ''), + '#default_value' => '', '#description' => t('This text will be displayed at the bottom of each page. Useful for adding a copyright notice to your pages.') ); $form['anonymous'] = array( '#type' => 'textfield', '#title' => t('Anonymous user'), - '#default_value' => variable_get('anonymous', t('Anonymous')), + '#default_value' => t('Anonymous'), '#description' => t('The name used to indicate anonymous users.'), '#required' => TRUE, ); $form['site_frontpage'] = array( '#type' => 'textfield', '#title' => t('Default front page'), - '#default_value' => variable_get('site_frontpage', 'node'), + '#default_value' => 'node', '#size' => 40, '#description' => t('The home page displays content from this relative URL. If unsure, specify "node".'), '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q='), @@ -1244,7 +1244,7 @@ ); $form['#validate'][] = 'system_site_information_settings_validate'; - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -1278,7 +1278,7 @@ $form['site_403'] = array( '#type' => 'textfield', '#title' => t('Default 403 (access denied) page'), - '#default_value' => variable_get('site_403', ''), + '#default_value' => '', '#size' => 40, '#description' => t('This page is displayed when the requested document is denied to the current user. If unsure, specify nothing.'), '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=') @@ -1287,19 +1287,20 @@ $form['site_404'] = array( '#type' => 'textfield', '#title' => t('Default 404 (not found) page'), - '#default_value' => variable_get('site_404', ''), + '#default_value' => '', '#size' => 40, '#description' => t('This page is displayed when no other content matches the requested document. If unsure, specify nothing.'), '#field_prefix' => url(NULL, array('absolute' => TRUE)) . (variable_get('clean_url', 0) ? '' : '?q=') ); $form['error_level'] = array( - '#type' => 'select', '#title' => t('Error reporting'), '#default_value' => variable_get('error_level', 1), + '#type' => 'select', '#title' => t('Error reporting'), + '#default_value' => 1, '#options' => array(t('Write errors to the log'), t('Write errors to the log and to the screen')), '#description' => t('Specify where Drupal, PHP and SQL errors are logged. While it is recommended that a site running in a production environment write errors to the log only, in a development or testing environment it may be helpful to write errors both to the log and to the screen.') ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -1416,7 +1417,7 @@ '#submit' => array('system_clear_cache_submit'), ); - return system_settings_form($form); + return system_settings_form($form, FALSE); } /** @@ -1458,12 +1459,12 @@ $form['file_downloads'] = array( '#type' => 'radios', '#title' => t('Download method'), - '#default_value' => variable_get('file_downloads', FILE_DOWNLOADS_PUBLIC), + '#default_value' => FILE_DOWNLOADS_PUBLIC, '#options' => array(FILE_DOWNLOADS_PUBLIC => t('Public - files are available using HTTP directly.'), FILE_DOWNLOADS_PRIVATE => t('Private - files are transferred by Drupal.')), '#description' => t('Choose the Public download method unless you wish to enforce fine-grained access controls over file downloads. Changing the download method will modify all download paths and may cause unexpected problems on an existing site.') ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -1478,7 +1479,7 @@ $form['image_toolkit'] = array( '#type' => 'radios', '#title' => t('Select an image processing toolkit'), - '#default_value' => variable_get('image_toolkit', image_get_toolkit()), + '#default_value' => image_get_toolkit(), '#options' => $toolkits_available ); } @@ -1488,7 +1489,7 @@ $form['image_toolkit_settings'] = image_toolkit_invoke('settings'); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -1502,19 +1503,19 @@ $form['feed_default_items'] = array( '#type' => 'select', '#title' => t('Number of items in each feed'), - '#default_value' => variable_get('feed_default_items', 10), + '#default_value' => 10, '#options' => drupal_map_assoc(array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30)), '#description' => t('Default number of items to include in each feed.') ); $form['feed_item_length'] = array( '#type' => 'select', '#title' => t('Feed content'), - '#default_value' => variable_get('feed_item_length', 'teaser'), + '#default_value' => 'teaser', '#options' => array('title' => t('Titles only'), 'teaser' => t('Titles plus teaser'), 'fulltext' => t('Full text')), '#description' => t('Global setting for the default display of content items in each feed.') ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -1687,7 +1688,7 @@ '#description' => t('A user-defined long date format. See the PHP manual for available options. This format is currently set to display as %date.', array('@url' => 'http://php.net/manual/function.date.php', '%date' => format_date(REQUEST_TIME, 'custom', $default_long_custom))), ); - $form = system_settings_form($form); + $form = system_settings_form($form, FALSE); // We will call system_settings_form_submit() manually, so remove it for now. unset($form['#submit']); return $form; @@ -1728,7 +1729,7 @@ $form['site_offline'] = array( '#type' => 'radios', '#title' => t('Site status'), - '#default_value' => variable_get('site_offline', 0), + '#default_value' => 0, '#options' => array(t('Online'), t('Offline')), '#description' => t('When set to "Online", all visitors will be able to browse your site normally. When set to "Offline", 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 offline message configured below. Authorized users can log in during "Offline" mode directly via the user login page.', array('@user-login' => url('user'))), ); @@ -1736,11 +1737,11 @@ $form['site_offline_message'] = array( '#type' => 'textarea', '#title' => t('Site offline message'), - '#default_value' => variable_get('site_offline_message', t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal')))), + '#default_value' => t('@site is currently under maintenance. We should be back shortly. Thank you for your patience.', array('@site' => variable_get('site_name', 'Drupal'))), '#description' => t('Message to show visitors when the site is in offline mode.') ); - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** @@ -1753,7 +1754,7 @@ $form['clean_url'] = array( '#type' => 'radios', '#title' => t('Clean URLs'), - '#default_value' => variable_get('clean_url', 0), + '#default_value' => 0, '#options' => array(t('Disabled'), t('Enabled')), '#description' => t('This option makes Drupal emit "clean" URLs (i.e. without ?q= in the URL).'), ); @@ -1773,7 +1774,7 @@ } } - return system_settings_form($form); + return system_settings_form($form, TRUE); } /** === modified file 'modules/system/system.module' --- modules/system/system.module 2008-12-24 10:00:03 +0000 +++ modules/system/system.module 2008-12-25 09:15:55 +0000 @@ -1284,6 +1284,24 @@ } } +function _system_settings_form_automatic_defaults($form) { + // Get an array of all non-property keys + $keys = element_children($form); + + foreach ($keys as $key) { + // If the property (key) '#default_value' exists, replace it. + if (array_key_exists('#default_value', $form[$key])) { + $form[$key]['#default_value'] = variable_get($key, $form[$key]['#default_value']); + } + else { + // Recurse through child elements + $form[$key] = _system_settings_form_automatic_defaults($form[$key]); + } + } + + return $form; +} + /** * Add default buttons to a form and set its prefix. * @@ -1294,10 +1312,14 @@ * @return * The form structure. */ -function system_settings_form($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); + } + if (!empty($_POST) && form_get_errors()) { drupal_set_message(t('The settings have not been saved because of the errors.'), 'error'); } === modified file 'modules/system/system.test' --- modules/system/system.test 2008-12-17 00:00:03 +0000 +++ modules/system/system.test 2008-12-25 09:13:41 +0000 @@ -683,3 +683,83 @@ } +class SystemSettingsForm extends DrupalWebTestCase { + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('System setting forms'), + 'description' => t('Tests correctness of system_settings_form() processing.'), + 'group' => t('System') + ); + } + + /** + * Implementation of setUp(). + */ + function setUp() { + parent::setUp(); + + variable_set('system_settings_form_test', TRUE); + variable_set('system_settings_form_test_4', TRUE); + } + + /** + * Reset page title. + */ + function tearDown() { + variable_del('system_settings_form_test'); + variable_del('system_settings_form_test_4'); + + parent::tearDown(); + } + + /** + * Tests the handling of automatic defaults in systems_settings_form(). + */ + function testAutomaticDefaults() { + $form = array(); + + $form['system_settings_form_test'] = array( + '#type' => 'checkbox', + '#default_value' => FALSE, + ); + + $form['system_settings_form_test_2'] = array( + '#type' => 'checkbox', + '#default_value' => FALSE, + ); + + $form['system_settings_form_test_3'] = array( + '#type' => 'checkbox', + '#default_value' => TRUE, + ); + + $form['has_children']['system_settings_form_test_4'] = array( + '#type' => 'checkbox', + '#default_value' => FALSE, + ); + + $form['has_children']['system_settings_form_test_5'] = array( + '#type' => 'checkbox', + '#default_value' => TRUE, + ); + + $automatic = system_settings_form($form, TRUE); + + $this->assertTrue($automatic['system_settings_form_test']['#default_value']); + $this->assertFalse($automatic['system_settings_form_test_2']['#default_value']); + $this->assertTrue($automatic['system_settings_form_test_3']['#default_value']); + $this->assertTrue($automatic['has_children']['system_settings_form_test_4']['#default_value']); + $this->assertTrue($automatic['has_children']['system_settings_form_test_5']['#default_value']); + + $no_automatic = system_settings_form($form); + + $this->assertFalse($no_automatic['system_settings_form_test']['#default_value']); + $this->assertFalse($no_automatic['system_settings_form_test_2']['#default_value']); + $this->assertTrue($no_automatic['system_settings_form_test_3']['#default_value']); + $this->assertFalse($no_automatic['has_children']['system_settings_form_test_4']['#default_value']); + $this->assertTrue($no_automatic['has_children']['system_settings_form_test_5']['#default_value']); + } +} === modified file 'modules/update/update.settings.inc' --- modules/update/update.settings.inc 2008-12-06 09:01:58 +0000 +++ modules/update/update.settings.inc 2008-12-25 09:32:26 +0000 @@ -43,7 +43,7 @@ '#description' => t('If there are updates available of Drupal core or any of your installed modules and themes, your site will print an error message on the status report, the modules page, and the themes page. You can choose to only see these error messages if a security update is available, or to be notified about any newer versions.', array('@status_report' => url('admin/reports/status'), '@modules_page' => url('admin/build/modules'), '@themes_page' => url('admin/build/themes'))) ); - $form = system_settings_form($form); + $form = system_settings_form($form, FALSE); // Custom valiation callback for the email notification setting. $form['#validate'][] = 'update_settings_validate'; // We need to call our own submit callback first, not the one from === modified file 'modules/upload/upload.admin.inc' --- modules/upload/upload.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/upload/upload.admin.inc 2008-12-25 09:39:24 +0000 @@ -148,5 +148,5 @@ $form['#validate'] = array('upload_admin_settings_validate'); - return system_settings_form($form); + return system_settings_form($form, FALSE); } === modified file 'modules/user/user.admin.inc' --- modules/user/user.admin.inc 2008-12-06 09:01:58 +0000 +++ modules/user/user.admin.inc 2008-12-25 09:30:41 +0000 @@ -482,7 +482,7 @@ '#description' => t("This text is displayed at the picture upload form in addition to the default guidelines. It's useful for helping or instructing your users."), ); - return system_settings_form($form); + return system_settings_form($form, FALSE); } /**