wisest owl (wisest_owl) wrote in changelog,
wisest owl
wisest_owl
changelog

[ljcom] r9423: LJSUP-6639. Purchasing for myself: need ...

Committer: gprochaev
LJSUP-6639. Purchasing for myself: need to apply userhead immediatelly

U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2010-08-27 04:36:17 UTC (rev 9422)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2010-08-27 04:47:09 UTC (rev 9423)
@@ -380,7 +380,7 @@
     # activate cap if necessary
     my ($new_size, $new_time) = 
         $item_to_deliver->_adopt_item(exp => $exp, payid => $payid, u => $u, time => $timestamp);
-    unless ($item_to_deliver->_activate_item(u => $u, error => $error_ref)) {
+    unless ($item_to_deliver->_activate_item(u => $u, payid => $payid, error => $error_ref)) {
         $$error_ref = "Can't activate item: $$error_ref" if $error_ref;
         return;
     }

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm	2010-08-27 04:36:17 UTC (rev 9422)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/UserHead.pm	2010-08-27 04:47:09 UTC (rev 9423)
@@ -5,6 +5,8 @@
 use base "LJ::Pay::Payment::PayItem::Addon";
 use LJ::Pay::Util qw/ _err _get_dbh/;
 
+use LJ::UserHead;
+
 sub item { return 'userhead'; }
 sub paidexp_item {
     my $self = shift;
@@ -87,6 +89,24 @@
 }
 
 sub _activate_item {
+    my $self = shift;
+    my %args = @_;
+
+    my $rcpt_u = $args{'u'} || $args{'userid'};
+    my $user = LJ::want_user($rcpt_u);
+
+    my $payid  = $args{'payid'};
+    my $cart = eval {LJ::Pay::Payment->load(payid => $payid)};
+
+    ## Userheads are delivering for self-buying users only
+    if ($cart && ($rcpt_u->{userid} == $cart->{userid})) {
+
+        my $subitem = $self->{subitem};
+        my ($uh_id) = $subitem =~ m#uh-(\d+)#;
+        my $uh = LJ::UserHead->get_userhead ($uh_id);
+        $user->set_custom_usericon ($uh->get_uh_img);
+    }
+
     return 1;
 }
 

Tags: ljcom, pm, wisest-owl
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments