Index: solr/project_solr.module
===================================================================
RCS file: /Users/wright/drupal/local_repo/contributions/modules/project/solr/project_solr.module,v
retrieving revision 1.81
diff -u -p -r1.81 project_solr.module
--- solr/project_solr.module	16 Jan 2011 02:11:26 -0000	1.81
+++ solr/project_solr.module	30 Jan 2011 14:32:33 -0000
@@ -137,6 +137,10 @@ function project_solr_apachesolr_update_
   if (!empty($node->project['uri'])) {
     $document->ss_project_uri = $node->project['uri'];
   }
+  if (!empty($node->project)) {
+    // The initial "is" is for integer/single.
+    $document->is_project_sandbox = !empty($node->project['sandbox']) ? 1 : 0;
+  }
   if (module_exists('project_release') && !empty($node->project_release['releases'])) {
     $document->is_project_has_releases = 1;
 
@@ -226,6 +230,18 @@ function project_solr_apachesolr_modify_
     }
     $query->add_subquery($tid_query, 'OR');
   }
+
+  // If we don't have any explicit filter for the sandbox status of the
+  // projects, add an explicit exclusion for sandbox projects.
+  foreach ($query->get_filters() as $filter) {
+    if ($filter['#name'] == 'is_project_sandbox') {
+      $has_filter = TRUE;
+    }
+  }
+  if (!$has_filter) {
+    // If not defined, we want to *hide* sandboxes, hence 0.
+    $query->add_filter('is_project_sandbox', 0, TRUE);
+  }
 }
 
 /**
@@ -665,6 +681,28 @@ function project_solr_browse_projects_fo
     }
   }
 
+  // Add the project sandbox fields.
+  $form['is_project_sandbox'] = array(
+    '#title' => t('Status'),
+    '#type' => 'select',
+    '#options' => array(
+      0 => t('Official projects'),
+      '*' => t('All projects'),
+      1 => t('Only sandbox projects'),
+    ),
+  );
+
+  // Extract the project sandbox value from our filters.
+  foreach ($query->get_filters() as $filter) {
+    if ($filter['#name'] == 'is_project_sandbox') {
+      $form['is_project_sandbox']['#default_value'] = $filter['#value'];
+    }
+  }
+
+  if (variable_get('project_solr_hide_sandbox_ui', TRUE)) {
+    $form['is_project_sandbox']['#access'] = FALSE;
+  }
+
   $form['text'] = array(
     '#title' => t('Search @project_type', array('@project_type' => $project_type->name)),
     '#type' => 'textfield',
@@ -758,6 +796,9 @@ function project_solr_browse_projects_fo
     drupal_set_message(t('No search text submitted for a relevancy sort.  The default sorting method was used instead.'));
   }
 
+  // Add the project sandbox filter.
+  $query->add_filter('is_project_sandbox', $form_state['values']['is_project_sandbox']);
+
   // Add all project-specific sorts so that the sort set in set_solrsort() will
   // work as intended.
   project_solr_add_sorts($query, variable_get('project_solr_project_release_api_tids_alias', 'api_version'));
