? .DS_Store
? advanced_blog_db_api.patch
Index: advanced_blog.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/advanced_blog/advanced_blog.module,v
retrieving revision 1.1.2.2
diff -u -p -r1.1.2.2 advanced_blog.module
--- advanced_blog.module	23 Jun 2009 15:05:08 -0000	1.1.2.2
+++ advanced_blog.module	18 Aug 2009 18:52:18 -0000
@@ -242,9 +242,9 @@ function advanced_blog_block($op = 'list
         .($advanced_blog_order==2 ? "numitems DESC, u.name" : "")
         .($advanced_blog_order==3 ? "n.created DESC, u.name" : "")
         .($advanced_blog_order==4 ? "RAND()" : "")
-        ." LIMIT $maxdisp"
+
         ;
-      $results = db_query($sql);
+      $results = db_query_range($sql, 0, $maxdisp);
     
     $block_content = '<div id="advanced_blog">';
     
@@ -366,8 +366,8 @@ function advanced_blog_block($op = 'list
       $bcontent .= "<li>" . l(t("My blog"),'blog/'. $user->name) . "</li>";
       $bcontent .= "<li>" . l('Post new blog entry','node/add/blog') . "</li>";
       $bcontent .= "<li>Top bloggers </li>";
-      $query = "SELECT u.uid, u.name, COUNT(n.uid) AS nposts FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.status=1 AND n.type = 'blog' GROUP BY u.uid  ORDER BY nposts DESC LIMIT " . variable_get('blog_nav_ntopbloggers', 5);
-      $result = db_query(db_rewrite_sql($query));
+      $query = "SELECT u.uid, u.name, COUNT(n.uid) AS nposts FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.status=1 AND n.type = 'blog' GROUP BY u.uid  ORDER BY nposts DESC";
+      $result = db_query_range(db_rewrite_sql($query, 'u', 'uid'), 0, variable_get('blog_nav_ntopbloggers', 5));
       $bcontent .= "<ul>";
 
       while ($blogger = db_fetch_object($result))
@@ -387,8 +387,8 @@ function advanced_blog_block($op = 'list
   }
   else
   {
-    $query = "SELECT node.nid, node.created FROM {node} WHERE node.type = 'blog' AND node.status = 1 AND node.uid = " . $account->uid . " ORDER By node.created DESC";
-    $result = db_query(db_rewrite_sql($query));
+    $query = "SELECT n.nid, n.created FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = %d ORDER BY n.created DESC";
+    $result = db_query(db_rewrite_sql($query), $account->uid);
     $bcontent .= "<ul>";
     $bcontent .= "<li>" . l($account->name . '\'s blog', 'blog/' . $account->uid) . "</li>";
     if ($user->uid == $account->uid)
@@ -413,10 +413,8 @@ function advanced_blog_block($op = 'list
       }
       if ($month != $lastmonth)
       {
-        $limit = " AND YEAR(FROM_UNIXTIME(n.created)) = " . $year;
-        $limit .= " AND MONTH(FROM_UNIXTIME(n.created)) = " . $month_numeric;
-  $query = "SELECT COUNT(n.nid) FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = " . $account->uid . $limit . " ORDER By n.created DESC ";
-  $postpermonth = db_result(db_query($query));
+  $query = "SELECT COUNT(n.nid) FROM {node} n WHERE n.type = 'blog' AND n.status = 1 AND n.uid = %d AND YEAR(FROM_UNIXTIME(n.created)) = %d AND MONTH(FROM_UNIXTIME(n.created)) = %d ORDER BY n.created DESC";
+  $postpermonth = db_result(db_query($query, $account->uid, $year, $month_numeric));
 
         $bcontent .= "<li>" . l($month,'blog/' . $account->name . '/' . $year . '/' . $month_numeric)  . " (" . $postpermonth . ") </li>";
   $lastmonth = $month;
