Index: search_restrict.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/search_restrict/search_restrict.module,v retrieving revision 1.5 diff -u -p -r1.5 search_restrict.module --- search_restrict.module 13 Sep 2009 21:22:32 -0000 1.5 +++ search_restrict.module 17 Feb 2010 21:40:49 -0000 @@ -64,13 +64,25 @@ function search_restrict_db_rewrite_sql( if ($user->uid == 1) { return; } - + $user_roles = $user->roles; $excluded_types = array(); if ($query == '' && $primary_table == 'n' && $primary_field == 'nid' && empty($args)) { $content_type_restrictions = variable_get('search_restrict_content_type', array()); + if (variable_get('search_restrict_default_no_access', 0) == 1) { + + $all_types = array_keys(node_get_types()); + + foreach ($all_types as $type) { + if (!isset($content_type_restrictions[$type])) { + $content_type_restrictions[$type]= array(); + } // if + } // foreach + + } // if + foreach ($content_type_restrictions as $type => $roles) { $access = FALSE; @@ -89,7 +101,10 @@ function search_restrict_db_rewrite_sql( // If no roles or all roles have been selected then everyone has access // skip this content type. - if (!empty($access_true) && !empty($access_false)) { + if ( + (!empty($access_true) && !empty($access_false)) || + (empty($access_true) && variable_get('search_restrict_default_no_access', 0) == 1) + ) { // If user has role in include list skip this content type. foreach ($access_true as $role_selected) { if (!empty($user_roles[$role_selected])) $access = TRUE; @@ -116,6 +131,18 @@ function search_restrict_form_alter(&$fo case 'search_form': $form['#after_build'][] = '_search_restrict_advanced_form'; break; + case 'search_admin_settings': + $form['search_restrict'] = array( + '#type' => 'fieldset', + '#title' => 'Search Restrict', + 'search_restrict_default_no_access' => array( + '#type' => 'checkbox', + '#title' => 'Default to No Access', + '#description' => 'If unchecked, any content type with no roles checked will give access to all users. If checked, any content types with no roles checked will give access to no one.', + '#default_value' => variable_get('search_restrict_default_no_access', 0), + ), + ); + break; } }