From d016fb14f43976ba184d3e0597065b15f5eca1f0 Mon Sep 17 00:00:00 2001
From: natrak <>
Date: Wed, 25 Jul 2001 12:21:48 +0000
Subject: [PATCH] common.inc - format_username() now takes a second optional
 parameter which gives the   real name of the user.

Rest
- updated the calls to format_username() where appropriate to show the name
  of the user instead of the account id. Clicking on a name will still give you
  the account info etc. If you find a place where the real name is not shown
  let me know.
---
 account.php                | 8 ++++----
 includes/comment.inc       | 6 +++---
 includes/node.inc          | 2 +-
 includes/search.inc        | 2 +-
 modules/rating.module      | 4 ++--
 node.php                   | 6 +++---
 themes/goofy/goofy.theme   | 4 ++--
 themes/jeroen/jeroen.theme | 4 ++--
 8 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/account.php b/account.php
index af220522014d..0ac0b7ab25be 100644
--- a/account.php
+++ b/account.php
@@ -404,10 +404,10 @@ function account_track_site() {
   while ($node = db_fetch_object($nresult)) {
     $output .= "<LI>". format_plural($node->count, "comment", "comments") ." ". t("attached to") ." '<A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A>':</LI>";
 
-    $cresult = db_query("SELECT c.subject, c.cid, c.pid, u.userid FROM comments c LEFT JOIN users u ON u.id = c.author WHERE c.lid = $node->nid ORDER BY c.timestamp DESC LIMIT $node->count");
+    $cresult = db_query("SELECT c.subject, c.cid, c.pid, u.userid, u.name FROM comments c LEFT JOIN users u ON u.id = c.author WHERE c.lid = $node->nid ORDER BY c.timestamp DESC LIMIT $node->count");
     $output .= "<UL>\n";
     while ($comment = db_fetch_object($cresult)) {
-      $output .= " <LI>'<A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>' ". t("by") ." ". format_username($comment->userid) ."</LI>\n";
+      $output .= " <LI>'<A HREF=\"node.php?id=$node->nid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A>' ". t("by") ." ". format_username($comment->userid, $comment->name) ."</LI>\n";
     }
     $output .= "</UL>\n";
   }
@@ -416,13 +416,13 @@ function account_track_site() {
 
   unset($output);
 
-  $result = db_query("SELECT n.title, n.nid, n.type, n.status, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE ". time() ." - n.timestamp < $period ORDER BY n.timestamp DESC LIMIT 10");
+  $result = db_query("SELECT n.title, n.nid, n.type, n.status, u.userid, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE ". time() ." - n.timestamp < $period ORDER BY n.timestamp DESC LIMIT 10");
 
   if (db_num_rows($result)) {
     $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
     $output .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Status") ."</TH></TR>\n";
     while ($node = db_fetch_object($result)) {
-      $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD></TR>";
+      $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_username($node->userid, $node->name) ."</TD><TD ALIGN=\"center\">$node->type</TD><TD>". node_status($node->status) ."</TD></TR>";
     }
     $output .= "</TABLE>";
   }
diff --git a/includes/comment.inc b/includes/comment.inc
index 870d5feb81dd..757a27c8933e 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -52,7 +52,7 @@ function comment_form($edit) {
   global $REQUEST_URI, $user;
 
   // name field:
-  $form .= form_item(t("Your name"), format_username($user->userid));
+  $form .= form_item(t("Your name"), format_username($user->userid, $user->name));
 
   // subject field:
   $form .= form_textfield(t("Subject"), "subject", $edit[subject], 50, 64);
@@ -216,7 +216,7 @@ function comment_view($comment, $folded = 0) {
 
   // display comment:
   if ($folded) $theme->comment($comment, $folded);
-  else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_username($comment->userid) ." <SMALL>($comment->score)</SMALL><P>";
+  else print "<A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A> by ". format_username($comment->userid, $comment->name) ." <SMALL>($comment->score)</SMALL><P>";
 }
 
 function comment_thread_min($cid, $threshold) {
@@ -278,7 +278,7 @@ function comment_render($lid, $cid) {
         print " <TR><TH>Subject</TH><TH>Author</TH><TH>Date</TH><TH>Score</TH></TR>\n";
         while ($comment = db_fetch_object($result)) {
           if (comment_visible($comment, $threshold)) {
-            print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
+            print " <TR><TD><A HREF=\"". comment_uri("id=$comment->lid&cid=$comment->cid#$comment->cid") ."\">". check_output($comment->subject) ."</A></TD><TD>". format_username($comment->userid, $comment->name) ."</TD><TD>". format_date($comment->timestamp, "small") ."</TD><TD>". comment_score($comment) ."</TD></TR>\n";
           }
         }
         print "</TABLE>\n";
diff --git a/includes/node.inc b/includes/node.inc
index 1653415d121d..de8b36f19fdf 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -16,7 +16,7 @@ function _node_get($conditions) {
   }
 
   if ($type) {
-    return db_query("SELECT n.*, l.*, u.userid FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE $where ORDER BY n.timestamp DESC");
+    return db_query("SELECT n.*, l.*, u.userid, u.name FROM node n LEFT JOIN $type l ON n.lid = l.lid AND n.nid = l.nid LEFT JOIN users u ON n.author = u.id WHERE $where ORDER BY n.timestamp DESC");
   }
 }
 
diff --git a/includes/search.inc b/includes/search.inc
index e3cd239c3389..5be56fb48b48 100644
--- a/includes/search.inc
+++ b/includes/search.inc
@@ -14,7 +14,7 @@ function search_data($keys, $type) {
     foreach ($result as $entry) {
       $output .= "<p>\n";
       $output .= " <b><u><a href=\"$entry[link]\" />$entry[title]</a></u></b><br />";
-      $output .= " <small>$entry[link]". ($entry[user] ? " - ". format_username($entry[user]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>";
+      $output .= " <small>$entry[link]". ($entry[user] ? " - ". format_username($entry[user], $entry[name]) : "") ."". ($entry[date] ? " - ". format_date($entry[date], "small") : "") ."</small>";
       $output .= "</p>\n";
     }
   }
diff --git a/modules/rating.module b/modules/rating.module
index 166edd12fc97..1cc82c381dca 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -79,12 +79,12 @@ function rating_gravity($id) {
 }
 
 function rating_list($limit) {
-  $result = db_query("SELECT u.userid, u.rating, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit");
+  $result = db_query("SELECT u.userid, u.rating, u.name, r.* FROM users u LEFT JOIN rating r ON u.id = r.user ORDER BY u.rating DESC LIMIT $limit");
 
   $output .= "<TABLE CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
   while ($account = db_fetch_object($result)) {
     $ranking = $account->old - $account->new;
-    $output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_username($account->userid) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>";
+    $output .= "<TR><TD ALIGN=\"right\">". ++$i .".</TD><TD>". format_username($account->userid, $account->name) ."</TD><TD ALIGN=\"right\">". check_output($account->rating) ."</TD><TD>(". ($ranking < 0 ? "" : "+") ."$ranking)</TD></TR>";
   }
   $output .= "</TABLE>\n";
   return $output;
diff --git a/node.php b/node.php
index e6db419138d0..7482e977dc2d 100644
--- a/node.php
+++ b/node.php
@@ -77,7 +77,7 @@ function node_failure() {
 function node_history($node) {
   global $status;
   if ($node->status == $status[expired] || $node->status == $status[posted]) {
-    $output .= "<DT><B>". format_date($node->timestamp) ." by ". format_username($node->userid) .":</B></DT><DD>". check_output($node->log, 1) ."<P></DD>";
+    $output .= "<DT><B>". format_date($node->timestamp) ." by ". format_username($node->userid, $node->name) .":</B></DT><DD>". check_output($node->log, 1) ."<P></DD>";
   }
   if ($node->pid) {
     $output .= node_history(node_get_object(array("nid" => $node->pid)));
@@ -88,11 +88,11 @@ function node_history($node) {
 $number = ($title ? db_result(db_query("SELECT COUNT(nid) FROM node WHERE title = '$title' AND status = $status[posted]")) : 1);
 
 if ($number > 1) {
-  $result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = '$title'");
+  $result = db_query("SELECT n.*, u.userid, u.name FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.title = '$title'");
 
   while ($node = db_fetch_object($result)) {
     if (node_access($node)) {
-      $output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_username($node->userid) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>";
+      $output .= "<P><B><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></B><BR><SMALL>$node->type - ". format_username($node->userid, $node->name) ." - ". format_date($node->timestamp, "small") ."</SMALL></P>";
     }
   }
 
diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme
index b2b7bea4cf77..6c338b18af05 100644
--- a/themes/goofy/goofy.theme
+++ b/themes/goofy/goofy.theme
@@ -102,7 +102,7 @@ function linksbar() { // helper function to prevent double code
     function node($node, $main = 0) {
       echo "\n<!-- node: \"$node->title\" -->\n";
       $title = check_output($node->title);
-      $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_username($node->userid), "%b" => format_date($node->timestamp, "large")));
+      $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp, "large")));
       $subright = node_index($node);
       $body = check_output($node->body, 1) . ($main ? "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links(link_node($node)) . " ]</div>" : "");
       print "<script language=\"JavaScript\"><!--\ns(\"". $this->stripbreaks(addslashes($title)) ."\",\"". $this->stripbreaks(addslashes($subleft)) ."\",\"". $this->stripbreaks(addslashes($subright)) ."\",\"". $this->stripbreaks(addslashes($body)) ."\"); // -->\n</script>\n";
@@ -112,7 +112,7 @@ function node($node, $main = 0) {
     function comment($comment, $link = "") {
       echo "<A NAME=\"$comment->cid\"></A>\n";
 
-      $author = "<b>" . format_username($comment->userid) . "</b>";
+      $author = "<b>" . format_username($comment->userid, $comment->name) . "</b>";
       if ($comment->userid) {
         if ($comment->fake_email) $info[] = format_email($comment->fake_email);
         if (eregi("http://",$comment->url)) $info[] = format_url($comment->url);
diff --git a/themes/jeroen/jeroen.theme b/themes/jeroen/jeroen.theme
index 7c9a1a03f46f..b91cd71f8bda 100644
--- a/themes/jeroen/jeroen.theme
+++ b/themes/jeroen/jeroen.theme
@@ -117,7 +117,7 @@ function node($node, $main = 0) {
                                       case 12: $how = "Forged"; break;
                                       default: $how = "Sneaked through";
                                     }
-                                    echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($node->userid), "%b" => format_date($node->timestamp), "large")) ."</FONT>";
+                                    echo "<FONT SIZE=\"-1\">". strtr(t("$how by %a on %b"), array("%a" => format_username($node->userid, $node->name), "%b" => format_date($node->timestamp), "large")) ."</FONT>";
 ?>
                                   </FONT>
                                 </td>
@@ -192,7 +192,7 @@ function comment($comment, $link = "") {
 
       // Author:
       echo "                        <tr>";
-      echo "                          <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_username($comment->userid) ."</B> ";
+      echo "                          <td align=\"right\"><FONT COLOR=\"#FEFEFE\">". t("Author") .":</FONT></td><td><B>". format_username($comment->userid, $comment->name) ."</B> ";
                                         if ($comment->userid) {
       // Display extra information line:
                                           if ($comment->fake_email) $info .= format_email($comment->fake_email);
-- 
GitLab