diff options
author | Yorhel <git@yorhel.nl> | 2008-11-15 12:39:02 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2008-11-15 12:39:02 +0100 |
commit | c6c8b37d60dfd8943a860043f61a9344ddb1dda6 (patch) | |
tree | fbe3aafdabc514b5e9ed5f3a906318c14bd20801 | |
parent | 0dd998b8b90f9a57025e4de0386dd7646f756af7 (diff) |
Proper display of deleted usernames
Well, 'proper'... I should fix the handling of deleted users in
the database, as the current solution is far from perfect.
-rw-r--r-- | lib/VNDB/Func.pm | 9 | ||||
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 2 |
3 files changed, 10 insertions, 3 deletions
diff --git a/lib/VNDB/Func.pm b/lib/VNDB/Func.pm index ef18c837..d2f86cf1 100644 --- a/lib/VNDB/Func.pm +++ b/lib/VNDB/Func.pm @@ -5,7 +5,7 @@ use strict; use warnings; use Exporter 'import'; use POSIX 'strftime'; -our @EXPORT = qw| shorten date datestr bb2html |; +our @EXPORT = qw| shorten date datestr userstr bb2html |; # I would've done this as a #define if this was C... @@ -47,6 +47,13 @@ sub datestr { } +# Arguments: (uid, username), or a hashref containing that info +sub userstr { + my($id,$n) = ref($_[0])eq'HASH'?($_[0]{uid}||$_[0]{requester}, $_[0]{username}):@_; + return !$id ? '[deleted]' : '<a href="/u'.$id.'">'.$n.'</a>'; +} + + # Arguments: input, and optionally the maximum length # Parses: # [url=..] [/url] diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index ea30336f..b2a7af03 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -88,7 +88,7 @@ sub history { end; td date $i->{added}; td; - a href => "/u$i->{requester}", $i->{username}; + lit userstr($i); end; td; a href => $revurl, title => $i->{ioriginal}, shorten $i->{ititle}, 80; diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index 6540a508..87942484 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -245,7 +245,7 @@ sub revheader { # type, obj txt ')'; br; txt 'By '; - a href => "/u$obj->{requester}", $obj->{username}; + lit userstr($obj); txt ' on '; lit date $obj->{added}, 'full'; } |