? .DS_Store
? d6port.patch
? nodecomment.admin.inc
? nodecomment.views.inc
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	7 Jul 2008 18:38:23 -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
diff -u -p -r1.1 nodecomment.install
--- nodecomment.install	10 Jan 2007 21:36:06 -0000	1.1
+++ nodecomment.install	7 Jul 2008 18:38:23 -0000
@@ -1,17 +1,88 @@
 <?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';
+  include_once './'. drupal_get_path('module', 'user') .'/user.module';
+  $types = node_get_types();
+  $types = array_change_key_case($types, CASE_LOWER);
+
+  if (!in_array('comment', array_keys($types))) {
+    // Create the comment content type.
+    $nodecomment_node_type = array(
+      'type' => 'comment',
+      'name' => t('Comment'),
+      'module' => 'node',
+      'description' => t('A comment for use with the nodecomment module.'),
+      'title_label' => t('Subject'),
+      'body_label' => t('Body'),
+      'custom' => TRUE,
+      'modified' => TRUE,
+      'locked' => FALSE,
+    );
+    $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();
+    node_types_rebuild();
+  }
+}
+
+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() {
+  drupal_uninstall_schema('nodecomment');
 }
 
-?>
\ No newline at end of file
+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.4
diff -u -p -r1.4 nodecomment.module
--- nodecomment.module	6 Mar 2007 05:51:19 -0000	1.4
+++ nodecomment.module	7 Jul 2008 18:38:24 -0000
@@ -10,11 +10,7 @@
  * a forum topic, weblog post, story, collaborative book page, etc.
  */
 
-if (module_exists('views')) {
-  include_once(drupal_get_path('module', 'nodecomment') . '/nodecomment_views.inc');
-}
-
-/*
+/**
  * Constants to define a comment's published state
  */
 define('COMMENT_PUBLISHED', 0);
@@ -84,37 +80,23 @@ 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."),
-    );
-
-    $items[] = array(
-      'path' => 'nodecomment/edit', 
-      'title' => t('Edit comment'),
-      'callback' => 'nodecomment_edit',
-      'access' => user_access('post comments'), 
-      'type' => MENU_CALLBACK,
-    );
-  }
-  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',
+    'description' => "Administer your site's comment settins.",
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('nodecomment_admin_settings'),
+    'access arguments' => array('administer comments'),
+    'file' => 'nodecomment.admin.inc',
+  );
+  
+  $items['node/%node/%node'] = array(
+    'title' => 'View',
+    'page callback' => 'node_page_view',    
+    'type' => MENU_CALLBACK,
+  );
 
   return $items;
 }
@@ -131,63 +113,14 @@ function nodecomment_perm() {
   );
 }
 
-
 /**
- * Menu callback; presents the comment settings page.
+ * Implementation of hook_form_alter().
  */
-function nodecomment_admin_settings() {
-  $form['posting_settings'] = array(
-    '#type' => 'fieldset',
-    '#title' => t('Posting settings'),
-    '#collapsible' => FALSE,
-    '#collapsed' => FALSE,
-  );
-
-  $form['posting_settings']['comment_anonymous'] = array(
-    '#type' => 'radios',
-    '#title' => t('Anonymous commenting'),
-    '#default_value' => variable_get('comment_anonymous', COMMENT_ANONYMOUS_MAYNOT_CONTACT),
-    '#options' => array(
-      COMMENT_ANONYMOUS_MAYNOT_CONTACT => t('Anonymous posters may not enter their contact information'),
-      COMMENT_ANONYMOUS_MAY_CONTACT => t('Anonymous posters may leave their contact information'),
-      COMMENT_ANONYMOUS_MUST_CONTACT => t('Anonymous posters must leave their contact information')),
-    '#description' => t('This option is enabled when anonymous users have permission to post comments on the <a href="@url">permissions page</a>.', array('@url' => url('admin/user/access'))),
-  );
-  if (!user_access('post comments', user_load(array('uid' => 0)))) {
-    $form['posting_settings']['comment_anonymous']['#disabled'] = TRUE;
-  }
-
-  $form['posting_settings']['comment_preview'] = array(
-    '#type' => 'radios',
-    '#title' => t('Preview comment'),
-    '#default_value' => variable_get('comment_preview', COMMENT_PREVIEW_REQUIRED),
-    '#options' => array(t('Optional'), t('Required')),
-  );
-
-  $form['posting_settings']['comment_form_location'] = array(
-    '#type' => 'radios',
-    '#title' => t('Location of comment submission form'),
-    '#default_value' => variable_get('comment_form_location', COMMENT_FORM_SEPARATE_PAGE),
-    '#options' => array(t('Display on separate page'), t('Display below post or comments')),
-  );
-  
-  $form['posting_settings']['default_comment_type'] = array(
-    '#type' => 'select',
-    '#title' => t('Default node type for comments'),
-    '#default_value' => variable_get('default_comment_type', ''),
-    '#options' => node_get_types('names'),
-    '#description' => t('The default node type to use for posting comments.'),
-  );
-
-
-  return system_settings_form($form);
-}
-
-
-function nodecomment_form_alter($form_id, &$form) {
+function nodecomment_form_alter(&$form, $form_state, $form_id) {
   global $user;
-
+  
   if ($form_id == 'node_type_form' && isset($form['identity']['type'])) {
+    $none = array('' => '-- None --');
     $form['workflow']['comment'] = array(
       '#type' => 'radios',
       '#title' => t('Default comment setting'),
@@ -345,13 +278,6 @@ function nodecomment_disable_comment_mod
   return $form;
 }
 
-
-if (!function_exists('comment_nodeapi')) {
-  function comment_nodeapi(&$node, $op, $arg = 0) {
-    return nodecomment_nodeapi($node, $op, $arg);
-  } 
-}
-
 /**
  * Implementation of hook_user().
  *
@@ -378,6 +304,11 @@ function nodecomment_user($type, $edit, 
 /**
  * Implementation of hook_nodeapi().
  */
+if (!function_exists('comment_nodeapi')) {
+  function comment_nodeapi(&$node, $op, $arg = 0) {
+    return nodecomment_nodeapi($node, $op, $arg);
+  } 
+}
 function nodecomment_nodeapi(&$node, $op, $arg = 0) {
   // When the node HAS comments
   //   -- delete the comments
@@ -486,7 +417,6 @@ function nodecomment_form($node) {
   return drupal_get_form($comment_type . '_node_form', $new_node);
 }
 
-
 /**
  * Implementation of hook_link().
  */
@@ -549,7 +479,6 @@ function nodecomment_link($type, $node =
   return $links;
 }
 
-
 function nodecomment_links($comment, $return = 1) {
   global $user;
 
@@ -602,20 +531,19 @@ function nodecomment_links($comment, $re
 if (!function_exists('comment_render')) {
   function comment_render($node, $cid = 0) {
     return nodecomment_render($node, $cid);
-  } 
+  }
 }
-
 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 ($cid) {
+    
+    if (is_numeric($cid)) {
       // Single comment view.
       if ($comment = node_load($cid)) {
         $output = theme('node', $comment, TRUE, TRUE);
@@ -644,6 +572,7 @@ function nodecomment_render($node, $cid 
   return $output;
 }
 
+
 /**
 *** misc functions: helpers, privates, history
 **/
@@ -790,7 +719,6 @@ function _nodecomment_per_page() {
   return drupal_map_assoc(array(10, 30, 50, 70, 90, 150, 200, 250, 300));
 }
 
-
 /**
  * Updates the comment statistics for a given node. This should be called any
  * time a comment is added, deleted, or updated.
@@ -821,18 +749,99 @@ 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 nodecomment_theme() {
+  return array(
+    'nodecomment_wrapper' => array(
+      'template' => 'comment-wrapper',
+      'arguments' => array('content' => NULL, 'node' => NULL),
+    ),
+  );
+}
 
-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;
+/**
+ * Allow themable wrapping of all comments.
+ */
+function theme_nodecomment_wrapper($content, $node) {
+  return '<div id="comments">'. $content .'</div>';
+}
+
+function nodecomment_get_thread($node) {
+  // Here we are building the thread field. See the documentation for
+  // comment_render().
+  if ($node->comment_target_cid == 0) {
+    // This is a comment with no parent comment (depth 0): we start
+    // by retrieving the maximum thread level.
+    $max = db_result(db_query('SELECT MAX(thread) FROM {node_comments} WHERE nid = %d', $node->comment_target_nid));
+
+    // Strip the "/" from the end of the thread.
+    $max = rtrim($max, '/');
+
+    // Finally, build the thread field for this new comment.
+    $thread = nodecomment_int2vancode(nodecomment_vancode2int($max) + 1) .'/';
+  }
+  else {
+    // This is comment with a parent comment: we increase
+    // the part of the thread value at the proper depth.
+
+    // Get the parent comment:
+    $parent = node_load($node->comment_target_cid);
+
+    // Strip the "/" from the end of the parent thread.
+    $parent->thread = (string) rtrim((string) $parent->thread, '/');
+
+    // Get the max value in _this_ thread.
+    $max = db_result(db_query("SELECT MAX(thread) FROM {node_comments} WHERE thread LIKE '%s.%%' AND nid = %d", $parent->thread, $node->comment_target_nid));
+
+    if ($max == '') {
+      // First child of this parent.
+      $thread = $parent->thread .'.'. nodecomment_int2vancode(0) .'/';
+    }
+    else {
+      // Strip the "/" at the end of the thread.
+      $max = rtrim($max, '/');
+
+      // We need to get the value at the correct depth.
+      $parts = explode('.', $max);
+      $parent_depth = count(explode('.', $parent->thread));
+      $last = $parts[$parent_depth];
+
+      // Finally, build the thread field for this new comment.
+      $thread = $parent->thread .'.'. nodecomment_int2vancode(nodecomment_vancode2int($last) + 1) .'/';
+    }
+  }
+  return $thread;
+}
+
+
+/** Copies of comment module's vancode helper functions **/
+
+/**
+ * Generate vancode.
+ *
+ * Consists of a leading character indicating length, followed by N digits
+ * with a numerical value in base 36. Vancodes can be sorted as strings
+ * without messing up numerical order.
+ *
+ * It goes:
+ * 00, 01, 02, ..., 0y, 0z,
+ * 110, 111, ... , 1zy, 1zz,
+ * 2100, 2101, ..., 2zzy, 2zzz,
+ * 31000, 31001, ...
+ */
+function nodecomment_int2vancode($i = 0) {
+  $num = base_convert((int)$i, 10, 36);
+  $length = strlen($num);
+  return chr($length + ord('0') - 1) . $num;
+}
+
+/**
+ * Decode vancode back to an integer.
+ */
+function nodecomment_vancode2int($c = '00') {
+  return base_convert(substr($c, 1), 36, 10);
 }
