? blog_list.patch
? blog_list_cvs.patch
Index: blog_list.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/blog_list/blog_list.info,v
retrieving revision 1.1
diff -u -p -r1.1 blog_list.info
--- blog_list.info	26 Feb 2008 22:08:23 -0000	1.1
+++ blog_list.info	11 Feb 2009 03:18:41 -0000
@@ -1,4 +1,6 @@
 ; $Id: blog_list.info,v 1.1 2008/02/26 22:08:23 noelbush Exp $
 name = Blog List
 description = "Provides a list of blogs on your site."
-dependencies = blog
+dependencies[] = blog
+core = 6.x
+php = 4.x
Index: blog_list.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/blog_list/blog_list.module,v
retrieving revision 1.1
diff -u -p -r1.1 blog_list.module
--- blog_list.module	26 Feb 2008 22:08:23 -0000	1.1
+++ blog_list.module	11 Feb 2009 03:18:41 -0000
@@ -14,15 +14,14 @@
  * @see hook_menu()
  * @return an array containing the menu item
  */
-function blog_list_menu($may_cache) {
-  global $user;
+function blog_list_menu() {
   $items = array();
-  if ($may_cache) {
-    $items[] = array('path' => 'blogs', 'title' => t('Blogs'),
-      'callback' => 'blog_list_blog_list',
-      'access' => user_access('access content'),
-      'type' => MENU_SUGGESTED_ITEM);
-  }
+  $items['blogs'] = array(
+    'title' => t('Blogs'),
+    'page callback' => 'blog_list_blog_list',
+    'access arguments' => array('access content'),
+    'type' => MENU_SUGGESTED_ITEM
+  );
   return $items;
 }
 
@@ -35,23 +34,51 @@ function blog_list_menu($may_cache) {
 function blog_list_blog_list() {
   global $user;
 
-  $output = '<table class="blog-list">' .
-            '<thead><tr><th>User</th></tr></thead>' .
-            '<tbody>';
-
-  $result = pager_query(db_rewrite_sql("SELECT DISTINCT u.name, u.uid FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.type = 'blog' AND n.status = 1 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10));
-
-  $odd = TRUE;
-  while ($row = db_fetch_array($result)) {
-    $output .= '<tr class="' . ($odd ? 'odd' : 'even') . '">' .
-               '<td>' . l($row['name'], 'blog/' . $row['uid']) . '</td>' .
-    		   '</tr>';
-    $odd = !$odd;
-  }
-  $output .= theme('pager', NULL, variable_get('default_nodes_main', 10));
-  
-  $output .= '</tbody>' .
-             '</table>';
+  $output = _blog_list_get_blogs(TRUE);
+  $content .= theme('pager', NULL, variable_get('default_nodes_main',10));
 
   return $output;
 }
+
+
+/**
+ * hook_block implementation
+ *
+ */
+function blog_list_block($op = 'list', $delta = 0, $edit = array()) {
+  if ($op == 'list') {
+    return array ( 0 => array(
+        'info' => t('Blogs'),
+        'cache' => BLOCK_NO_CACHE)
+    );
+  } else if ($op == 'view') {
+    if ($delta == 0) {
+      $block['subject'] = t('Blogs');
+      $block['content'] = _blog_list_get_blogs(FALSE);
+    }
+  }
+  return $block;
+}
+
+
+/**
+ * Helper function to grab the 'blogs'
+ *
+ *  @param boolean use pager or not
+ *  @return HTML with a themed table
+ */
+function _blog_list_get_blogs($pager = FALSE) {
+  $header = array(t('User'));
+  $rows = array();
+
+  if ($pager) {
+    $result = pager_query(db_rewrite_sql("SELECT DISTINCT u.name, u.uid FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.type = 'blog' AND n.status = 1 AND u.uid <> 0 ORDER BY n.created DESC"), variable_get('default_nodes_main', 10));
+  } else {
+    $result = db_query("SELECT DISTINCT u.name, u.uid FROM {users} u INNER JOIN {node} n ON u.uid = n.uid WHERE n.type = 'blog' AND n.status = 1 AND u.uid <> 0 ORDER BY n.created DESC");
+  }
+  while ($bu = db_fetch_array($result)) {
+    $rows[] = array(l($bu['name'],'blog/'.$bu['uid']));
+  }
+
+  return theme('table',$header,$rows,NULL,NULL);
+}
