Commit d016fb14 authored by natrak's avatar natrak
Browse files

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.
parent e0dc03dc
......@@ -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>";
}
......
......@@ -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";
......
......@@ -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");
}
}
......
......@@ -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";
}
}
......
......@@ -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;
......
......@@ -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>";
}
}
......
......@@ -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);
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment