Only in ./: .svn
Common subdirectories: /Users/alex/Desktop/zeitgeist/theme and ./theme
Common subdirectories: /Users/alex/Desktop/zeitgeist/views and ./views
diff -up /Users/alex/Desktop/zeitgeist/zeitgeist.admin.inc ./zeitgeist.admin.inc
--- /Users/alex/Desktop/zeitgeist/zeitgeist.admin.inc	2010-11-26 11:19:06.000000000 -0500
+++ ./zeitgeist.admin.inc	2010-12-10 17:06:55.000000000 -0500
@@ -40,7 +40,17 @@ function _zeitgeist_admin_settings() {
     '#size'               => 4, // this is good until 2037, should be enough for all 6.x needs.
     '#maxlength'          => 4,
     );
-
+  if (module_exists('domain')) {
+    $options = array('1' => t('Enabled'), '0' => t('Disabled'));
+    $form[ZGVARDOMAIN]     = array
+      (
+      '#type'               => 'radios',
+      '#title'              => t('Filter blocks by domain'),
+      '#description'        => t('If enabled, then Zeitgeist blocks will show search data only for searches conducted in the current domain.'),
+      '#default_value'      => variable_get(ZGVARDOMAIN, ZGDEFDOMAIN),
+      '#options'            => $options,
+      );
+  }
   $form['zeitgeist-display'] = array
     (
     '#type'               => 'fieldset',
@@ -204,6 +214,16 @@ function _zeitgeist_admin_settings() {
     '#description'        => t('An attribute for the "a" (X)HTML alement, !attr is non-standard, but is recognized by several search engines, notably Google, MSN and Yahoo!',
       array('!attr' => '<code>rel="nofollow"</code>')),
     );
+  $form['advanced'][ZGVARSEARCHPATH] = array
+    (
+    '#type'               => 'textfield',
+    '#title'              => t('Base search path'),
+    '#default_value'      => variable_get(ZGVARSEARCHPATH, ZGDEFSEARCHPATH),
+    '#description'        => t('If you\'re using core search, leave this at the default value.  Otherwise, enter your site\'s base ' .
+                               'search path (no trailing slash), e.g. search/apachesolr_search.  This is used in the Zeitgeist ' .
+                               'blocks to create links for the top/latest search terms.'),
+    '#size'               => 40,
+    );
   $form['advanced'][ZGVERSION] = array
     (
     '#value'         => '<p>'
Only in ./: zeitgeist.admin.inc.orig
diff -up /Users/alex/Desktop/zeitgeist/zeitgeist.install ./zeitgeist.install
--- /Users/alex/Desktop/zeitgeist/zeitgeist.install	2010-08-29 14:24:26.000000000 -0400
+++ ./zeitgeist.install	2010-12-10 17:06:55.000000000 -0500
@@ -34,6 +34,13 @@ function zeitgeist_schema() {
         'default'     => 'node',
         'description' => $t('The search category. Core categories are "node" and "user".'),
       ),
+      'domain_id' => array(
+        'type'        => 'int',
+        'length'      => 11,
+        'not null'    => FALSE,
+        'default'     => NULL,
+        'description' => $t('The id of the domain in which this search was executed.'),
+      ),
       'ts'          => array(
         'type'        => 'int',
         'unsigned'    => TRUE,
@@ -124,6 +131,23 @@ function zeitgeist_update_6000() {
 }
 
 /**
+ * Adds the 'domain_id' column to the zeitgeist table
+ *
+ * @return array
+ */
+function zeitgeist_update_6000domain() {
+  $t = get_t();
+  $ret = array();
+  db_add_column($ret, 'zeitgeist', 'domain_id', 'int', array(
+    'length'      => 11,
+    'not null'    => FALSE,
+    'default'     => NULL,
+    'description' => $t('The id of the domain in which this search was executed.'))
+  );
+  return $ret;
+}
+
+/**
  * Remove obsolete cache keys and block configuration variables
  */
 function zeitgeist_update_6001() {
diff -up /Users/alex/Desktop/zeitgeist/zeitgeist.module ./zeitgeist.module
--- /Users/alex/Desktop/zeitgeist/zeitgeist.module	2010-12-01 15:32:06.000000000 -0500
+++ ./zeitgeist.module	2010-12-10 17:14:10.000000000 -0500
@@ -93,6 +93,8 @@ define('ZGVARLATESTSEP',     'zeitgeist_
 define('ZGVARNOFOLLOW',      'zeitgeist_nofollow');       // Emit a rel=nofollow attribute in feature blocks
 define('ZGVARPAGEHEIGHT',    'zeitgeist_page_height');    // Number of rows on the zeitgeist pager
 define('ZGVARRECORDEMPTY',   'zeitgeist_record_empty');   // Record empty searches
+define('ZGVARDOMAIN',        'zeitgeist_domain');         // Should Zeitgeist filter search history by domain?
+define('ZGVARSEARCHPATH',    'zeitgeist_searchpath');     // User may specify search path if it's different than core search
 define('ZGVARTOPCACHE',      'zeitgeist_top_cache');      // Block minimum caching duration in minutes
 define('ZGVARTOPCOUNT',      'zeitgeist_top_count');      // How many top queries are displayed in their block ?
 define('ZGVARTOPDISPLAY',    'zeitgeist_top_display');    // 'list' or 'implode'
@@ -109,12 +111,15 @@ define('ZGDEFDISPLAY',     'list');     
 define('ZGDEFTOPCOUNT',    5);                        // Default for ZGVARTOPCOUNT
 define('ZGDEFTOPSPAN',     ZGSPANMONTH);              // Default for ZGVARTOPSPAN
 define('ZGDEFHISTORY',     0);                        // Default means forever
+define('ZGDEFDOMAIN',      0);                        // By default, don't filter by domain
 define('ZGDEFNOFOLLOW',    1);                        // Default is TRUE
+define('ZGDEFSEARCHPATH',  'search/node');            // Default is the core search path
 define('ZGDEFPAGEHEIGHT',  20);                       // Number of rows on the zeitgeist pager
 define('ZGDEFRECORDEMPTY', 1);                        // Defaut is TRUE: record empty queries
 define('ZGDEFTYPE',        ZGDISPLAYTYPEADMIN);       // Default is admin only
 define('ZGDEFVALIDATION',  ZGVALIDATEDISPLAY);        // Default is validate upon display
 define('ZGDEFVALSEP',      ' - ');                    // Default separator for blocks in "inline" mode
+
 /*
  * Block deltas
  */
@@ -139,7 +144,9 @@ function zeitgeist_help($path, $arg) {
     case 'admin/help#zeitgeist':
       $ret = t('<p>zeitgeist records recent searches when they are performed.</p>
 <p>It also supplies a block listing the "n" latest searches, and a setting to define the value of "n".</p>
-<p>If Views 2.x is installed, Zeitgeist can be used as a Views data source.');
+<p>If the Domain module is installed, Zeitgeist can optionally filter blocks by domain.  e.g., the "Top 5" block will
+   show the top 5 searches that were performed in the current domain.</p>
+<p>If Views 2.x is installed, Zeitgeist can be used as a Views data source.</p>');
       break;
 
     default:
@@ -244,14 +251,15 @@ function zeitgeist_block($op = 'list', $
       switch ($delta) {
         case ZGBLOCKLATEST:
           $now = time();
-          $cache = cache_get(ZGCIDLATEST);
+          $cache_id = _zeitgeist_cache_id(ZGCIDLATEST);
+          $cache = cache_get($cache_id);
           if (empty($cache) || ($now >= $cache->expire)) {
             $count = variable_get(ZGVARLATESTCOUNT, ZGDEFLATESTCOUNT);
             $block = array(
               'subject' => t('Latest @count searches', array('@count' => $count)),
               'content' => theme('zeitgeist_block_latest', $count),
             );
-            cache_set(ZGCIDLATEST, $block, 'cache', $expires = $now + 60 * variable_get(ZGVARLATESTCACHE, 0));
+            cache_set($cache_id, $block, 'cache', $expires = $now + 60 * variable_get(ZGVARLATESTCACHE, 0));
           }
           else {
             $block = $cache->data;
@@ -260,14 +268,15 @@ function zeitgeist_block($op = 'list', $
 
         case ZGBLOCKTOP:
           $now = time();
-          $cache = cache_get(ZGCIDTOP);
+          $cache_id = _zeitgeist_cache_id(ZGCIDTOP);
+          $cache = cache_get($cache_id);
           if (empty($cache) || ($now >= $cache->expire)) {
             $count = variable_get(ZGVARTOPCOUNT, ZGDEFTOPCOUNT);
             $block = array(
               'subject' => t('Top @count searches', array('@count' => $count)),
               'content' => theme('zeitgeist_block_top', $count),
             );
-            cache_set(ZGCIDTOP, $block, 'cache', $expires = $now + 60 * variable_get(ZGVARTOPCACHE, 0));
+            cache_set($cache_id, $block, 'cache', $expires = $now + 60 * variable_get(ZGVARTOPCACHE, 0));
           }
           else {
             $block = $cache->data;
@@ -278,7 +287,6 @@ function zeitgeist_block($op = 'list', $
           $block = NULL;
           watchdog('zeitgeist', "zeitgeist_block('view') invoked with invalid delta: @delta. Should not happen",
             array('@delta' => $delta), WATCHDOG_ERROR, ip_address());
-        break;
       }
       $ret = $block;
       break;
@@ -315,11 +323,19 @@ function _zeitgeist_store_search($keys, 
     return;
   }
 
+  if (module_exists('domain')) {
+    //store the domain_id even if "Filter by Domain" is not enabled
+    global $_domain;
+    $domain_id = $_domain['domain_id'];
+  } else {
+    $domain_id = 'NULL';
+  }
+
   if (!isset($ts)) {
     $ts = time();
   }
-  $sq = 'INSERT INTO ' . ZGTABLE . ' (search, category, ts) '
-      . "VALUES ('%s', '%s', %d) ";
+  $sq = 'INSERT INTO ' . ZGTABLE . ' (search, category, ts, domain_id) '
+      . "VALUES ('%s', '%s', %d, $domain_id) "; //don't parameterize $domain_id because we don't want NULL cast to 0
   // No access control on logging, so no db_rewrite_sql().
   db_query($sq, $keys, $kind, $ts);
 }
@@ -442,9 +458,18 @@ function _zeitgeist_stats($span = ZGSPAN
       break;
   }
 
+  $filter_by_domain = (module_exists('domain') && variable_get(ZGVARDOMAIN, ZGDEFDOMAIN));
+
   $sq = 'SELECT zg.search, zg.category, count(zg.ts) cnt '
       . 'FROM ' . ZGTABLE . ' zg '
-      . 'WHERE (zg.ts >= %d) AND( zg.ts < %d) ' ;
+      . 'WHERE (zg.ts >= %d) AND (zg.ts < %d) ' ;
+
+  if ($filter_by_domain) {
+    global $_domain;
+    $domain_id = $_domain['domain_id'];
+    $sq .= "AND (zg.domain_id = $domain_id) ";
+  }
+
   if (isset($category)) {
     $sq .= "AND (zg.category = '%s') "
          . 'GROUP BY 1, 2 '
@@ -503,6 +528,13 @@ function _zeitgeist_cache_clear() {
       cache_clear_all($name, 'cache');
     }
   }
+  if (module_exists('domain') && variable_get(ZGVARDOMAIN, ZGDEFDOMAIN)) {
+    $available_domains = domain_domains();
+    foreach ($available_domains as $domain) {
+      cache_clear_all(ZGCIDTOP . '_' . $domain['domain_id'], 'cache');
+      cache_clear_all(ZGCIDLATEST . '_' . $domain['domain_id'], 'cache');
+    }
+  }
 }
 
 /**
@@ -521,6 +553,22 @@ function _zeitgeist_clear_older($days) {
 }
 
 /**
+ * Returns a cache_id to be used in calls to cache_get() and cache_set().
+ * If Domain filtering is enabled, then the cache_id must be unique to the domain, so
+ * this function appends the current domain id to $base_id 
+ * @param string $base_id The cache_id to be used if domain filtering is not enabled
+ * @return string
+ */
+function _zeitgeist_cache_id($base_id) {
+  if (module_exists('domain') && variable_get(ZGVARDOMAIN, ZGDEFDOMAIN)) {
+    global $_domain;
+    return $base_id . "_" . $_domain['domain_id'];
+  } else {
+    return $base_id;
+  }
+}
+
+/**
  * Implement hook_cron().
  *
  * This is used to clean the old entries
@@ -575,9 +623,10 @@ function template_preprocess_zeitgeist_b
     ? array('rel' => 'nofollow')
     : array() ;
   $attr = array_merge($attr, array('absolute' => TRUE));
+  $search_path = trim(variable_get(ZGVARSEARCHPATH, ZGDEFSEARCHPATH), " /");
   foreach ($ar_stats->scores as $score) {
     $ar_scores[] = l($score['search'] . " (${score['count']})",
-      "search/node/$score[search]", $attr);
+      "$search_path/$score[search]", $attr);
   }
   unset($ar_stats);
 
@@ -693,8 +742,9 @@ function zeitgeist_page_single_column() 
   $q = pager_query($sq, $height, 0, $sq_count);
   $ar = array();
   $cnt = 0;
+  $search_path = trim(variable_get(ZGVARSEARCHPATH, ZGDEFSEARCHPATH), " /");
   while ($o = db_fetch_object($q)) {
-    $ar[] = "$o->cnt - " . l($o->search, "search/node/$o->search");
+    $ar[] = "$o->cnt - " . l($o->search, "$search_path/$o->search");
     $cnt += $o->cnt;
   }
   $ret .= theme('item_list', $ar);
