9 my $remote = LJ::get_remote;
10 my @displayprivs = ( "finduser:codetrace", "finduser:*" );
11 my $numprivs = @displayprivs;
13 return "<?needlogin?>"
16 return BML::ml( "admin.noprivserror", { numprivs => $numprivs, needprivs => "<b>" . join(", ", @displayprivs) . "</b>"} )
17 unless $remote->has_priv( "finduser", "codetrace" );
21 $ret .= "<form method='GET'>";
22 $ret .= "View invite details: ";
23 $ret .= "<table summary=''>";
24 $ret .= "<tr><td><label>By code: </label></td>";
25 $ret .= "<td>" . LJ::html_text( { name => 'code', maxlength => DW::InviteCodes::CODE_LEN, size => DW::InviteCodes::CODE_LEN } ) . "</td></tr>";
26 $ret .= "<tr><td><label>By account: </label></td>";
27 $ret .= "<td>" . LJ::html_text( { name => 'account', maxlength => 25, size=> 20 } ) . "</td></tr>";
28 $ret .= "<tr><td colspan='2' align='right'>";
29 $ret .= LJ::html_submit( value => "View" );
30 $ret .= "</td></tr></table>";
36 my $code = DW::InviteCodes->new( code => $GET{code} );
37 return $ret . "Error: invalid code '$GET{code}'" unless $code;
39 $ret .= display_codes ( $remote, $code );
41 } elsif ( $GET{account} ) {
43 my $account = LJ::load_user( $GET{account} );
44 return $ret . "Error: invalid user '$GET{account}'" unless $account;
46 my @used = DW::InviteCodes->by_recipient( userid => $account->id );
47 my @owned = DW::InviteCodes->by_owner( userid => $account->id );
49 $ret .= display_codes ( $account, @used, @owned );
56 my ($account, @codes) = @_;
58 my $ret = "<table border='1' cellpadding='5'><thead><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><th>Email</th></tr></thead>";
60 foreach my $code ( @codes ) {
61 my $owner = $code->owner == $account->id ? $account : LJ::load_userid( $code->owner );
62 my $recipient = $code->is_used ? LJ::load_userid( $code->recipient ) : undef;
64 $ret .= "<td><tt>" . $code->code . "</tt></td>";
65 $ret .= "<td>" . ( $owner ? $owner->ljuser_display : "" ) . "</td>";
66 $ret .= "<td>" . ( $code->is_used ? $recipient->ljuser_display : "" ) . "</td>";
67 $ret .= "<td>" . $code->reason . "</td>";
68 $ret .= "<td>" . LJ::time_to_http( $code->timegenerate). "</td>";
69 $ret .= "<td>" . ( $code->timesent ? LJ::time_to_http( $code->timesent ) : "" ) . "</td>";
70 $ret .= "<td>" . ( $code->is_used ? LJ::time_to_http( $recipient->timecreate ) : "" ) . "</td>";
71 $ret .= "<td>" . $code->email . "</td>";