Index: modules/blog/blog.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.module,v
retrieving revision 1.325
diff -u -r1.325 blog.module
--- modules/blog/blog.module	27 Jun 2009 11:11:53 -0000	1.325
+++ modules/blog/blog.module	27 Jun 2009 22:26:29 -0000
@@ -7,41 +7,6 @@
  */
 
 /**
- * Implement hook_node_info().
- */
-function blog_node_info() {
-  return array(
-    'blog' => array(
-      'name' => t('Blog entry'),
-      'base' => 'blog',
-      'description' => t('Use for multi-user blogs. Every user gets a personal blog.'),
-    )
-  );
-}
-
-/**
- * Implement hook_perm().
- */
-function blog_perm() {
-  return node_list_permissions('blog');
-}
-
-/**
- * Implement hook_access().
- */
-function blog_access($op, $node, $account) {
-  switch ($op) {
-    case 'create':
-      // Anonymous users cannot post even if they have the permission.
-      return user_access('create blog content', $account) && $account->uid;
-    case 'update':
-      return user_access('edit any blog content', $account) || (user_access('edit own blog content', $account) && ($node->uid == $account->uid));
-    case 'delete':
-      return user_access('delete any blog content', $account) || (user_access('delete own blog content', $account) && ($node->uid == $account->uid));
-  }
-}
-
-/**
  * Implement hook_user_view().
  */
 function blog_user_view(&$edit, &$user, $category) {
@@ -61,8 +26,8 @@
 function blog_help($path, $arg) {
   switch ($path) {
     case 'admin/help#blog':
-      $output  = '<p>' . t('The blog module allows registered users to maintain an online journal, or <em>blog</em>. Blogs are made up of individual <em>blog entries</em>, and the blog entries are most often displayed in descending order by creation time.') . '</p>';
-      $output .= '<p>' . t("There is an (optional) <em>Blogs</em> menu item added to the Navigation menu, which displays all blogs available on your site, and a <em>My blog</em> item displaying the current user's blog entries. The <em>Blog entry</em> menu item under <em>Add new content</em> allows new blog entries to be created.") . '</p>';
+      $output  = '<p>' . t('The blog module allows registered users to maintain an online journal, or <em>blog</em>. Blogs are most often displayed in descending order by creation time. Blogs can contain multiple content types. A <em>Blog entry</em> is set up by default.') . '</p>';
+      $output .= '<p>' . t("There is an (optional) <em>Blogs</em> menu item added to the Navigation menu, which displays all blogs available on your site, and a <em>My blog</em> item displaying the current user's blog entries.") . '</p>';
       $output .= '<p>' . t('Each blog entry is displayed with an automatic link to other blogs created by the same user. By default, blog entries have comments enabled and are automatically promoted to the site front page. The blog module also creates a <em>Recent blog posts</em> block that may be enabled at the <a href="@blocks">blocks administration page</a>.', array('@blocks' => url('admin/build/block'))) . '</p>';
       $output .= '<p>' . t('For more information, see the online handbook entry for <a href="@blog">Blog module</a>.', array('@blog' => 'http://drupal.org/handbook/modules/blog/')) . '</p>';
       return $output;
@@ -70,13 +35,6 @@
 }
 
 /**
- * Implement hook_form().
- */
-function blog_form($node, $form_state) {
-  return node_content_form($node, $form_state);
-}
-
-/**
  * Implement hook_view().
  */
 function blog_view($node, $build_mode) {
@@ -155,9 +113,10 @@
  * Helper function to determine if a user has blog posts already.
  */
 function _blog_post_exists($account) {
-  return (bool)db_select('node', 'n')
+  $query = db_select('node', 'n');
+  $query->join('blog', 'b', 'n.nid = b.nid');
+  return (bool)$query
     ->fields('n', array('nid'))
-    ->condition('type', 'blog')
     ->condition('uid', $account->uid)
     ->condition('status', 1)
     ->range(0, 1)
@@ -183,11 +142,12 @@
   global $user;
 
   if (user_access('access content')) {
-    $result = db_select('node', 'n')
+    $query = db_select('node', 'n');
+    $query->join('blog', 'b', 'n.nid = b.nid');
+    $result = $query
       ->fields('n', array('nid', 'title', 'created'))
-      ->condition('type', 'blog')
-      ->condition('status', 1)
-      ->orderBy('created', 'DESC')
+      ->condition('n.status', 1)
+      ->orderBy('n.created', 'DESC')
       ->range(0, 10)
       ->addTag('node_access')
       ->execute();
Index: modules/blog/blog.pages.inc
===================================================================
RCS file: /cvs/drupal/drupal/modules/blog/blog.pages.inc,v
retrieving revision 1.19
diff -u -r1.19 blog.pages.inc
--- modules/blog/blog.pages.inc	21 May 2009 21:12:23 -0000	1.19
+++ modules/blog/blog.pages.inc	27 Jun 2009 22:26:29 -0000
@@ -30,13 +30,13 @@
   );
 
   $query = db_select('node', 'n')->extend('PagerDefault');
+  $query->join('blog', 'b', 'n.nid = b.nid');
   $nids = $query
     ->fields('n', array('nid', 'sticky', 'created'))
-    ->condition('type', 'blog')
-    ->condition('uid', $account->uid)
-    ->condition('status', 1)
-    ->orderBy('sticky', 'DESC')
-    ->orderBy('created', 'DESC')
+    ->condition('n.uid', $account->uid)
+    ->condition('n.status', 1)
+    ->orderBy('n.sticky', 'DESC')
+    ->orderBy('n.created', 'DESC')
     ->limit(variable_get('default_nodes_main', 10))
     ->addTag('node_access')
     ->execute()
@@ -80,12 +80,12 @@
   }
 
   $query = db_select('node', 'n')->extend('PagerDefault');
+  $query->join('blog', 'b', 'n.nid = b.nid');
   $nids = $query
     ->fields('n', array('nid', 'sticky', 'created'))
-    ->condition('type', 'blog')
-    ->condition('status', 1)
-    ->orderBy('sticky', 'DESC')
-    ->orderBy('created', 'DESC')
+    ->condition('n.status', 1)
+    ->orderBy('n.sticky', 'DESC')
+    ->orderBy('n.created', 'DESC')
     ->limit(variable_get('default_nodes_main', 10))
     ->addTag('node_access')
     ->execute()
@@ -112,12 +112,13 @@
  */
 function blog_feed_user($account) {
 
-  $nids = db_select('node', 'n')
+  $query = db_select('node', 'n');
+  $query->join('blog', 'b', 'n.nid = b.nid');
+  $nids = $query
     ->fields('n', array('nid', 'created'))
-    ->condition('type', 'blog')
-    ->condition('uid', $account->uid)
-    ->condition('status', 1)
-    ->orderBy('created', 'DESC')
+    ->condition('n.uid', $account->uid)
+    ->condition('n.status', 1)
+    ->orderBy('n.created', 'DESC')
     ->range(0, variable_get('feed_default_items', 10))
     ->addTag('node_access')
     ->execute()
@@ -133,9 +134,8 @@
  * Menu callback; displays an RSS feed containing recent blog entries of all users.
  */
 function blog_feed_last() {
-  $nids = db_select('node', 'n')
-    ->fields('n', array('nid', 'created'))
-    ->condition('type', 'blog')
+  $nids = db_select('blog', 'b')
+    ->fields('b', array('nid', 'created'))
     ->condition('status', 1)
     ->orderBy('created', 'DESC')
     ->range(0, variable_get('feed_default_items', 10))
--- modules/blog/blog.install
+++ modules/blog/blog.install
@@ -0,0 +1,123 @@
+<?php
+// $Id:$
+
+/**
+ * @file
+ * Install, update and uninstall functions for the blog module.
+ */
+
+/**
+ * Implement hook_install().
+ */
+function blog_install() {
+  // Create tables.
+  drupal_install_schema('blog');
+  
+  // Create a content type of "blog".
+  $type = array(
+    'type' => 'blog',
+    'name' => st('Blog entry'),
+    'base' => 'node_content',
+    'description' => st("Use for multi-user blogs. Every user gets a personal blog."),
+    'custom' => 1,
+    'modified' => 1,
+    'locked' => 0,
+  );
+  $type = node_type_set_defaults($type);
+  node_type_save($type);
+}
+
+/**
+ * Implement hook_schema().
+ */
+function blog_schema() {
+  $schema['blog'] = array(
+    'description' => 'Stores the relationship of nodes to a user\'s blog.',
+    'fields' => array(
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'The ID of a node to be listed in the blog.',
+      ),
+      'created' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'When the blog post was created.',
+      ),
+    ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      'created' => array('created'),
+    ),
+    'primary key' => array('nid'),
+    'foreign keys' => array(
+      'nid' => array('node' => 'nid'),
+      'created' => array('node' => 'created'),
+    ),
+  );
+
+  return $schema;
+}
+
+/**
+ * Update function to upate the schema when upgrading to Drupal 7.
+ */
+function blog_update_7000() {
+  $schema['blog'] = array(
+    'description' => 'Stores the relationship of nodes to a user\'s blog.',
+    'fields' => array(
+      'nid' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'The ID of a node to be listed in the blog.',
+      ),
+      'created' => array(
+        'type' => 'int',
+        'unsigned' => TRUE,
+        'not null' => TRUE,
+        'default' => 0,
+        'description' => 'When the blog post was created.',
+      ),
+    ),
+    'indexes' => array(
+      'nid' => array('nid'),
+      'created' => array('created'),
+    ),
+    'primary key' => array('nid'),
+    'foreign keys' => array(
+      'nid' => array('node' => 'nid'),
+      'created' => array('node' => 'created'),
+    ),
+  );
+
+  // Create blog table
+  db_create_table($ret, 'blog', $schema['blog']);
+
+  // insert the blog data into the newly created blog table.
+  $posts = db_query("SELECT nid, created FROM {node} n WHERE n.type = :type", array(
+    ':type' => 'blog',
+  ));
+  
+  foreach ($posts as $post) {
+  db_insert('blog')
+  ->fields(array(
+    'nid' => $post->nid,
+    'created' => $post->created,
+  ))
+  ->execute();
+  }
+  
+  // Change the module type of blogs from "blog" to "node".
+  db_update('node_type')
+  ->fields(array(
+    'module' => 'node',
+  ))
+  ->condition('module', 'blog')
+  ->execute();
+}


