? d6port.patch
Index: nodecomment-wrapper.tpl.php
===================================================================
RCS file: nodecomment-wrapper.tpl.php
diff -N nodecomment-wrapper.tpl.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ nodecomment-wrapper.tpl.php	21 Jul 2008 21:11:46 -0000
@@ -0,0 +1 @@
+<div id="comments"><?php print $content ?></div>
\ No newline at end of file
Index: nodecomment.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodecomment/nodecomment.info,v
retrieving revision 1.1
diff -u -p -r1.1 nodecomment.info
--- nodecomment.info	10 Jan 2007 21:36:06 -0000	1.1
+++ nodecomment.info	21 Jul 2008 21:11:46 -0000
@@ -1,4 +1,5 @@
 ; $Id$
 name = Node Comment
 description = Allows users to comment on and discuss published content using nodes.
-dependencies = views
+dependencies[] = views
+core = 6.x
\ No newline at end of file
Index: nodecomment.install
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodecomment/nodecomment.install,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 nodecomment.install
--- nodecomment.install	19 May 2008 18:47:01 -0000	1.1.2.4
+++ nodecomment.install	21 Jul 2008 21:11:46 -0000
@@ -1,20 +1,29 @@
 <?php
 // $Id: nodecomment.install,v 1.1.2.4 2008/05/19 18:47:01 sirkitree Exp $
 
+/**
+ * @file
+ * Install file for nodecomment
+ */
+ 
+/**
+ * Implementation of hook_enable().
+ */
+function nodecomment_enable() {
+  // Disable comment.module since it is incompatible with nodecomment
+  $result = db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = 'comment' AND status = 1");
+  if (db_affected_rows()) {
+    drupal_set_message(t('Comment module has been deactivated -- it is incompatible with Node Comment module.'));
+  }
+}
+
 function nodecomment_install() {
-  db_query("CREATE TABLE {node_comments} (
-    cid int NOT NULL default 0,
-    pid int NOT NULL default 0,
-    nid int NOT NULL default 0,
-    hostname varchar(128) NOT NULL default '',
-    thread varchar(255) NOT NULL,
-    name varchar(60) default NULL,
-    mail varchar(64) default NULL,
-    homepage varchar(255) default NULL,
-    PRIMARY KEY (cid),
-    KEY lid (nid)
-  ) /*!40100 DEFAULT CHARACTER SET UTF8 */ ");
+  drupal_set_message('Installing Node Comments.');  
+  drupal_install_schema('nodecomment');
+  _nodecomment_install_type_create();
+}
 
+function _nodecomment_install_type_create() {
   // During install profiles, node and user modules aren't yet loaded.
   // Ensure they're loaded before calling node_get_types().
   include_once './'. drupal_get_path('module', 'node') .'/node.module';
@@ -24,31 +33,22 @@ function nodecomment_install() {
 
   if (!in_array('comment', array_keys($types))) {
     // Create the comment content type.
-    include_once './'. drupal_get_path('module', 'node') .'/content_types.inc';
-
-    $type  = array(
-      'name' => 'Comment',
+    $nodecomment_node_type = array(
       'type' => 'comment',
-      'description' => 'A comment for use with the nodecomment module.',
-      'title_label' => 'Subject',
-      'body_label' => 'Body',
-      'min_word_count' => '0',
-      'help' => '',
-      'node_options' => array(
-        'status' => true,
-        'promote' => false,
-        'sticky' => false,
-        'revision' => false,
-        ),
-      'old_type' => 'comment',
-      'orig_type' => '',
+      'name' => t('Comment'),
       'module' => 'node',
-      'custom' => '1',
-      'modified' => '1',
-      'locked' => '0',
+      'description' => t('A comment for use with the nodecomment module.'),
+      'title_label' => t('Subject'),
+      'body_label' => t('Body'),
+      'custom' => TRUE,
+      'modified' => TRUE,
+      'locked' => FALSE,
     );
-    drupal_execute('node_type_form', $type, (object)$type);
+    $nodecomment_node_type = (object)_node_type_set_defaults($nodecomment_node_type);
+    node_type_save($nodecomment_node_type);
 
+    // Default to not promoted.
+    variable_set('node_options_comment', array('status'));
     cache_clear_all();
     system_modules();
     menu_rebuild();
@@ -56,10 +56,33 @@ function nodecomment_install() {
   }
 }
 
+function nodecomment_schema() {
+  $schema['node_comments'] = array(
+    'fields' => array(
+      'cid'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'pid'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'nid'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'hostname' => array('type' => 'varchar', 'length' => '128', 'not null' => TRUE, 'default' => ''),
+      'thread'   => array('type' => 'varchar', 'length' => '255', 'not null' => TRUE),
+      'name'     => array('type' => 'varchar', 'length' => '60', 'not null' => FALSE),
+      'uid'      => array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'),
+      'mail'     => array('type' => 'varchar', 'length' => '64', 'not null' => FALSE),
+      'homepage' => array('type' => 'varchar', 'length' => '255', 'not null' => FALSE)
+    ),
+    'primary key' => array('cid'),
+    'indexes' => array(
+      'lid' => array('nid')),
+  );
+  return $schema;
+}
+
 function nodecomment_uninstall() {
-  if (db_table_exists('node_comments')) {
-    // The uninstall hook should do more than this and clean up the node
-    // and node_comment_statistics table as well.
-    db_query("DROP TABLE {node_comments}");
-  }
+  drupal_uninstall_schema('nodecomment');
 }
+
+function nodecomment_update_6000() {
+  // adding uid to schema. this is needed to avoid the (not verified) that theme_user now implements
+  $ret = array();
+  db_add_field($ret, 'node_comments', 'uid', array('type' => 'int', 'not null' => TRUE, 'default' => 0, 'disp-width' => '11'));
+  return $ret;
+}
\ No newline at end of file
Index: nodecomment.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/nodecomment/nodecomment.module,v
retrieving revision 1.3.2.15
diff -u -p -r1.3.2.15 nodecomment.module
--- nodecomment.module	23 May 2008 12:58:35 -0000	1.3.2.15
+++ nodecomment.module	21 Jul 2008 21:11:46 -0000
@@ -10,10 +10,6 @@
  * a forum topic, weblog post, story, collaborative book page, etc.
  */
 
-if (!module_exists('comment') && module_exists('views')) {
-  include_once(drupal_get_path('module', 'nodecomment') .'/nodecomment_views.inc');
-}
-
 /*
  * Constants to define a comment's published state
  */
@@ -71,8 +67,8 @@ define('COMMENT_PREVIEW_REQUIRED', 1);
 /**
  * Implementation of hook_help().
  */
-function nodecomment_help($section) {
-  switch ($section) {
+function nodecomment_help($path, $arg) {
+  switch ($path) {
     case 'admin/help#nodecomment':
       $output = '<p>'. t('The comment module creates a discussion board for each post. Users can post comments to discuss a forum topic, weblog post, story, collaborative book page, etc. The ability to comment is an important part of involving members in a community dialogue.') .'</p>';
       $output .= '<p>'. t('An administrator can give comment permissions to user groups, and users can (optionally) edit their last comment, assuming no others have been posted since. Attached to each comment board is a control panel for customizing the way that comments are displayed. Users can control the chronological ordering of posts (newest or oldest first) and the number of posts to display on each page. Comments behave like other user submissions. Filters, smileys and HTML that work in nodes will also work with comments. The comment module provides specific features to inform site members when new comments have been posted.') .'</p>';
@@ -84,29 +80,22 @@ function nodecomment_help($section) {
 /**
  * Implementation of hook_menu().
  */
-function nodecomment_menu($may_cache) {
+function nodecomment_menu() {
   $items = array();
-
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/settings/nodecomment',
-      'title' => t('Comments'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('nodecomment_admin_settings'),
-      'access' => user_access('administer comments'),
-      'description' => t("Administer your site's comment settings."),
-    );
-  }
-  else {
-    if ((arg(0) == 'node') && is_numeric(arg(1)) && is_numeric(arg(2))) {
-      $items[] = array(
-        'path' => ('node/'. arg(1) .'/'. arg(2)),
-        'title' => t('View'),
-        'callback' => 'node_page',
-        'type' => MENU_CALLBACK,
-      );
-    }
-  }
+  
+  $items['admin/settings/nodecomment'] = array(
+    'title' => 'Comments',
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('nodecomment_admin_settings'),
+    'access arguments' => array('administer comments'),
+    'description' => t("Administer your site's comment settings."),
+  );
+  
+  $items['node/%node/%node'] = array(
+    'title' => 'View',
+    'page callback' => 'node_page_view',    
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
@@ -171,12 +160,13 @@ function nodecomment_admin_settings() {
     '#description' => t('The default node type to use for posting comments.'),
   );
 
-
   return system_settings_form($form);
 }
 
-
-function nodecomment_form_alter($form_id, &$form) {
+/**
+ * Implementation of hook_form_alter().
+ */
+function nodecomment_form_alter(&$form, $form_state, $form_id) {
   global $user;
   
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
@@ -197,20 +187,12 @@ function nodecomment_form_alter($form_id
     );
 
     $options = $none;
-    include_once(drupal_get_path('module', 'views') .'/views_cache.inc');
-    $default_views = _views_get_default_views();
-
-    $res = db_query("SELECT name FROM {view_view} ORDER BY name");
-    while ($view = db_fetch_object($res)) {
-      $options[$view->name] = $view->name;
-    }
-
+    $default_views = views_get_all_views();
     if (is_array($default_views)) {
       foreach ($default_views as $key => $view) {
         $options[$key] = $view->name;
       }
     }
-
     $form['workflow']['comment_view'] = array(
       '#type' => 'select',
       '#title' => t('Comment view'),
@@ -295,7 +277,7 @@ function nodecomment_form_alter($form_id
         $form['#prefix'] .= node_view($target_node);
 
         // now we send it back to nodecomment_form_alter and let it be handled as a comment.
-        return nodecomment_form_alter($form_id, $form);
+        return nodecomment_form_alter($form, $form_state, $form_id);
       }
       // Just a normal node: turn on the comment control settings.
       else {
@@ -336,17 +318,6 @@ function nodecomment_comment_type_valida
 }
 
 /**
- * Implementation of hook_enable().
- */
-function nodecomment_enable() {
-  // Disable comment.module
-  $result = db_query("UPDATE {system} SET status = 0 WHERE type = 'module' AND name = 'comment' AND status = 1");
-  if (db_affected_rows()) {
-    drupal_set_message(t('Comment module has been deactivated -- it is incompatible with Node Comment module.'));
-  }
-}
-
-/**
  * Disables the comment module checkbox so it can't be selected.
  */
 function nodecomment_disable_comment_module($form, $edit) {
@@ -472,9 +443,9 @@ function nodecomment_save($node) {
   $node->thread = nodecomment_get_thread($node);
 
   db_query("INSERT INTO {node_comments} ".
-         "(cid,        nid,                       pid,                       hostname,                thread,        name,        mail,        homepage)".
-  "VALUES (%d,         %d,                        %d,                        '%s',                    '%s',          '%s',        '%s',        '%s')",
-           $node->nid, $node->comment_target_nid, $node->comment_target_cid, $_SERVER['REMOTE_ADDR'], $node->thread, $node->name, $node->mail, $node->homepage);
+         "(cid,        nid,                       pid,                       hostname,                thread,        name,        uid,        mail,        homepage)".
+  "VALUES (%d,         %d,                        %d,                        '%s',                    '%s',          '%s',        %d,         '%s',        '%s')",
+           $node->nid, $node->comment_target_nid, $node->comment_target_cid, $_SERVER['REMOTE_ADDR'], $node->thread, $node->name, $node->uid, $node->mail, $node->homepage);
 
   _nodecomment_update_node_statistics($node->comment_target_nid);
 
@@ -496,7 +467,8 @@ function nodecomment_form($node) {
       'type' => $comment_type,
       'comment_target_nid' => $node->nid,
     );
-    return drupal_get_form($comment_type .'_node_form', $new_node);  
+    require_once drupal_get_path('module', 'node') . '/node.pages.inc';
+    return drupal_get_form($comment_type .'_node_form', $new_node);
   }
 }
 
@@ -633,14 +605,14 @@ if (!function_exists('comment_render')) 
 
 function nodecomment_render($node, $cid = 0) {
   global $user;
-
+  
   if (user_access('access comments')) {
     // Pre-process variables.
     $nid = $node->nid;
     if (empty($nid)) {
       $nid = 0;
     }
-
+    
     if (is_numeric($cid)) {
       // Single comment view.
       if ($comment = node_load($cid)) {
@@ -650,7 +622,7 @@ function nodecomment_render($node, $cid 
     else {
       $view_name = variable_get('comment_view_'. $node->type, 'node_comments');
       if ($view_name) {
-        $output = theme('view', $view_name, NULL, NULL, 'embed', array($nid));
+        $output = views_embed_view($view_name, 'default', array($nid));
       }
     }
 
@@ -671,9 +643,8 @@ function nodecomment_render($node, $cid 
 }
 
 /**
-*** misc functions: helpers, privates, history
-**/
-
+ * misc functions: helpers, privates, history
+ */
 
 function nodecomment_num_all($nid) {
   static $cache;
@@ -723,13 +694,6 @@ function nodecomment_form_box($node, $ti
   return theme('box', $title, nodecomment_form($node));
 }
 
-/**
- * Allow themable wrapping of all comments.
- */
-function theme_nodecomment_wrapper($content, $node) {
-  return '<div id="comments">'. $content .'</div>';
-}
-
 function _nodecomment_delete_thread($comment) {
   if (!is_object($comment) || !is_numeric($comment->cid)) {
     watchdog('content', t('Can not delete non-existent comment.'), WATCHDOG_WARNING);
@@ -815,20 +779,26 @@ function _nodecomment_update_node_statis
   }
 }
 
-if (!function_exists('theme_comment')) {
-  function theme_comment($comment, $links=array()) {
-    return theme('nodecomment', $comment, $links);
+if (!function_exists('comment_theme')) {
+  function comment_theme() {
+    return nodecomment_theme();
   }
 }
 
-function theme_nodecomment($comment, $links = array()) {
-  $output  = '<div class="comment'. ($comment->status == COMMENT_NOT_PUBLISHED ? ' comment-unpublished' : '') .'">';
-  $output .= '<div class="subject">'. l($comment->subject, $_GET['q'], NULL, NULL, "comment-$comment->cid") .' '. theme('mark', $comment->new) ."</div>\n";
-  $output .= '<div class="credit">'. t('by %a on %b', array('%a' => theme('username', $comment), '%b' => format_date($comment->timestamp))) ."</div>\n";
-  $output .= '<div class="body">'. $comment->comment .'</div>';
-  $output .= '<div class="links">'. theme('links', $links) .'</div>';
-  $output .= '</div>';
-  return $output;
+function nodecomment_theme() {
+  return array(
+    'nodecomment_wrapper' => array(
+      'template' => 'nodecomment-wrapper',
+      'arguments' => array('content' => NULL, 'node' => NULL),
+    ),
+  );
+}
+
+/**
+ * Allow themable wrapping of all comments.
+ */
+function theme_nodecomment_wrapper($content, $node) {
+  return '<div id="comments">'. $content .'</div>';
 }
 
 function nodecomment_get_thread($node) {
Index: nodecomment.views.inc
===================================================================
RCS file: nodecomment.views.inc
diff -N nodecomment.views.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ nodecomment.views.inc	21 Jul 2008 21:11:47 -0000
@@ -0,0 +1,352 @@
+<?php
+// $Id: nodecomment_views.inc,v 1.2.2.7 2008/05/15 16:26:15 sirkitree Exp $
+/**
+ * @file
+ * Provide views data and handlers for nodecomment.module
+ */
+
+/**
+ * @defgroup views_nodecomment_module nodecomment.module handlers
+ *
+ * Includes the tables 'node', 'node_comments' and 'node_comment_statistics'.
+ * @{
+ */
+
+/**
+ * Implementation of hook_views_data()
+ */
+function nodecomment_views_data() {
+  $data['node_comments']['table']['group']  = t('Node');
+	
+	// ----------------------------------------------------------------
+  // node table -- basic table information.
+
+	$data['node_comments']['table']['join'] = array(
+		// node_comments links to node
+		'node' => array(
+			'left_field' => 'nid',
+			'field' => 'cid',
+		),
+	);
+	
+	// ----------------------------------------------------------------
+  // node_comments table -- fields
+  
+  $data['node_comments']['cid'] = array(
+    'title' => t('Nid'),
+    'help' => t('The node ID of the comment.'),
+    'argument' => array(
+      'handler' => 'views_handler_argument_node_nid',
+      'name field' => 'title', 
+      'numeric' => TRUE,
+      'validate type' => 'nid',
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_numeric',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+  );
+  
+  $data['node_comments']['nid'] = array(
+    'title' => t('Original Parent Nid'),
+    'help' => t('The original node the comment is a reply to.'),
+    'relationship' => array(
+      'base' => 'node',
+      'field' => 'nid',
+      'handler' => 'views_handler_relationship',
+      'label' => t('Node'),
+    ),
+  );
+  
+  $data['node_comments']['pid'] = array(
+    'title' => t('Parent Nid'),
+    'help' => t('The node of the parent comment. Could be another comment.'),
+    'field' => array(
+      'handler' => 'views_handler_field',
+    ),
+    'relationship' => array(
+      'title' => t('Parent comment'),
+      'help' => t('The parent comment.'),
+      'base' => 'comments',
+      'field' => 'cid',
+      'handler' => 'views_handler_relationship',
+      'label' => t('Parent comment'),
+    ),
+  );
+  
+  $data['node_comments']['name'] = array(
+    'title' => t('Author'),
+    'help' => t('The name of the poster.'),
+    'field' => array(
+      'handler' => 'views_handler_field_username_comment',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+  
+  $data['node_comments']['homepage'] = array(
+    'title' => t("Author's website"),
+    'help' => t("The website address of the comment's author. Can be a link. The homepage can also be linked with the Name field. Will be empty if posted by a registered user."),
+    'field' => array(
+      'handler' => 'views_handler_field_url',
+      'click sortable' => TRUE,
+    ),
+    'filter' => array(
+      'handler' => 'views_handler_filter_string',
+    ),
+    'sort' => array(
+      'handler' => 'views_handler_sort',
+    ),
+    'argument' => array(
+      'handler' => 'views_handler_argument_string',
+    ),
+  );
+  
+  $data['node_comments']['thread'] = array(
+    'field' => array(
+      'title' => t('Depth'),
+      'help' => t('Display the depth of the comment if it is threaded.'),
+      'handler' => 'views_handler_field_comment_depth',
+    ),
+    'sort' => array(
+      'title' => t('Thread'),
+      'help' => t('Sort by the threaded order. This will keep child comments together with their parents.'),
+      'handler' => 'views_handler_sort_comment_thread',
+    ),
+  );
+  
+  // link to reply to comment
+  $data['node_comments']['replyto_comment'] = array(
+    'field' => array(
+      'title' => t('Reply-to link'),
+      'help' => t('Provide a simple link to reply to the comment.'),
+      'handler' => 'views_handler_field_comment_link_reply',
+    ),
+  );
+	
+  return $data;
+}
+
+/**
+ * Field handler to allow linking to a user account or homepage
+ */
+class views_handler_field_username_comment extends views_handler_field {
+  /**
+   * Override init function to add uid and homepage fields.
+   */
+  function init(&$view, &$data) {
+    parent::init($view, $data);
+    $this->additional_fields['uid'] = 'uid';
+    $this->additional_fields['homepage'] = 'homepage';
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['link_to_user'] = array('default' => TRUE);
+    return $options;
+  }
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $form['link_to_user'] = array(
+      '#title' => t("Link this field to its user or an author's homepage"),
+      '#type' => 'checkbox',
+      '#default_value' => $this->options['link_to_user'],
+    );
+  }
+
+  function render_link($data, $values) {
+    $account->uid = $values->{$this->aliases['uid']};
+    $account->name = $values->{$this->field_alias};
+    $account->homepage = $values->{$this->aliases['homepage']};
+
+    if (!empty($this->options['link_to_user'])) {
+      return theme('username', $account);
+    }
+    else {
+      return $data;
+    }
+  }
+
+  function render($values) {
+    return $this->render_link(check_plain($values->{$this->field_alias}), $values);
+  }
+
+}
+
+/**
+ * Field handler to display the depth of a comment
+ */
+class views_handler_field_comment_depth extends views_handler_field {
+  /**
+   * Work out the depth of this comment
+   */
+  function render($values) {
+    return count(explode('.', $values->comments_thread)) - 1;
+  }
+}
+
+/**
+ * Sort handler for ordering by thread
+ */
+class views_handler_sort_comment_thread extends views_handler_sort {
+  function query() {
+    $this->ensure_my_table();
+
+    //Read comment_render() in comment.module for an explanation of the
+    //thinking behind this sort.
+    if ($this->options['order'] == 'DESC') {
+      $this->query->add_orderby($this->table_alias, $this->real_field, $this->options['order']);
+    }
+    else {
+      $alias = $this->table_alias . '_' . $this->real_field . 'asc';
+      //@todo is this secure?
+      $this->query->add_orderby(NULL, "SUBSTRING({$this->table_alias}.{$this->real_field}, 1, (LENGTH({$this->table_alias}.{$this->real_field}) - 1))", $this->options['order'], $alias);
+    }
+  }
+}
+
+/**
+ * Base field handler to present a link.
+ */
+class views_handler_field_comment_link extends views_handler_field {
+  function construct() {
+    parent::construct();
+    $this->additional_fields['cid'] = 'cid';
+    $this->additional_fields['nid'] = 'nid';
+  }
+
+  function option_definition() {
+    $options = parent::option_definition();
+    $options['text'] = array('default' => '', 'translatable' => TRUE);
+    return $options;
+  }
+
+  function options_form(&$form, &$form_state) {
+    parent::options_form($form, $form_state);
+    $form['text'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Text to display'),
+      '#default_value' => $this->options['text'],
+    );
+  }
+
+  function query() {
+    $this->ensure_my_table();
+    $this->add_additional_fields();
+  }
+
+  function render($values) {
+    $text = !empty($this->options['text']) ? $this->options['text'] : t('view');
+    return l($text, "node/" . $values->{$this->aliases['nid']}, array('html' => TRUE, 'fragment' => "comment-" . $values->{$this->aliases['cid']}));
+  }
+}
+
+/**
+ * Field handler to present a link to delete a node.
+ */
+class views_handler_field_comment_link_reply extends views_handler_field_comment_link {
+  function render($values) {
+    //check for permission to reply to comments
+    if (!user_access('post comments')) {
+      return;
+    }
+    $text = !empty($this->options['text']) ? $this->options['text'] : t('reply');
+    return l($text, "node/add/comment/" . $values->{$this->aliases['nid']} . '/' . $values->{$this->aliases['cid']});
+  }
+}
+
+/**
+ * Implementation of hook_views_plugins
+ */
+function nodecomment_views_plugins() {
+  return array(
+    'module' => 'nodecomment',
+    'row' => array(
+      'comment' => array(
+        'title' => t('Comments flat'),
+        'help' => t('Display the comment with standard comment view.'),
+        'handler' => 'views_plugin_row_comment_view',
+        'theme' => 'views_view_row_comment',
+        'base' => array('comments'), // only works with 'comment' as base.
+        'uses options' => TRUE,
+        'type' => 'normal',
+      ),
+      'comment_threaded' => array(),
+      'comment_rss' => array(
+        'title' => t('Comments RSS'),
+        'help' => t('Display the comment as RSS.'),
+        'handler' => 'views_plugin_row_comment_rss',
+        'base' => array('comments'), // only works with 'comment' as base.
+        'type' => 'feed',
+      ),
+    ),
+  );
+}
+
+function theme_nodecomment_threaded_comments($view, $nodes, $type) {
+  $divs = 0;
+  $last_depth = 0;
+  drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
+  foreach ($nodes as $n) {
+    $node = node_load($n->nid);
+    $node->depth = count(explode('.', $node->thread)) - 1;
+
+
+    if ($node->depth > $last_depth) {
+      $divs++;
+      $output .= '<div class="indented">';
+      $last_depth++;
+    }
+    else {
+      while ($node->depth < $last_depth) {
+        $divs--;
+        $output .= '</div>';
+        $last_depth--;
+      }
+    }
+
+    if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
+      //$output .= theme('comment_thread_collapsed', $node);
+    }
+    // $mode == COMMENT_MODE_THREADED_EXPANDED
+    else {
+      $output .= theme('nodecomment_view', $node);
+    }
+  }
+  for ($i = 0; $i < $divs; $i++) {
+    $output .= '</div>';
+  }
+
+  return $output;
+}
+
+function theme_nodecomment_view($comment) {
+  static $first_new = TRUE;
+
+  $output = '';
+  $comment->new = node_mark($comment->nid, $comment->timestamp);
+  if ($first_new && $comment->new != MARK_READ) {
+    // Assign the anchor only for the first new comment. This avoids duplicate
+    // id attributes on a page.
+    $first_new = FALSE;
+    $output .= "<a id=\"new\"></a>\n";
+  }
+
+  $output .= "<a id=\"comment-$comment->nid\"></a>\n";
+
+  // Switch to folded/unfolded view of the comment
+  $output .= node_view($comment, FALSE, FALSE, TRUE);
+
+  return $output;
+}
Index: nodecomment.views_default.inc
===================================================================
RCS file: nodecomment.views_default.inc
diff -N nodecomment.views_default.inc
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ nodecomment.views_default.inc	21 Jul 2008 21:11:47 -0000
@@ -0,0 +1,143 @@
+<?php
+// $Id: $
+/**
+ * @file
+ * Contains default views on behalf of the nodecomment module.
+ */
+
+/**
+ * Implementation of hook_default_view_views().
+ */
+function nodecomment_views_default_views() {
+  $view = new view;
+  $view->name = 'nodecomments';
+  $view->description = '';
+  $view->tag = '';
+  $view->view_php = '';
+  $view->base_table = 'node';
+  $view->is_cacheable = FALSE;
+  $view->api_version = 2;
+  $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
+  $handler = $view->new_display('default', 'nodecomments', 'default');
+  $handler->override_option('relationships', array(
+    'nid' => array(
+      'label' => 'Node',
+      'required' => 0,
+      'id' => 'nid',
+      'table' => 'node_comments',
+      'field' => 'nid',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('fields', array(
+    'title' => array(
+      'label' => 'Title',
+      'link_to_node' => 0,
+      'exclude' => 0,
+      'id' => 'title',
+      'table' => 'node',
+      'field' => 'title',
+      'relationship' => 'none',
+    ),
+    'name' => array(
+      'label' => 'Author',
+      'link_to_user' => 1,
+      'exclude' => 0,
+      'id' => 'name',
+      'table' => 'node_comments',
+      'field' => 'name',
+      'relationship' => 'none',
+    ),
+    'thread' => array(
+      'label' => 'Depth',
+      'exclude' => 0,
+      'id' => 'thread',
+      'table' => 'node_comments',
+      'field' => 'thread',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('arguments', array(
+    'nid' => array(
+      'default_action' => 'not found',
+      'style_plugin' => 'default_summary',
+      'style_options' => array(),
+      'wildcard' => 'all',
+      'wildcard_substitution' => 'All',
+      'title' => '',
+      'default_argument_type' => 'fixed',
+      'default_argument' => '',
+      'validate_type' => 'none',
+      'validate_fail' => 'not found',
+      'break_phrase' => 0,
+      'not' => 0,
+      'id' => 'nid',
+      'table' => 'node',
+      'field' => 'nid',
+      'relationship' => 'nid',
+      'default_options_div_prefix' => '',
+      'default_argument_user' => 0,
+      'default_argument_fixed' => '',
+      'default_argument_php' => '',
+      'validate_argument_node_type' => array(
+        'comment' => 0,
+        'page' => 0,
+        'story' => 0,
+      ),
+      'validate_argument_node_access' => 0,
+      'validate_argument_nid_type' => 'nid',
+      'validate_argument_vocabulary' => array(),
+      'validate_argument_type' => 'tid',
+      'validate_argument_php' => '',
+    ),
+  ));
+  $handler->override_option('filters', array(
+    'status' => array(
+      'operator' => '=',
+      'value' => 1,
+      'group' => '0',
+      'exposed' => FALSE,
+      'expose' => array(
+        'operator' => FALSE,
+        'label' => '',
+      ),
+      'id' => 'status',
+      'table' => 'node',
+      'field' => 'status',
+      'relationship' => 'none',
+    ),
+    'type' => array(
+      'operator' => 'in',
+      'value' => array(
+        'comment' => 'comment',
+      ),
+      'group' => '0',
+      'exposed' => FALSE,
+      'expose' => array(
+        'operator' => FALSE,
+        'label' => '',
+      ),
+      'id' => 'type',
+      'table' => 'node',
+      'field' => 'type',
+      'relationship' => 'none',
+    ),
+  ));
+  $handler->override_option('access', array(
+    'type' => 'none',
+    'role' => array(),
+    'perm' => '',
+  ));
+  $handler->override_option('items_per_page', 0);
+  $handler->override_option('style_options', array(
+    'grouping' => '',
+  ));
+  $handler->override_option('row_plugin', 'node');
+  $handler->override_option('row_options', array(
+    'teaser' => 0,
+    'links' => 1,
+  ));
+  $views[$view->name] = $view;
+
+  return $views;
+}
Index: nodecomment_views.inc
===================================================================
RCS file: nodecomment_views.inc
diff -N nodecomment_views.inc
--- nodecomment_views.inc	15 May 2008 16:26:15 -0000	1.2.2.7
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,413 +0,0 @@
-<?php
-// $Id: nodecomment_views.inc,v 1.2.2.7 2008/05/15 16:26:15 sirkitree Exp $
-
-/**
- * This include file implements views functionality on behalf of relationship.module
- */
-
-function nodecomment_views_tables() {
-  $tables['node_comments'] = array(
-    'name' => 'node_comments',
-    'provider' => 'internal',
-    'join' => array(
-      'left' => array(
-        'table' => 'node',
-        'field' => 'nid'
-      ),
-      'right' => array(
-        'field' => 'cid'
-      )
-    ),
-    'fields' => array(
-      'nid' => array(
-        'name' => t('Node comment: Parent node'),
-        'help' => t('Display the node the comment was posted in response to'),
-      ),
-      'name' => array(
-        'name' => t('Node comment: User name'),
-        'help' => t('Display the name of the user who posted the comment'),
-      ),
-      'mail' => array(
-        'name' => t('Node comment: Email address'),
-        'help' => t('Display the email address of the user who posted the comment'),
-      ),
-      'homepage' => array(
-        'name' => t('Node comment: Homepage'),
-        'help' => t('Display the home page of the user who posted the comment'),
-      ),
-    ),
-    'filters' => array(
-      'nid' => array(
-        'name' => t('Node comment: Parent node'),
-        'operator' => views_handler_operator_eqneq(),
-        'help' => t('This allows you to filter based on the parent node.'),
-      ),
-    ),
-    'sorts' => array(
-      'thread' => array(
-        'name' => t('Node comment: Threaded comments'),
-        'handler' => 'nodecomment_views_handler_sort_thread',
-        'help' => t('Sort by discussion thread.')
-      ),
-    ),
-  );
-
-  $tables['node_comment_statistics'] = array(
-    'name' => 'node_comment_statistics',
-    'provider' => 'internal',
-    'join' => array(
-      'left' => array(
-        'table' => 'node',
-        'field' => 'nid'
-      ),
-      'right' => array(
-        'field' => 'nid'
-      ),
-    ),
-    'fields' => array(
-      'last_comment_timestamp' => array(
-        'name' => t('Node comment: Last Comment Time'),
-        'sortable' => true,
-        'handler' => views_handler_field_dates(),
-        'option' => 'string',
-        'help' => t('This will display the last comment time.'),
-       ),
-      'last_comment_name' => array(
-        'name' => t('Node comment: Last Comment Author'),
-        'query_handler' => 'views_query_handler_field_last_comment_name',
-        'handler' => 'views_handler_field_last_comment_name',
-        'sortable' => true,
-        'uid' => 'last_comment_uid',
-        'addlfields' => array('last_comment_name', 'last_comment_uid'),
-        'help' => t('This will display the name of the last user to comment on the post.'),
-      ),
-      'comment_count' => array(
-        'name' => t('Node comment: Count'),
-        'sortable' => true,
-        'handler' => array(
-          'views_handler_field_int'         => t('Normal'),
-          'views_handler_comments_with_new' => t('With New Count')
-        ),
-        'help' => t('This will display the comment count.'),
-      ),
-    ),
-    'filters' => array(
-      'comment_count' => array(
-        'name' => t('Node comment: Comment Count'),
-        'operator' => 'views_handler_operator_gtlt',
-        'option' => 'integer',
-        'help' => t('This filter allows you to filter by the amount of comments.'),
-      ),
-      'last_comment_timestamp' => array(
-        'name' => t('Node comment: Last Comment Time'),
-        'operator' => 'views_handler_operator_gtlt',
-        'value' => views_handler_filter_date_value_form(),
-        'handler' => 'views_handler_filter_timestamp',
-        'option' => 'string',
-        'help' => t('This filter allows nodes to be filtered by the last comment timestamp. Enter dates in the format: CCYY-MM-DD HH:MM:SS. Enter \'now\' to use the current time. You may enter a delta (in seconds) to the option that will be added to the time; this is most useful when combined with now. If you have the jscalendar module from jstools installed, you can use a popup date picker here.'),
-      ),
-    ),
-    'sorts' => array(
-      'last_comment_timestamp' => array(
-        'name' => t('Node comment: Last Comment Date'),
-        'handler' => 'views_handler_sort_date',
-        'option' => views_handler_sort_date_options(),
-        'help' => t('This will allow you to sort by the date of the most recent comment on a node.')
-      ),
-      'comment_count' => array(
-        'name' => t('Node comment: Comment Count'),
-        'help' => t('This filter allows you to sort by the number of comments.'),
-      ),
-    ),
-  );
-
-  return $tables;
-}
-
-function nodecomment_views_arguments() {
-  $arguments = array(
-    'comment_target_nid' => array(
-      'name' => t("Node comment: Parent node ID"),
-      'handler' => "views_handler_arg_comment_target_nid",
-    ),
-  );
-  return $arguments;
-}
-
-function nodecomment_views_default_views() {
-  $flatview = new stdClass();
-  $flatview->name = 'node_comments';
-  $flatview->description = 'Node comments flat';
-  $flatview->access = array();
-  $flatview->view_args_php = '$args_rev = array_reverse($args);
-  if (strtolower($args_rev[0]) == \'desc\') {
-    $view->sort[0][\'sortorder\'] = \'DESC\';
-  }
-  return $args;';
-  $flatview->sort = array(
-    array(
-      'tablename' => 'node',
-      'field' => 'sticky',
-      'sortorder' => 'DESC',
-      'options' => '',
-    ),
-    array(
-      'tablename' => 'node',
-      'field' => 'created',
-      'sortorder' => 'ASC',
-      'options' => 'normal',
-    ),
-  );
-  $flatview->argument = array(
-    array(
-      'type' => 'comment_target_nid',
-      'argdefault' => '1',
-      'title' => '',
-      'options' => '',
-      'wildcard' => '',
-      'wildcard_substitution' => '',
-    ),
-  );
-  $flatview->field = array(
-  );
-  $flatview->filter = array(
-    array(
-      'tablename' => 'node',
-      'field' => 'status',
-      'operator' => '=',
-      'options' => '',
-      'value' => '1',
-    ),
-    array(
-      'tablename' => 'node',
-      'field' => 'moderate',
-      'operator' => '=',
-      'options' => '',
-      'value' => '0',
-    ),
-  );
-  $flatview->exposed_filter = array();
-  $flatview->requires = array('node');
-  $flatview->page_type = 'node';
-  $views[$flatview->name] = $flatview;
-
-  // Threaded views
-  $threadedview = new stdClass();
-  $threadedview->name = 'node_comments_threaded';
-  $threadedview->description = 'Node comments threaded';
-  $threadedview->access = array();
-  $threadedview->view_args_php = '';
-  $threadedview->sort = array(
-    array(
-      'tablename' => 'node_comments',
-      'field' => 'thread',
-      'sortorder' => 'ASC',
-      'options' => '',
-    ),
-  );
-  $threadedview->argument = array(
-    array(
-      'type' => 'comment_target_nid',
-      'argdefault' => '1',
-      'title' => '',
-      'options' => '',
-      'wildcard' => '',
-      'wildcard_substitution' => '',
-    ),
-  );
-  $threadedview->field = array();
-  $threadedview->filter = array(
-    array(
-      'tablename' => 'node',
-      'field' => 'status',
-      'operator' => '=',
-      'options' => '',
-      'value' => '1',
-    ),
-    array(
-      'tablename' => 'node',
-      'field' => 'moderate',
-      'operator' => '=',
-      'options' => '',
-      'value' => '0',
-    ),
-  );
-  $threadedview->exposed_filter = array();
-  $threadedview->requires = array(node_comments, node);
-
-  // Secret sauce for threaded comments - the style plugin
-  $threadedview->page_type = 'threaded_comments';
-
-  $views[$threadedview->name] = $threadedview;
-
-  return $views;
-}
-
-function nodecomment_views_style_plugins() {
-  $items['threaded_comments'] = array(
-    'name' => t('Node comment: Threaded comments'),
-    'theme' => 'nodecomment_threaded_comments',
-    'needs_fields' => true,
-  );
-  return $items;
-}
-
-function views_handler_arg_comment_target_nid($op, &$query, $argtype, $arg = '') {
-  switch ($op) {
-    case 'summary' :
-      // Not supported at present
-      break;
-    case 'sort':
-      // Not supported at present
-      break;
-    case 'filter' :
-      $query->ensure_table("node_comments");
-      $query->add_where("node_comments.nid = %d", $arg);
-      break;
-    case 'link' :
-      // Not supported at present
-      break;
-    case 'title' :
-      if ($query) {
-        $n = db_fetch_object(db_query("SELECT title FROM {node} WHERE nid = %d", $query));
-        return $n->title;
-      }
-  }
-}
-
-
-// This code is copied shamelessly from views module's views_comment.inc.
-// Since comment.module isn't enabled, we lose this functionality. But we
-// do, indeed, want it for building forum views and so on.
-
-function views_query_handler_field_last_comment_name($field, $fieldinfo, &$query) {
-  $num = $query->add_table('users', false, 1, array(
-    'left' => array(
-      'table' => $field['tablename'],
-      'field' => 'last_comment_uid'
-    ),
-    'right' => array(
-      'field' => 'uid'
-    ),
-  ));
-  $query->add_field('name', $query->get_table_name('users', $num), $field['tablename'] .'_name');
-}
-
-function views_handler_field_last_comment_name($fieldinfo, $fielddata, $value, $data) {
-  $obj->name = $value;
-  $uidfield = $fielddata['tablename'] ."_". $fieldinfo['uid'];
-  $obj->uid = $data->$uidfield;
-  if ($obj->uid != 0) {
-    $fieldname = $fielddata['tablename'] .'_name';
-    $obj->name = $data->$fieldname;
-  }
-  return theme('username', $obj);
-}
-
-/*
- * Format a field as a link to a comment.
- */
-function views_handler_field_commentlink($fieldinfo, $fielddata, $value, $data) {
-  if ($fielddata['options'] == 'nolink') {
-    return check_plain($value);
-  }
-  return l($value, "node/$data->nid", NULL, NULL, "comment-$data->comments_cid");
-}
-
-/*
- * Format a field as a number of comments, plus the number of unread comments.
- */
-function views_handler_comments_with_new($fieldinfo, $fielddata, $value, $data) {
-  $comments = intval($value);
-  if ($comments && $new = nodecomment_num_new($data->nid)) {
-    $comments .= ' ';
-    //comment_page_new_query($data->nid)
-    $comments .= l(t('@num new', array('@num' => $new)), "node/$data->nid", NULL, NULL, 'new');
-  }
-  return $comments;
-}
-
-/*
- * Format a field as a link to a 'mark', stating whether or not the comment has
- * updated since it was last viewed by the user.
- */
-function views_handler_field_commentlink_with_mark($fieldinfo, $fielddata, $value, $data) {
-  if ($fielddata['options'] == 'nolink') {
-    $link = check_plain($value);
-  }
-  else {
-    $link = l($value, "node/$data->nid", NULL, NULL, "comment-$data->comments_cid");
-  }
-  return $link .' '. theme('mark', node_mark($data->nid, $data->comments_timestamp));
-}
-
-function nodecomment_views_handler_sort_thread($op, &$query, $sortinfo, $sortdata) {
-  // For descending sorts, natural order is ok.
-  if ($sortdata['sortorder'] == 'DESC') {
-    $query->add_orderby($sortinfo['table'], $sortinfo['field'], 'DESC');
-  }
-  // For ascending sorts special logic is needed so that only the top level
-  // of the thread is sorted ascending, but the sub-threads are sorted DESC.
-  // See code comments for comment_render.
-  else {
-    $alias = $sortdata['field'];
-    $query->orderby[] = "SUBSTRING($alias, 1, (LENGTH($alias) - 1))";
-  }
-}
-
-function theme_nodecomment_threaded_comments($view, $nodes, $type) {
-  $divs = 0;
-  $last_depth = 0;
-  drupal_add_css(drupal_get_path('module', 'comment') .'/comment.css');
-  foreach ($nodes as $n) {
-    $node = node_load($n->nid);
-    $node->depth = count(explode('.', $node->thread)) - 1;
-
-
-    if ($node->depth > $last_depth) {
-      $divs++;
-      $output .= '<div class="indented">';
-      $last_depth++;
-    }
-    else {
-      while ($node->depth < $last_depth) {
-        $divs--;
-        $output .= '</div>';
-        $last_depth--;
-      }
-    }
-
-    if ($mode == COMMENT_MODE_THREADED_COLLAPSED) {
-      //$output .= theme('comment_thread_collapsed', $node);
-    }
-    // $mode == COMMENT_MODE_THREADED_EXPANDED
-    else {
-      $output .= theme('nodecomment_view', $node);
-    }
-  }
-  for ($i = 0; $i < $divs; $i++) {
-    $output .= '</div>';
-  }
-
-  return $output;
-}
-
-function theme_nodecomment_view($comment) {
-  static $first_new = TRUE;
-
-  $output = '';
-  $comment->new = node_mark($comment->nid, $comment->timestamp);
-  if ($first_new && $comment->new != MARK_READ) {
-    // Assign the anchor only for the first new comment. This avoids duplicate
-    // id attributes on a page.
-    $first_new = FALSE;
-    $output .= "<a id=\"new\"></a>\n";
-  }
-
-  $output .= "<a id=\"comment-$comment->nid\"></a>\n";
-
-  // Switch to folded/unfolded view of the comment
-  $output .= node_view($comment, FALSE, FALSE, TRUE);
-
-  return $output;
-}
