Don't let codetrace die
Patch by alierak.
diffs (114 lines):
diff -r 0aa49d0b92ad -r a0378546aba2 htdocs/admin/invitecodes.bml
--- a/htdocs/admin/invitecodes.bml Sat May 09 16:03:56 2009 +0800
+++ b/htdocs/admin/invitecodes.bml Sat May 09 08:31:27 2009 +0000
@@ -5,13 +5,13 @@ body<=
{
use strict;
use vars qw( %POST );
-
+
return LJ::server_down_html if ( $LJ::SERVER_DOWN );
-
+
my $remote = LJ::get_remote;
my @displayprivs = ( "finduser:codetrace", "finduser:*" );
my $numprivs = @displayprivs;
-
+
return "<?needlogin?>"
unless $remote;
@@ -19,7 +19,7 @@ body<=
unless LJ::check_priv( $remote, "finduser", "codetrace" );
my $ret;
-
+
$ret .= "<form method='GET'>";
$ret .= "View invite details: ";
$ret .= "<table>";
@@ -32,53 +32,51 @@ body<=
$ret .= "</td></tr></table>";
$ret .= "</form>";
$ret .= "<?hr?>";
-
+
if ( $GET{code} ) {
+
my $code = DW::InviteCodes->new( code => $GET{code} );
return $ret . "Error: invalid code '$GET{code}'" unless $code;
-
- my $owner = LJ::load_userid( $code->owner );
+
+ $ret .= display_codes ( $remote, $code );
+
+ } elsif ( $GET{account} ) {
+
+ my $account = LJ::load_user( $GET{account} );
+ return $ret . "Error: invalid user '$GET{account}'" unless $account;
+
+ my @used = DW::InviteCodes->by_recipient( userid => $account->id );
+ my @owned = DW::InviteCodes->by_owner( userid => $account->id );
+
+ $ret .= display_codes ( $account, @used, @owned );
+ }
+
+ return $ret;
+}
+
+sub display_codes {
+ my ($account, @codes) = @_;
+
+ my $ret = "<table border='1'
cellpadding='5'><tr><th>Code</th><th>Owner</th><th>Recipient</th><th>Reason</th><th>Date
generated</th><th>Date sent</th><th>Date used</th></tr>";
+
+ foreach my $code ( @codes ) {
+ my $owner = $code->owner == $account->id ? $account : LJ::load_userid(
$code->owner );
my $recipient = LJ::load_userid( $code->recipient ) if $code->is_used;
-
- $ret .= "<table border='1'
cellpadding='5'><tr><th>Code</th><th>Owner</th><th>Recipient</th><th>Reason</th><th>Date
generated</th><th>Date sent</th><th>Date used</th></tr>";
$ret .= "<tr>";
$ret .= "<td><tt>" . $code->code . "</tt></td>";
- $ret .= "<td>" . $owner->ljuser_display . "</td>";
+ $ret .= "<td>" . ( $owner ? $owner->ljuser_display : "" ) . "</td>";
$ret .= "<td>" . ( $code->is_used ? $recipient->ljuser_display : "" )
. "</td>";
$ret .= "<td>" . $code->reason . "</td>";
$ret .= "<td>" . LJ::time_to_http( $code->timegenerate). "</td>";
$ret .= "<td>" . ( $code->timesent ? LJ::time_to_http( $code->timesent
) : "" ) . "</td>";
$ret .= "<td>" . ( $code->is_used ? LJ::time_to_http(
$recipient->timecreate ) : "" ) . "</td>";
$ret .= "</tr>";
- $ret .= "</table>";
-
- } elsif ( $GET{account} ) {
-
- my $account = LJ::load_user( $GET{account} );
- return $ret . "Error: invalid user '$GET{account}'" unless $account;
-
- my @used = DW::InviteCodes->by_recipient( userid => $account->id );
- my @owned = DW::InviteCodes->by_owner( userid => $account->id );
-
- $ret .= "<table border='1'
cellpadding='5'><tr><th>Code</th><th>Owner</th><th>Recipient</th><th>Reason</th><th>Date
generated</th><th>Date sent</th><th>Date used</th></tr>";
- foreach my $code ( @used, @owned ) {
- my $owner = $code->owner == $account->id ? $account :
LJ::load_userid( $code->owner );
- my $recipient = LJ::load_userid( $code->recipient ) if
$code->is_used;
- $ret .= "<tr>";
- $ret .= "<td><tt>" . $code->code . "</tt></td>";
- $ret .= "<td>" . $owner->ljuser_display . "</td>";
- $ret .= "<td>" . ( $code->is_used ? $recipient->ljuser_display :
"" ) . "</td>";
- $ret .= "<td>" . $code->reason . "</td>";
- $ret .= "<td>" . LJ::time_to_http( $code->timegenerate). "</td>";
- $ret .= "<td>" . ( $code->timesent ? LJ::time_to_http(
$code->timesent ) : "" ) . "</td>";
- $ret .= "<td>" . ( $code->is_used ? LJ::time_to_http(
$recipient->timecreate ) : "" ) . "</td>";
- $ret .= "</tr>";
- }
- $ret .= "</table>";
}
-
+ $ret .= "</table>";
return $ret;
-} _code?>
+}
+
+ _code?>
<=body
page?>
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog