? 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 .= '
'; $output .= drupal_render($form['filters']); $output .= '
'; - $output .= drupal_render_children($form); + $output .= drupal_render($form); return $output; } @@ -616,7 +619,7 @@ function theme_node_admin_nodes($form) { $output .= drupal_render($form['pager']); } - $output .= drupal_render_children($form); + $output .= drupal_render($form); return $output; } Index: node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1023 diff -u -p -r1.1023 node.module --- node.module 6 Feb 2009 16:25:08 -0000 1.1023 +++ node.module 8 Feb 2009 23:09:15 -0000 @@ -1,5 +1,5 @@ array( - 'name' => t('Node'), - 'id key' => 'nid', - 'revision key' => 'vid', - 'bundle key' => 'type', - // Node.module handles its own caching. - // 'cacheable' => FALSE, - // Bundles must provide human readable name so - // we can create help and error messages about them. - 'bundles' => node_get_types('names'), - ), - ); - return $return; -} - - -/** - * Implementation of hook_field_build_modes(). - */ -function node_field_build_modes($obj_type) { - $modes = array(); - if ($obj_type == 'node') { - $modes = array( - 'teaser' => t('Teaser'), - 'full' => t('Full node'), - NODE_BUILD_RSS => t('RSS'), - NODE_BUILD_PRINT => t('Print'), - ); - if (module_exists('search')) { - $modes += array( - NODE_BUILD_SEARCH_INDEX => t('Search Index'), - NODE_BUILD_SEARCH_RESULT => t('Search Result'), - ); - } - } - return $modes; -} - -/** * Gather a listing of links to nodes. * * @param $result @@ -580,9 +537,6 @@ function node_type_save($info) { if ($is_existing) { db_update('node_type')->fields($fields)->condition('type', $existing_type)->execute(); - if (!empty($type->old_type) && $type->old_type != $type->type) { - field_attach_rename_bundle($type->old_type, $type->type); - } module_invoke_all('node_type', 'update', $type); return SAVED_UPDATED; } @@ -590,8 +544,6 @@ function node_type_save($info) { $fields['orig_type'] = (string) $type->orig_type; db_insert('node_type')->fields($fields)->execute(); - field_attach_create_bundle($type->type); - module_invoke_all('node_type', 'insert', $type); return SAVED_NEW; } @@ -909,14 +861,6 @@ function node_load_multiple($nids = arra } } - // Attach fields. - if ($vid) { - field_attach_load_revision('node', $queried_nodes); - } - else { - field_attach_load('node', $queried_nodes); - } - // Call hook_nodeapi_load(), pass the node types so modules can return early // if not acting on types in the array. foreach (module_implements('nodeapi_load') as $module) { @@ -997,9 +941,6 @@ function node_validate($node, $form = ar } } - // Validate fields - field_attach_validate('node', $node, $form); - // Do node-type-specific validation checks. node_invoke($node, 'validate', $form); node_invoke_nodeapi($node, 'validate', $form); @@ -1052,7 +993,6 @@ function node_submit($node) { * Save a node object into the database. */ function node_save(&$node) { - field_attach_presave('node', $node); // Let modules modify the node before it is saved to the database. node_invoke_nodeapi($node, 'presave'); global $user; @@ -1128,11 +1068,6 @@ function node_save(&$node) { // node_invoke($node, 'insert') or // node_invoke($node, 'update'). node_invoke($node, $op); - - // Save fields. - $function = "field_attach_$op"; - $function('node', $node); - node_invoke_nodeapi($node, $op); // Update the node access table for this node. @@ -1270,9 +1205,6 @@ function node_build_content($node, $teas $node = node_prepare($node, $teaser); } - // Build fields content. - $node->content += field_attach_view('node', $node, $teaser); - // Allow modules to make their own additions to the node. node_invoke_nodeapi($node, 'view', $teaser); @@ -1612,7 +1544,7 @@ function theme_node_search_admin($form) } $output .= theme('table', $header, $rows); - $output .= drupal_render_children($form); + $output .= drupal_render($form); return $output; } @@ -1692,14 +1624,7 @@ function node_menu() { 'weight' => -10, ); - $items['admin/content/node-settings'] = array( - 'title' => 'Post settings', - 'description' => 'Control posting behavior, such as teaser length, requiring previews before posting, and the number of posts on the front page.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('node_configure'), - 'access arguments' => array('administer nodes'), - ); - $items['admin/content/node-settings/rebuild'] = array( + $items['admin/settings/site-information/rebuild'] = array( 'title' => 'Rebuild permissions', 'page arguments' => array('node_configure_rebuild_confirm'), // Any user than can potentially trigger a node_access_needs_rebuild(TRUE) @@ -3066,7 +2991,7 @@ function node_unpublish_by_keyword_actio $form['keywords'] = array( '#title' => t('Keywords'), '#type' => 'textarea', - '#description' => t('The post will be unpublished if it contains any of the phrases above. Use a case-sensitive, comma-separated list of phrases. Example: funny, bungee jumping, "Company, Inc."'), + '#description' => t('The post will be unpublished if it contains any of the character sequences above. Use a comma-separated list of character sequences. Example: funny, bungee jumping, "Company, Inc." . Character sequences are case-sensitive.'), '#default_value' => isset($context['keywords']) ? drupal_implode_tags($context['keywords']) : '', ); return $form; @@ -3138,7 +3063,7 @@ function node_list_permissions($type) { * Implementation of hook_elements(). */ function node_elements() { - $type['node_links'] = array('#theme' => 'node_links'); + $type['node_links'] = array(); return $type; }