cgi-bin/DW/Hooks/Display.pm
author fu
Thu Feb 23 02:21:54 2012 +0800
changeset 4315 34b3c4ba3afb
parent 3132 037560b72db0
permissions -rw-r--r--
http://bugs.dwscoalition.org/show_bug.cgi?id=3859

Tweak for grammar / clarity / wording.

Patch by fu.
     1 #!/usr/bin/perl
     2 #
     3 # DW::Hooks::Display
     4 #
     5 # A file for miscellaneous display-related hooks.
     6 #
     7 # Authors:
     8 #      Denise Paolucci <denise@dreamwidth.org>
     9 #
    10 # Copyright (c) 2009 by Dreamwidth Studios, LLC.
    11 #
    12 # This program is free software; you may redistribute it and/or modify it under
    13 # the same terms as Perl itself.  For a copy of the license, please reference
    14 # 'perldoc perlartistic' or 'perldoc perlgpl'.
    15 #
    16 
    17 package DW::Hooks::Display;
    18 
    19 use strict;
    20 use LJ::Hooks;
    21 
    22 # Displays extra info on finduser results. Called as:
    23 #   LJ::Hooks::run_hooks("finduser_extrainfo", $u })
    24 # Currently used to return paid status, expiration date, and number of
    25 # unused invite codes.
    26 
    27 LJ::Hooks::register_hook( 'finduser_extrainfo', sub {
    28     my $u = shift;
    29 
    30     my $ret;
    31 
    32     my $paidstatus = DW::Pay::get_paid_status( $u );
    33     my $numinvites = DW::InviteCodes->unused_count( userid => $u->id );
    34 
    35     unless ( DW::Pay::is_default_type( $paidstatus ) ) {
    36         $ret .= "  " . DW::Pay::type_name( $paidstatus->{typeid} );
    37         $ret .= $paidstatus->{permanent} ? ", never expires" :
    38             ", expiring " . LJ::mysql_time( $paidstatus->{expiretime} );
    39         $ret .= "\n";
    40     }
    41 
    42     if ( $numinvites ) {
    43         $ret .= "  Unused invites: " . $numinvites . "\n";
    44     }
    45 
    46     return $ret;
    47 });
    48 
    49 1;