--- /home/flow/src/contributions/modules/weblink/weblink.module	2005-01-07 14:56:43.000000000 +0100
+++ weblink.module	2005-03-13 09:48:28.000000000 +0100
@@ -380,7 +380,7 @@
     $match = array();
     if (preg_match_all("/\[weblink:(\S+?)\]/i", $text, $match)) {
       for ($i = 0; $i <= count($match[1]); $i++) {
-        $result = db_query("SELECT nid FROM {weblink} ". node_access_join_sql() ." WHERE weblink = '%s' AND ". node_access_where_sql(), $match[1][$i]);
+        $result = db_query("SELECT nid FROM {weblink} WHERE weblink = '%s' AND ". node_access_where_sql(), $match[1][$i]);
         $weblink = db_fetch_object($result);
         $node = node_load(array("nid" => $weblink->nid));
         $text = str_replace($match[0][$i], l($node->title, "weblink/goto/$node->nid", _weblink_attributes($node)), $text);
@@ -582,7 +582,7 @@
 function weblink_block_list($type = 'top', $limit = 10) {
   $orderby = ($type == 'new') ?  'n.created' : 'w.click';
 
-  $result = db_query_range("SELECT n.nid, n.title, n.status, n.moderate, w.weblink, w.author, w.click FROM {node} n LEFT JOIN {weblink} w on n.nid = w.nid ". node_access_join_sql() ." WHERE n.type = 'weblink' AND n.promote = '1' AND n.status = 1 AND n.moderate = 0  AND ". node_access_where_sql() ."ORDER by $orderby DESC", 0, $limit);
+  $result = db_query_range("SELECT n.nid, n.title, n.status, n.moderate, w.weblink, w.author, w.click FROM {node} n LEFT JOIN {weblink} w on n.nid = w.nid WHERE n.type = 'weblink' AND n.promote = '1' AND n.status = 1 AND n.moderate = 0  AND ". node_access_where_sql() ."ORDER by $orderby DESC", 0, $limit);
   
   $links = array();
   while ($node = db_fetch_object($result)) {
@@ -600,7 +600,7 @@
   }
 
   // SQL copied over and modified from taxonomy_select_nodes()
-  $result = db_query_range("SELECT DISTINCT(n.nid), n.title, n.body, n.type, n.created, n.changed, n.uid, n.sticky, u.name FROM {node} n ". node_access_join_sql() ." INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid = '%d' AND n.status = '1' AND ". node_access_where_sql(). " ORDER BY sticky DESC, created DESC", $tid, 0, $limit);
+  $result = db_query_range("SELECT DISTINCT(n.nid), n.title, n.body, n.type, n.created, n.changed, n.uid, n.sticky, u.name FROM {node} n INNER JOIN {term_node} r ON n.nid = r.nid INNER JOIN {users} u ON n.uid = u.uid WHERE r.tid = '%d' AND n.status = '1' AND ". node_access_where_sql(). " ORDER BY sticky DESC, created DESC", $tid, 0, $limit);
 
   $links = array();
   while($node = db_fetch_object($result)) {
@@ -705,7 +705,7 @@
 function weblink_monitor_list($limit = 10) {
   global $user;
 
-  $result = db_query_range("SELECT * FROM {weblink} n ". node_access_join_sql() ." WHERE change_stamp > ". (time() - 604800) ." AND ". node_access_where_sql()." ORDER BY change_stamp DESC", 0, $limit);
+  $result = db_query_range("SELECT * FROM {weblink} n WHERE change_stamp > ". (time() - 604800) ." AND ". node_access_where_sql()." ORDER BY change_stamp DESC", 0, $limit);
 
   $hour = -1;
   $list = -1;
@@ -1119,7 +1119,7 @@
       $terms[] = $term->tid;
       $categories[$term_id]->subterms[$term->tid] = $term->name;
     }
-    $result = db_query("SELECT COUNT(*) AS c FROM {term_node} t, {node} n ". node_access_join_sql() ." WHERE t.nid = n.nid AND tid IN (". implode(",", $terms) .") AND n.type = 'weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql());
+    $result = db_query("SELECT COUNT(*) AS c FROM {term_node} t, {node} n WHERE t.nid = n.nid AND tid IN (". implode(",", $terms) .") AND n.type = 'weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql());
     while ($term = db_fetch_object($result)) {
       $categories[$term_id]->link_count = $term->c;
     }
@@ -1129,7 +1129,7 @@
 }
 
 function _weblink_get_links($tid) {
-  $SQL = "SELECT n.nid, n.title, n.teaser, n.body, n.status, n.moderate, n.comment, w.weblink, w.author, w.click, w.rating FROM {node} n, {term_node} t, {weblink} w ". node_access_join_sql() ." WHERE t.nid = n.nid AND n.nid = w.nid AND tid = %d AND n.type='weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql()." ORDER BY n.title";
+  $SQL = "SELECT n.nid, n.title, n.teaser, n.body, n.status, n.moderate, n.comment, w.weblink, w.author, w.click, w.rating FROM {node} n, {term_node} t, {weblink} w WHERE t.nid = n.nid AND n.nid = w.nid AND tid = %d AND n.type='weblink' AND n.status = 1 AND n.moderate = 0 AND ". node_access_where_sql()." ORDER BY n.title";
   if ($weblink_pager_term = variable_get("weblink_pager_term", 0)) {
     $result = pager_query(sprintf($SQL, $tid), $weblink_pager_term);
   }
@@ -1147,7 +1147,7 @@
 
 function _weblink_page_goto($id, $type = 'weblink') {
   if (in_array($type, array("weblink", "feed"))) {
-    $result = db_query("SELECT n.nid,%s FROM {weblink} n ". node_access_join_sql() ." WHERE n.nid = '%d' AND ". node_access_where_sql(), $type, $id);
+    $result = db_query("SELECT n.nid,%s FROM {weblink} n WHERE n.nid = '%d'", $type, $id);
     $wl = db_fetch_object($result);
     if ($wl->$type!='')   {
        db_query("UPDATE {weblink} SET click = click + 1 where nid = '%d'", $id);
