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