Index: modules/node/node.module =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.module,v retrieving revision 1.1082 diff -u -p -r1.1082 node.module --- modules/node/node.module 10 Jul 2009 05:58:13 -0000 1.1082 +++ modules/node/node.module 13 Jul 2009 19:45:33 -0000 @@ -1309,6 +1309,10 @@ function node_permission() { 'title' => t('View own unpublished content'), 'description' => t('View unpublished content created by the user'), ), + 'search all content types' => array( + 'title' => t('Search all content types'), + 'description' => t('Search all content types'), + ), ); foreach (node_type_get_types() as $type) { @@ -1395,6 +1399,20 @@ function node_search($op = 'search', $ke '#default_value' => variable_get('node_rank_' . $var, 0), ); } + $form['node_types'] = array( + '#type' => 'fieldset', + '#title' => t('Content types'), + '#collapsible' => TRUE, + '#description' => t('If not all content types should be included in the search results, content types can be excluded here. Users with the permission '. l('search all content types', 'admin/user/permissions') .' will still be able to search all content types.') + ); + + $form['node_types']['search_node_types_exclude'] = array( + '#type' => 'checkboxes', + '#title' => t('Content types excluded from search results'), + '#default_value' => variable_get('search_node_types_exclude', array()), + '#options' => node_type_get_names(), + '#description' => t('Content types chosen here will be excluded from searches, but will still be indexed by the search indexer.') + ); return $form; case 'search': @@ -1403,6 +1421,18 @@ function node_search($op = 'search', $ke $arguments1 = array(); $conditions1 = 'n.status = 1'; + if (!user_access('search all content types')) { + $includes = array_keys(array_filter(variable_get('search_node_types_exclude', array()), create_function('$a', 'return $a === 0;'))); + $types_entered = search_query_extract($keys, 'type'); + if (!empty($types_entered)) { + $includes = array_intersect(explode(',', $types_entered), $includes); + $keys = preg_replace('/type:'. preg_quote($types_entered) .'/', 'type:'. implode(',', $includes), $keys); + } + else if (!empty($includes)){ + $keys .= ' type:' . implode(',', $includes); + } + } + if ($type = search_query_extract($keys, 'type')) { $types = array(); foreach (explode(',', $type) as $t) {