? post_settings.patch Index: node.admin.inc =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.admin.inc,v retrieving revision 1.38 diff -u -p -r1.38 node.admin.inc --- node.admin.inc 3 Feb 2009 18:55:30 -0000 1.38 +++ node.admin.inc 8 Feb 2009 23:09:14 -0000 @@ -1,5 +1,5 @@ 0) { - $status = '
' . t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') . '
'; - $status .= '' . t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') . '
'; - - $form['access'] = array( - '#type' => 'fieldset', - '#title' => t('Node access status'), - ); - $form['access']['status'] = array('#markup' => $status); - $form['access']['rebuild'] = array( - '#type' => 'submit', - '#value' => t('Rebuild permissions'), - '#submit' => array('node_configure_access_submit'), - ); - } - - $form['default_nodes_main'] = array( - '#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' => 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.") - ); - - $form['node_preview'] = array( - '#type' => 'radios', - '#title' => t('Preview post'), - '#default_value' => 0, - '#options' => array(t('Optional'), t('Required')), - '#description' => t('Must users preview posts before submitting?'), - ); - - return system_settings_form($form, TRUE); -} - -/** * Helper function for teaser length choices. */ function _node_characters($length) { @@ -64,7 +17,7 @@ function _node_characters($length) { * Form button submit callback. */ function node_configure_access_submit($form, &$form_state) { - $form_state['redirect'] = 'admin/content/node-settings/rebuild'; + $form_state['redirect'] = 'admin/settings/site-information/rebuild'; } /** @@ -127,6 +80,56 @@ function node_node_operations() { } /** + * Hook_form_alter - adds post settings to system admin pages + */ + +function node_form_alter(&$form, $form_state, $form_id) { + if ($form_id == "system_site_information_settings") { + // Only show rebuild button if there are either 0, or 2 or more, rows + // in the {node_access} table, or if there are modules that + // implement hook_node_grants(). + if (db_result(db_query('SELECT COUNT(*) FROM {node_access}')) != 1 || count(module_implements('node_grants')) > 0) { + $status = '' . t('If the site is experiencing problems with permissions to content, you may have to rebuild the permissions cache. Possible causes for permission problems are disabling modules or configuration changes to permissions. Rebuilding will remove all privileges to posts, and replace them with permissions based on the current modules and settings.') . '
'; + $status .= '' . t('Rebuilding may take some time if there is a lot of content or complex permission settings. After rebuilding has completed posts will automatically use the new permissions.') . '
'; + + $form['access'] = array( + '#type' => 'fieldset', + '#title' => t('Node access status'), + ); + $form['access']['status'] = array('#markup' => $status); + $form['access']['rebuild'] = array( + '#type' => 'submit', + '#value' => t('Rebuild permissions'), + '#submit' => array('node_configure_access_submit'), + ); + } + + $form['default_nodes_main'] = array( + '#type' => 'select', '#title' => t('Number of posts on main page'), + '#default_value' => variable_get('default_nodes_main', 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), + '#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.") + ); + + $form['node_preview'] = array( + '#type' => 'radios', + '#title' => t('Preview post'), + '#default_value' => variable_get('node_preview', 0), + '#options' => array(t('Optional'), t('Required')), + '#description' => t('Must users preview posts before submitting?'), + ); + + $form['buttons']['#weight'] = 10; + } +} + +/** * List node administration filters that can be applied. */ function node_filters() { @@ -269,7 +272,7 @@ function theme_node_filter_form($form) { $output .= '