Committer: gariev
LJSUP-5838: Add warning message when user buys small userpics and paid account.
U trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm
U trunk/htdocs/pay/modify.bml
U trunk/htdocs/pay/modify.bml.text.local
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm 2010-04-12 10:46:31 UTC (rev 8490)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm 2010-04-12 11:23:30 UTC (rev 8491)
@@ -25,4 +25,36 @@
return \%LJ::Pay::Payment::PayItem::Addon::userpic_small;
}
+##
+## Special case: if recipient of userpic is not a paid user now,
+## but cart contains a paid account for this recipient,
+## then do allow to buy small packet of userpics, but issue a warning
+##
+sub can_belong_to {
+ my ($self, $cartobj, $errs_ref, $warns_ref, $action, $not_check_amount) = @_;
+
+ ## if base class says 'no', it means 'no'
+ return unless $self->SUPER::can_belong_to($cartobj, $errs_ref, $warns_ref, $action, $not_check_amount);
+
+ my $recipient_has_paid_account;
+ my $rcpt_id = $self->get_rcptid;
+ foreach my $item ($cartobj->get_items('paidacct')) {
+ if ($item->get_rcptid==$rcpt_id) {
+ $recipient_has_paid_account = 1;
+ last;
+ }
+ }
+ if ($recipient_has_paid_account) {
+ my $u = LJ::load_userid($rcpt_id);
+ my $key = ($cartobj->get_userid==$rcpt_id) ?
+ '/pay/modify.bml.warning.small_userpics_for_paid.you' :
+ '/pay/modify.bml.warning.small_userpics_for_paid.other';
+ push @$warns_ref, BML::ml($key, { ljuser => $u->ljuser_display });
+ }
+
+ return 1;
+}
+
+
+
1;
Modified: trunk/htdocs/pay/modify.bml
===================================================================
--- trunk/htdocs/pay/modify.bml 2010-04-12 10:46:31 UTC (rev 8490)
+++ trunk/htdocs/pay/modify.bml 2010-04-12 11:23:30 UTC (rev 8491)
@@ -1,3 +1,6 @@
+1
+_info?>