Index: zeitgeist.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/zeitgeist/zeitgeist.module,v
retrieving revision 1.9.6.5
diff -u -p -r1.9.6.5 zeitgeist.module
--- zeitgeist.module	5 Jul 2009 17:59:24 -0000	1.9.6.5
+++ zeitgeist.module	15 Oct 2009 05:38:24 -0000
@@ -4,17 +4,17 @@
  * @file
  * The Zeitgeist module provides history services for search.
  *
- * It is mainly targeted to coders: look at the ZGSPAN* constants for your own
- * use when creating blocks or pages using this module.
+ * It is mainly targeted to coders: look at the ZGSPAN* constants for 
+ * your own use when creating blocks or pages using this module.
  *
  * Example code is in _zeitgeist_stats().
  *
- * WARNING 1: the current method used to trap searches relies on undocumented
- * search module behaviours, and can break at any version change until a proper
- * logging API is implemented in Drupal core.
+ * WARNING 1: the current method used to trap searches relies on 
+ * undocumented search module behaviours, and can break at any version 
+ * change until a proper logging API is implemented in Drupal core.
  *
- * WARNING 2: always truncate or hand-check the contents of the zeitgeist table
- * after installing a new module version.
+ * WARNING 2: always truncate or hand-check the contents of the 
+ * zeitgeist table after installing a new module version.
  *
  * @copyright  2005-2008 Frédéric G. MARAND
  * @link       http://drupal.org/project/zeitgeist
@@ -31,10 +31,11 @@
  * distribution chain.
  *
  * If you obtained G2 from drupal.org, that site received it under the
- * GPL v2 or later license and can therefore distribute it under the GPL v2 or
- * later, and so can you and just anyone down the chain as long as the GPL v2 or
- * later terms are abided by, the module distributor in that case being the
- * drupal.org organization or the downstream distributor, not OSInet.
+ * GPL v2 or later license and can therefore distribute it under the 
+ * GPL v2 or later, and so can you and just anyone down the chain as 
+ * long as the GPL v2 or later terms are abided by, the module 
+ * distributor in that case being the drupal.org organization or the 
+ * downstream distributor, not OSInet.
  */
 
 /**
@@ -563,7 +564,7 @@ function _zeitgeist_block_latest($count 
   $sq = 'SELECT zg.search, zg.category '
       . 'FROM ' . ZGTABLE . ' zg '
       . 'ORDER BY zg.ts DESC' ;
-  $sq = db_rewrite_sql($sq);
+  $sq = db_rewrite_sql($sq, 'zg', 'search');
   $q = db_query($sq);
   $ar = array();
 
@@ -674,7 +675,7 @@ function _zeitgeist_stats($span = ZGSPAN
     $sq .= "AND (zg.category = '%s') "
          . 'GROUP BY 1, 2 '
          . 'ORDER BY 3 DESC, 1 ASC, 2 ASC '  ;
-    $sq = db_rewrite_sql($sq);
+    $sq = db_rewrite_sql($sq, 'zg', 'search');        
     $q = (isset($count) && ($count > 0))
       ? db_query_range($sq, $ts1, $ts2, $category, 0, $count)
       : db_query($sq, $ts1, $ts2, $category);
@@ -682,7 +683,7 @@ function _zeitgeist_stats($span = ZGSPAN
   else {
     $sq .= 'GROUP BY 1, 2 '
          . 'ORDER BY 3 DESC, 1 ASC, 2 ASC '  ;
-    $sq = db_rewrite_sql($sq);
+    $sq = db_rewrite_sql($sq, 'zg', 'search');     
     $q = (isset($count) && ($count > 0))
       ? db_query_range($sq, $ts1, $ts2, 0, $count)
       : db_query($sq, $ts1, $ts2);
@@ -926,13 +927,13 @@ function _zeitgeist_page($days = 30) {
 
 
   $ar_searches = array();
-  $sq = 'SELECT DISTINCT search, count(ts) AS nts '
-      . 'FROM {zeitgeist} z '
-   // . "WHERE z.category = 'node' "
-      . 'WHERE z.ts >= %d '
-      . 'GROUP BY search '
-      . 'ORDER BY nts DESC, search ASC ';
-  $sq = db_rewrite_sql($sq);
+  $sq = 'SELECT DISTINCT zg.search, count(zg.ts) AS nts '
+      . 'FROM {zeitgeist} zg '
+   // . "WHERE zg.category = 'node' "
+      . 'WHERE zg.ts >= %d '
+      . 'GROUP BY zg.search '
+      . 'ORDER BY zg.nts DESC, zg.search ASC ';
+  $sq = db_rewrite_sql($sq, 'zg', 'search');
   $q = db_query_range($sq, $limit, 0, $height * 3);
   while ($o = db_fetch_array($q)) {
     if ($o['search'] == '') {
