5 # A file for miscellaneous display-related hooks.
8 # Denise Paolucci <denise@dreamwidth.org>
10 # Copyright (c) 2009 by Dreamwidth Studios, LLC.
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'.
17 package DW::Hooks::Display;
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.
27 LJ::Hooks::register_hook( 'finduser_extrainfo', sub {
32 my $paidstatus = DW::Pay::get_paid_status( $u );
33 my $numinvites = DW::InviteCodes->unused_count( userid => $u->id );
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} );
43 $ret .= " Unused invites: " . $numinvites . "\n";