--- ./live_discussions.module	2005-04-02 04:01:25.000000000 +0200
+++ ./live_discussions_ec.module	2005-06-03 19:00:42.000000000 +0200
@@ -1,5 +1,7 @@
 <?php
 /* $Id: live_discussions.module,v 1.5.2.3 2005/04/01 23:23:33 prometheus6 Exp $ */
+// **ec indicates ec mod(s)
+
 /**
   * @file
   * Creates a block of links to the nodes most recently commented on
@@ -66,9 +68,14 @@
         if (arg(1)) $select_blog .= " AND n.uid = '".arg(1)."' ";
       }
       // create the SQL
-      $query = "SELECT c.nid, n.title, count(c.nid) as comment_count, max(c.timestamp) as the_time FROM {comments} c ".
-               "JOIN {node} n on n.nid = c.nid ".$select_blog." where c.status = 0 group by c.nid order by the_time desc ".
-               "LIMIT ".$commented_limit;
+
+      // **ec change to uppercase for use with db_rewrite_sql
+      $query = 'SELECT n.nid, n.title, COUNT(c.nid) AS comment_count, MAX(c.timestamp) AS the_time FROM {comments} c 
+               ' . 'JOIN {node} n ON n.nid = c.nid ' . $select_blog . ' WHERE c.status = 0 GROUP BY c.nid ORDER BY the_time DESC
+               ' . ' LIMIT ' . $commented_limit;
+
+      // **ec use db_rewrite_sql to take care of user's permissions
+      $query = db_rewrite_sql($query);
       $query_result = db_query($query);
 
       if (db_num_rows($query_result) > 0) {
