#!/usr/bin/perl
#
# LJ::Event::VgiftDelivered
#
# Event for delivering a virtual gift
#
# Authors:
# Jen Griffin ';
$ret .= '' . $trans->{reason} . '
' if $trans->{reason}; $ret .= LJ::Lang::ml( "event.vgift.delivery.msg", { num_days => $LJ::VGIFT_EXPIRE_DAYS } ) . "
\n"; $ret .= $self->as_html_actions; return $ret; } # contents for plaintext email sub as_email_string { my ( $self, $u ) = @_; my $trans = $self->trans; my $from = $trans->from_text; my $anon = $trans->is_anonymous ? LJ::Lang::ml( 'shop.item.vgift.anonymous', { sitenameshort => $LJ::SITENAMESHORT } ) : ''; return LJ::Lang::ml( 'shop.email.vgift.body.text', { sitenameshort => $LJ::SITENAMESHORT, sitename => $LJ::SITENAME, touser => $u->display_name, fromuser => $anon || $from, accept => $trans->url, } ) . "\n\n"; } sub as_email_html { my ( $self, $u ) = @_; my $trans = $self->trans; my $from = $trans->from_html; my $anon = $trans->is_anonymous ? LJ::Lang::ml( 'shop.item.vgift.anonymous', { sitenameshort => $LJ::SITENAMESHORT } ) : ''; return LJ::Lang::ml( 'shop.email.vgift.body.html', { sitenameshort => $LJ::SITENAMESHORT, sitename => $LJ::SITENAME, touser => $u->ljuser_display, fromuser => $anon || $from, accept => $trans->url, } ) . "\n\n"; } sub as_email_subject { my $self = $_[0]; return LJ::Lang::ml( 'shop.email.vgift.subject', { sitenameshort => $LJ::SITENAMESHORT, } ); } # subscriptions are always on, can't be turned off sub is_common { 1 } sub is_visible { 1 } sub always_checked { 1 } sub subscription_as_html { my ( $class, $subscr ) = @_; return LJ::Lang::ml('event.vgift.delivery'); } # override parent class subscriptions method to always return # a subscription object for the user sub raw_subscriptions { my ( $class, $self, %args ) = @_; $args{ntypeid} = LJ::NotificationMethod::Inbox->ntypeid; # Inbox return $class->_raw_always_subscribed( $self, %args ); } sub get_subscriptions { my ( $self, $u, $subid ) = @_; unless ($subid) { my $row = { userid => $u->{userid}, ntypeid => LJ::NotificationMethod::Inbox->ntypeid, # Inbox }; return LJ::Subscription->new_from_row($row); } return $self->SUPER::get_subscriptions( $u, $subid ); } 1;