diff --git a/usasearch.admin.inc b/usasearch.admin.inc index 677d12d..e3548c1 100644 --- a/usasearch.admin.inc +++ b/usasearch.admin.inc @@ -64,6 +64,12 @@ function usasearch_admin() { '#default_value' => 'teaser', '#description' => t('Select a preferred view mode to define description shown in search results. The view mode will need to be enabled and configured for each content type. If the view mode is not available for a content type "Teaser" will be used.'), ); + $form['usasearch_include_if_not_excluded'] = array( + '#type' => 'checkbox', + '#title' => t('Include by content type unless explicitly excluded.'), + '#description' => t('If a content type is enabled for indexing and there is no record of the node in the database as being excluded for indexing then index it.'), + '#default_value' => variable_get('usasearch_include_if_not_excluded', TRUE), + ); return system_settings_form($form); } diff --git a/usasearch.module b/usasearch.module index 34af913..484f266 100644 --- a/usasearch.module +++ b/usasearch.module @@ -31,8 +31,12 @@ function usasearch_form_node_form_alter(&$form, &$form_state, $form_id) { // Include/exclude node from usasearch index $node = $form['#node']; $usasearch_content_type_settings = variable_get("usasearch_node_include_{$node->type}", TRUE); - if(isset($node->nid) && $usasearch_content_type_settings == TRUE) { + if (isset($node->nid) && $usasearch_content_type_settings == TRUE) { $usasearch_node_settings = db_query("SELECT search_include FROM {digitalgovsearch} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField(); + if (is_null($usasearch_node_settings) || $usasearch_node_settings == '') { + // there was no entry in the database, or the search_include column was null + $usasearch_node_settings = variable_get('usasearch_include_if_not_excluded', TRUE); + } } else { $usasearch_node_settings = $usasearch_content_type_settings; } diff --git a/usasearch_api/usasearch_api.module b/usasearch_api/usasearch_api.module index 3abc35e..c6895c2 100644 --- a/usasearch_api/usasearch_api.module +++ b/usasearch_api/usasearch_api.module @@ -92,6 +92,10 @@ function usasearch_api_indexing_allowed ($node){ $index_allowed = variable_get("usasearch_node_include_{$node->type}", TRUE); if ($index_allowed) { $index_allowed = db_query("SELECT search_include FROM {digitalgovsearch} WHERE nid = :nid", array(':nid' => $node->nid))->fetchField(); + if (is_null($index_allowed) || $index_allowed == '') { + // there was no entry in the database, or the search_include column was null + $index_allowed = variable_get('usasearch_include_if_not_excluded', TRUE); + } } return $index_allowed; }