? .xvpics
? TODO
? comment-1.240-2.diff
? comment.patch
? files
? search-replace.sh
? tabs.patch
? includes/dione.drupal.org.cvs.php
Index: database/database.mysql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.mysql,v
retrieving revision 1.128
diff -u -r1.128 database.mysql
--- database/database.mysql	10 May 2004 20:34:24 -0000	1.128
+++ database/database.mysql	15 May 2004 15:04:07 -0000
@@ -185,6 +185,9 @@
   status tinyint(3) unsigned NOT NULL default '0',
   thread varchar(255) NOT NULL,
   users longtext,
+  name varchar(60) NOT NULL default '',
+  mail varchar(64) default '',
+  url varchar(255) default NULL,
   PRIMARY KEY  (cid),
   KEY lid (nid)
 ) TYPE=MyISAM;
Index: database/database.pgsql
===================================================================
RCS file: /cvs/drupal/drupal/database/database.pgsql,v
retrieving revision 1.65
diff -u -r1.65 database.pgsql
--- database/database.pgsql	10 May 2004 20:34:24 -0000	1.65
+++ database/database.pgsql	15 May 2004 15:04:08 -0000
@@ -185,6 +185,9 @@
   status smallint  NOT NULL default '0',
   thread varchar(255) default '',
   users text default '',
+  name varchar(60) NOT NULL default '',
+  mail varchar(64) default '',
+  url varchar(255) default NULL,
   PRIMARY KEY  (cid)
 );
 CREATE INDEX comments_nid_idx ON comments(nid);
Index: database/updates.inc
===================================================================
RCS file: /cvs/drupal/drupal/database/updates.inc,v
retrieving revision 1.14
diff -u -r1.14 updates.inc
--- database/updates.inc	13 May 2004 18:19:29 -0000	1.14
+++ database/updates.inc	15 May 2004 15:04:11 -0000
@@ -1,5 +1,5 @@
 <?php
-/* $Id: updates.inc,v 1.14 2004/05/13 18:19:29 dries Exp $ */
+/* $Id: updates.inc,v 1.13 2004/05/10 20:34:24 dries Exp $ */
 
 // Define the various updates in an array("date : comment" => "function");
 $sql_updates = array(
@@ -57,7 +57,8 @@
   "2004-04-15" => "update_83",
   "2004-04-21" => "update_84",
   "2004-04-27" => "update_85",
-  "2004-05-10" => "update_86"
+  "2004-05-10" => "update_86",
+  "2004-05-15" => "update_87"
 );
 
 function update_32() {
@@ -1084,6 +1085,14 @@
   return $ret;
 }
 
+function update_87() {
+  $ret = array();
+  $ret[] = update_sql("ALTER TABLE {comments} ADD name varchar(60)");
+  $ret[] = update_sql("ALTER TABLE {comments} ADD mail varchar(64)");
+  $ret[] = update_sql("ALTER TABLE {comments} ADD homepage varchar(255)");
+  return $ret;
+}
+
 function update_sql($sql) {
   $edit = $_POST["edit"];
   $result = db_query($sql);
Index: modules/comment.module
===================================================================
RCS file: /cvs/drupal/drupal/modules/comment.module,v
retrieving revision 1.240
diff -u -r1.240 comment.module
--- modules/comment.module	10 May 2004 21:30:31 -0000	1.240
+++ modules/comment.module	15 May 2004 15:04:39 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: comment.module,v 1.240 2004/05/10 21:30:31 dries Exp $
+// $Id: comment.module,v 1.8 2004/05/05 20:29:53 pablobm Exp $
 
 function comment_help($section = "admin/help#comment") {
   $output = "";
@@ -120,7 +120,11 @@
   $group .= form_radios(t("Comment controls"), "comment_controls", variable_get("comment_controls", 0), array(t("Display above the comments"), t("Display below the comments"), t("Display above and below the comments"), t("Do not display")), t("Position of the comment controls box.  The comment controls let the user change the default display mode and display order of comments."));
   $output = form_group(t('Comment viewing options'), $group);
 
-  $group  = form_radios(t("Preview comment"), "comment_preview", variable_get("comment_preview", 1), array(t("Optional"), t("Required")), t("Must users preview comments before submitting?"));
+  $group  = form_checkbox(t('Show subject field'), 'comment_subject_field', 1, variable_get('comment_subject_field', 1));
+  $group .= form_checkbox(t('Show name field for anonymous users'), 'comment_name_field', 1, variable_get('comment_name_field', 0));
+  $group .= form_checkbox(t('Show e-mail address field for anonymous users'), 'comment_mail_field', 1, variable_get('comment_mail_field', 0));
+  $group .= form_checkbox(t('Show homepage field for anonymous users'), 'comment_homepage_field', 1, variable_get('comment_homepage_field', 0));
+  $group .= form_radios(t("Preview comment"), "comment_preview", variable_get("comment_preview", 1), array(t("Optional"), t("Required")), t("Must users preview comments before submitting?"));
   $group .= form_radios(t("Location of comment submission form"), "comment_form_location", variable_get("comment_form_location", 0), array(t("Display on separate page"), t("Display below post or comments")), t("The location of the comment submission form."));
   $output .= form_group(t('Comment posting settings'), $group);
 
@@ -171,8 +175,9 @@
 function comment_edit($cid) {
   global $user;
 
-  $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $cid));
+  $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2', $cid));
   $comment = drupal_unpack($comment);
+  $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
   if (comment_access("edit", $comment)) {
     return comment_preview(object2array($comment));
   }
@@ -189,8 +194,9 @@
     */
 
     if ($pid) {
-      $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $pid));
+      $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0', $pid));
       $comment = drupal_unpack($comment);
+      $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
       $output .= theme("comment_view", $comment);
     }
     else if (user_access("access content")) {
@@ -233,7 +239,7 @@
   */
 
   $comment->uid = $user->uid;
-  $comment->name = $user->name;
+  $comment->name = $user->name ? $user->name : $comment->name;
   $comment->timestamp = time();
 
   /*
@@ -244,8 +250,9 @@
   $output .= theme("comment_form", $edit, t("Reply"));
 
   if ($edit["pid"]) {
-    $comment = db_fetch_object(db_query("SELECT c.*, u.uid, u.name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0", $edit["pid"]));
+    $comment = db_fetch_object(db_query('SELECT c.*, u.uid, u.name AS registered_name, u.picture, u.data FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0', $edit["pid"]));
     $comment = drupal_unpack($comment);
+    $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
     $output .= theme("comment_view", $comment);
   }
   else {
@@ -281,6 +288,32 @@
     }
 
     /*
+    ** Check validity of name, mail and homepage (if given)
+    */
+
+    $edit['name'] = strip_tags($edit['name']);
+
+    if (!$user->uid) {
+      $nametaken = db_result(db_query("SELECT COUNT(uid) FROM {users} WHERE name = '%s'", $edit['name']), 0);
+
+      if ($nametaken != 0) {
+        return array(t('Name already taken'), t('The name you used as your signature belongs to a registered user.'));
+      }
+    }
+
+    if ($edit['mail']) {
+      if (!valid_email_address($edit['mail'])) {
+        return array(t('Invalid e-mail address'), t('The e-mail address you specifed is not valid.'));
+      }
+    }
+
+    if ($edit['homepage']) {
+      if (!valid_url($edit['homepage'], TRUE)) {
+        return array(t('Invalid URL for homepage'), t('The URL (web address) you specifed is not valid. Remember that it must be fully qualified, i.e. of the form <code>http://yourhomepage.com/directory</code>.'));
+      }
+    }
+
+    /*
     ** Check for duplicate comments.  Note that we have to use the
     ** validated/filtered data to perform such check.
     */
@@ -419,7 +452,7 @@
 
         $edit["cid"] = db_next_id("{comments}_cid");
 
-        db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users, thread) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], $_SERVER['REMOTE_ADDR'], time(), $status, $score, $users, $thread);
+        db_query("INSERT INTO {comments} (cid, nid, pid, uid, subject, comment, hostname, timestamp, status, score, users, thread, name, mail, homepage) VALUES (%d, %d, %d, %d, '%s', '%s', '%s', %d, %d, %d, '%s', '%s', '%s', '%s', '%s')", $edit["cid"], $edit["nid"], $edit["pid"], $user->uid, $edit["subject"], $edit["comment"], $_SERVER['REMOTE_ADDR'], time(), $status, $score, $users, $thread, $edit["name"], $edit['mail'], $edit["homepage"]);
 
         /*
         ** Tell the other modules a new comment has been submitted:
@@ -542,9 +575,10 @@
       $output .= "<form method=\"post\" action=\"". url("comment") ."\"><div>\n";
       $output .= form_hidden("nid", $nid);
 
-      $result = db_query("SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users", $cid);
+      $result = db_query('SELECT c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.name, c.mail, c.homepage FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status = 0 GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users', $cid);
 
       if ($comment = db_fetch_object($result)) {
+        $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
         $output .= theme("comment_view", $comment, theme('links', module_invoke_all('link', 'comment', $comment, 1)));
       }
 
@@ -559,7 +593,7 @@
       ** Multiple comments view
       */
 
-      $query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
+      $query .= "SELECT c.cid as cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, c.name, c.mail, u.uid, u.name AS registered_name, u.picture, u.data, c.score, c.users, c.thread, c.name , c.mail, c.homepage FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.nid = '". check_query($nid) ."' AND c.status = 0";
 
       $query .= " GROUP BY c.cid, c.pid, c.nid, c.subject, c.comment, c.timestamp, u.uid, u.name, u.picture, u.data, c.score, c.users, c.thread";
 
@@ -667,6 +701,7 @@
 
       while ($comment = db_fetch_object($result)) {
         $comment = drupal_unpack($comment);
+        $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
         $comment->depth = count(explode(".", $comment->thread)) - 1;
 
         if ($mode == 1) {
@@ -861,12 +896,13 @@
     ** Edit comments:
     */
 
-    $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE nid = %d AND c.status = 0 ORDER BY c.timestamp", $node->nid);
+    $result = db_query('SELECT c.cid, c.subject, c.name, u.uid, u.name AS registered_name, c.name FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE nid = %d AND c.status = 0 ORDER BY c.timestamp', $node->nid);
 
 
     $header = array(t("title"), t("author"), array("data" => t("operations"), "colspan" => 3));
 
     while ($comment = db_fetch_object($result)) {
+      $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
       $rows[] = array(l($comment->subject, "node/view/$node->nid", NULL, NULL, "comment-$comment->cid"), format_name($comment), l(t("view comment"), "node/view/$node->nid", NULL, NULL, $comment->cid), l(t("edit comment"), "admin/comment/edit/$comment->cid"), l(t("delete comment"), "admin/comment/delete/$comment->cid"));
     }
 
@@ -881,8 +917,9 @@
 
 function comment_admin_edit($id) {
 
-  $result = db_query("SELECT c.*, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2", $id);
+  $result = db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE c.cid = %d AND c.status != 2', $id);
   $comment = db_fetch_object($result);
+  $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
   $comment = drupal_unpack($comment);
 
   if ($comment) {
@@ -910,7 +947,8 @@
 }
 
 function comment_delete($cid, $confirmed = 0) {
-  $comment = db_fetch_object(db_query("SELECT c.*, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d", $cid));
+  $comment = db_fetch_object(db_query('SELECT c.*, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.cid = %d', $cid));
+  $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
 
   if ($comment->cid) {
     if ($confirmed) {
@@ -963,11 +1001,12 @@
     array("data" => t("operations"), "colspan" => 2)
   );
 
-  $sql = "SELECT c.*, u.name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = ". check_query($status);
+  $sql = 'SELECT c.subject, c.nid, c.cid, c.comment, c.timestamp, c.status, c.name, u.name AS registered_name, u.uid FROM {comments} c INNER JOIN {users} u ON u.uid = c.uid WHERE c.status = '. check_query($status);
   $sql .= tablesort_sql($header);
   $result = pager_query($sql,  50);
 
   while ($comment = db_fetch_object($result)) {
+    $comment->name = $comment->registered_name ? $comment->registered_name : $comment->name;
     $rows[] = array(l($comment->subject, "node/view/$comment->nid/$comment->cid", array("title" => htmlspecialchars(truncate_utf8($comment->comment, 128))), NULL, "comment-$comment->cid") ." ". (node_is_new($comment->nid, $comment->timestamp) ? theme("mark") : ""), format_name($comment), ($comment->status == 0 ? t("published") : t("not published")) ."</td><td>". format_date($comment->timestamp, "small") ."</td><td>". l(t("edit comment"), "admin/comment/edit/$comment->cid"), l(t("delete comment"), "admin/comment/delete/$comment->cid"));
   }
 
@@ -1227,10 +1266,29 @@
   $form .= "<a id=\"comment\"></a>\n";
 
   // name field:
-  $form .= form_item(t("Your name"), format_name($user));
+  if ($user->uid) {
+    $form .= form_item(t('Your name'), format_name($user));
+  }
+  else if (variable_get('comment_name_field', 0)) {
+    $form .= form_textfield(t('Your name'), 'name', $edit[name] ? $edit[name] : variable_get('anonymous', 'Anonymous') , 20, 40);
+  }
+
+
+  // e-mail field
+  if (! $user->uid && variable_get('comment_mail_field', 0)) {
+    $form .= form_textfield(t('E-Mail'), 'mail', $edit['mail'], 20, 40);
+  }
+
+  // homepage field
+  if (! $user->uid && variable_get('comment_homepage_field', 0)) {
+    $form .= form_textfield(t('Homepage'), 'homepage', $edit['homepage'], 20, 40);
+  }
+
 
   // subject field:
-  $form .= form_textfield(t("Subject"), "subject", $edit["subject"], 50, 64);
+  if (variable_get('comment_subject_field', 0)) {
+    $form .= form_textfield(t('Subject'), 'subject', $edit['subject'], 50, 64);
+  }
 
   // comment field:
   $form .= form_textarea(t("Comment"), "comment", $edit["comment"] ? $edit["comment"] : $user->signature, 70, 10, filter_tips_short());
@@ -1378,18 +1436,35 @@
   $output  = "<div class=\"comment\">\n";
   $output .= "<div class=\"subject\">$comment->subject". ($comment->new ? ' '. theme('mark') : '') ."</div>\n";
   $output .= "<div class=\"moderation\">". $comment->moderation ."</div>\n";
-  $output .= "<div class=\"credit\">". t("by %a on %b", array("%a" => format_name($comment), "%b" => format_date($comment->timestamp))) ."</div>\n";
+
+  $output .= "<div class=\"credit\">";
+  $output .= t('by %a on %b', array('%a' => theme('comment_name', $comment), '%b' => format_date($comment->timestamp))) . "\n";
+  $output .= "</div>\n";
+
   $output .= "<div class=\"body\">". check_output($comment->comment) ."</div>\n";
   $output .= "<div class=\"links\">$links</div>\n";
   $output .= "</div>\n";
   return $output;
 }
 
+function theme_comment_name($comment) {
+  if ($comment->uid) {
+    $output = format_name($comment);
+  }
+  else {
+    $name = $comment->name;
+    $name = $comment->homepage ? '<a href="' . $comment->homepage . '" title="' . t("Link to %a's homepage", array("%a" => $name)) . '">' . $name . '</a>' : $name;
+    $name .= $comment->mail ? ' &lt;<a href="mailto://' . $comment->mail . '" title="' . t("%a's e-mail address", array("%a" => $comment->name)) . '">' . $comment->mail . '</a>&gt;' : '';
+    $output = $name . ' (' . t("identity not verified") . ')' ;
+  }
+  return $output;
+}
+
 function theme_comment_folded($comment) {
-  $output  = "<div class=\"comment-folded\">\n";
-  $output .= " <span class=\"subject\">". l($comment->subject, comment_node_url() ."/$comment->cid", NULL, NULL, "comment-$comment->cid") . ($comment->new ? ' '. theme('mark') : '') ."</span> ";
-  $output .= "<span class=\"credit\">". t("by") ." ". format_name($comment) ."</span>\n";
-  $output .= "</div>\n";
+  $output  = '<div class="comment-folded">';
+  $output .= ' <span class="subject">'. l($comment->subject, comment_node_url() ."/$comment->cid", NULL, NULL, "comment-$comment->cid") . ($comment->new ? ' '. theme('mark') : '') .'</span> ';
+  $output .= '<span class="credit">'. t('by') .' '. theme('comment_name', $comment) .'</span>';
+  $output .= '</div>';
   return $output;
 }
 
@@ -1600,6 +1675,9 @@
   **
   ** The select statement may optionally provide "nid", which is a secondary
   ** identifier which is currently used byt the comment module.
+  **
+  ** Notice this will not search through comments table 'name' field, but will
+  ** do through users table one.
   */
 
   $find = do_search(array("keys" => $keys, "type" => "comment", "select" => "select s.lno as lno, c.nid as nid, c.subject as title, c.timestamp as created, u.uid as uid, u.name as name, s.count as count FROM {search_index} s, {comments} c INNER JOIN {users} u ON c.uid = u.uid WHERE s.lno = c.cid AND s.type = 'comment' AND c.status = 0 AND s.word like '%'"));
