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

[ljcom] r8322: LJSUP-4203

Committer: gprochaev
LJSUP-4203

U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm
U   trunk/htdocs/shop/userpics.bml
U   trunk/htdocs/shop/view.bml
U   trunk/htdocs/shop/view.bml.text.local
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm	2010-03-22 09:54:45 UTC (rev 8322)
@@ -41,7 +41,7 @@
     my $class = shift;
     my %args = @_;
     
-    my $userid = LJ::want_userid($args{u});
+    my $userid = LJ::want_userid($args{u} || $args{userid});
     my $item = $class->item;
 
     my $u = '';

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm	2010-03-22 09:54:45 UTC (rev 8322)
@@ -186,7 +186,8 @@
 sub validate_user_input {
     my ($self, $cartobj, $errs_ref, $warn_ref) = @_;
 
-    return $self->is_valid_bool_bonus(0);
+    my $is_rec = $cartobj && $cartobj->{forwhat} eq 'recbill' ? 1 : 0;
+    return $self->is_valid_bool_bonus($is_rec);
 }
 
 # fill 'amt', and, may be, 'qty' field

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm	2010-03-22 09:54:45 UTC (rev 8322)
@@ -55,56 +55,6 @@
     # make sure exp/size signature in subitem still matches
     my ($it_size, $old_exptime, $old_size) = split("-", $subitem);
 
-    # only do extra checks if old_exptime and old_size were provided for our pleasure
-    if (defined $old_exptime && defined $old_size) {
-
-        # if a payid is passed, then first check to make sure that no other payitems
-        # in this cart have been applied, altering the exp/size signature and making
-        # this check return false-positives
-
-        unless ($payid &&
-                $dbh->selectrow_array("SELECT COUNT(*) FROM payitems " .
-                                      "WHERE payid=? AND item=? AND subitem=? AND status='done'",
-                                      undef, $payid, $item, $subitem))
-        {
-
-            # zero-fill
-            $old_exptime ||= 0;
-            $old_size ||= 0;
-
-            # check for exptime/size mismatch, now that we know it's necessary
-            unless ($old_exptime == $exp->{'exptime'} && $old_size == $exp->{'size'}) {
-
-                # all bonus items of this type have the same size and exptime/oldsize signature
-                # by the rules applied to them when they entered the cart.
-                #
-                # so if one item fails, we go ahead and mark them all as having failed.
-                # the caller (pay.pl) will have to be smart enough to know to not try to process
-                # subsequent items of the failed bonus type
-
-                LJ::statushistory_add($userid, undef, 'pay_modify',
-                                      "ERROR: cannot apply bonus feature: $item, " .
-                                      "${old_exptime}x${old_size} != $exp->{'exptime'}x$exp->{'size'}");
-
-                  $dbh->do("UPDATE payitems SET status='done' WHERE payid=? AND item=? AND subitem=?",
-                           undef, $payid, $item, $subitem);
-
-                  return undef;
-              }
-        }
-
-        # means that we are upgrading a sized bonus item, so the time added should start
-        # from now, not the current expdate
-        $sized_upgrade = 1 unless $old_size == $it_size;
-
-    # no old_exptime or old_size passed -- recbill case, etc
-    } else {
-
-        # it is a sized upgrade if the amount currently applied account (new_size, from $exp)
-        # is not equal to the size being passed from the caller (it_size)
-        $sized_upgrade = 1 unless $new_size == $it_size;
-    }
-
     return $it_size;
 }
 
@@ -114,7 +64,7 @@
 
     my $invalid = sub { _err("invalid value for element" => @_) };
  
-    return $invalid->('size') unless $item->{size} > 0;
+    return $invalid->("size=$item->{size}") unless $item->{size} > 0;
 
     return 1;
 }
@@ -148,6 +98,9 @@
         foreach my $it (@{$cartobj->{'items'}}) {
             next unless $it->{'rcptid'} == $userid;
 
+            # skip ourself.
+            next if $self->{piid} and $it->{piid} eq $self->{piid};
+
             # collect information on when paid account starts in this cart
             $cart_paid_immed = 1
                 if $it->{'item'} eq 'paidacct' && ! $it->{'giveafter'};
@@ -323,7 +276,7 @@
     my $self = shift;
     my %opts = @_;
 
-    return undef unless $self->is_valid_sized_bonus;
+    return undef unless $self->is_valid_sized_bonus('recuring');
     my $size = (split("-", $self->{'subitem'}))[0];
     return $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{'items'}->{$size}->{'qty'}->{$self->{qty}}->{'amount_rec'};
 }

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm	2010-03-22 09:54:45 UTC (rev 8322)
@@ -11,7 +11,7 @@
     'items' => {
         # quantities
         # * undef amount means recurring only
-        12 => { 'name' => '12 months', 'amount' => 3,    'amount_rec' => 3, }
+        12 => { 'name' => '12 months', 'amount' => 2,    'amount_rec' => 2, }
     }
 );
 

Modified: trunk/htdocs/shop/userpics.bml
===================================================================
--- trunk/htdocs/shop/userpics.bml	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/htdocs/shop/userpics.bml	2010-03-22 09:54:45 UTC (rev 8322)
@@ -3,7 +3,7 @@
 <?_code
 {
     use strict;
-    use vars qw(%COOKIE %GET $cart $cartobj
+    use vars qw(%COOKIE %GET %POST $cart $cartobj
                 $remote $can_mod $promo
                 $related $note $body $img
                 $disabled $banner $itemname);
@@ -34,13 +34,29 @@
 
     LJ::set_active_crumb('shopitem');
 
+    my $val_otheruser = LJ::ehtml($POST{'otheruser'});
+    my $val_otheruser_u = LJ::load_user($val_otheruser);
+
+    my $gift = $GET{gift} || !$remote;
+    my $bitem = ();
+    my $min_packet = ();
+    my $recipient = $remote;
+    if ($gift && $val_otheruser_u) {
+        $recipient = LJ::load_user($val_otheruser);
+        $bitem = $recipient && $recipient->in_class('paid') ? LJ::Pay::Payment::PayItem::Addon::Userpics::Large->get_item_data : LJ::Pay::Payment::PayItem::Addon::Userpics::Small->get_item_data;
+        $min_packet = $recipient && $recipient->in_class('paid') ? LJ::Pay::Payment::PayItem::Addon::Userpics::Large->get_packet_size : LJ::Pay::Payment::PayItem::Addon::Userpics::Small->get_packet_size;
+    } else {
+        $bitem = $remote && $remote->in_class('paid') ? LJ::Pay::Payment::PayItem::Addon::Userpics::Large->get_item_data : LJ::Pay::Payment::PayItem::Addon::Userpics::Small->get_item_data;
+        $min_packet = $remote && $remote->in_class('paid') ? LJ::Pay::Payment::PayItem::Addon::Userpics::Large->get_packet_size : LJ::Pay::Payment::PayItem::Addon::Userpics::Small->get_packet_size;
+    }
+
     my %items = (
                  'userpics' => {
                      'title' => BML::ml('.userpics.title', {'numuserpics' => ($remote && $remote->get_cap('paid')) ? 210 : 15 }),
-                     'gifttitle' => BML::ml('.userpics.gifttitle', {'numuserpics' => ($remote && $remote->get_cap('paid')) ? 210 : 15 }),
+                     'gifttitle' => BML::ml('.userpics.gifttitle', {'numuserpics' => ($recipient && $recipient->get_cap('paid')) ? 210 : 15 }),
                      'desc' => $ML{'.userpics.desc'},
                      'longdesc' => BML::ml('.userpics.longdesc1', {'numuserpics' => ($remote && $remote->get_cap('paid')) ? 210 : 15, 'aopts' => "href='$LJ::SITEROOT/paidaccounts/'"}) . "</p><p style='text-align: justify'><?de " . BML::ml('.userpics.longdesc2', {'aopts1' => "href='$LJ::SITEROOT/manage/payments/'", 'aopts2' => "href='$LJ::SITEROOT/manage/payments/modify.bml'"}) . " de?>",
-                     'giftdesc' => BML::ml('.userpics.giftdesc', {'numuserpics' => ($remote && $remote->get_cap('paid')) ? 210 : 15 }),
+                     'giftdesc' => BML::ml('.userpics.giftdesc', {'numuserpics' => ($recipient && $recipient->get_cap('paid')) ? 210 : 15 }),
                      'shortdesc' => $ML{'.userpics.shortdesc'},
                      'class' => "bonusfeatures",
                      'price' => BML::ml('.userpics.price', {'price' => '$2 USD'}),
@@ -53,8 +69,6 @@
     $itemname = "userpics";
     my $item = $items{$itemname};
 
-    my $gift = $GET{gift} || !$remote;
-
     unless ($can_mod) {
         $note .= "<?errorbar " . BML::ml('.error.checkedout', {'aopts' => "href='$LJ::SITEROOT/shop/view.bml?item=$itemname&c=new'"}) . " errorbar?>";
     }
@@ -76,7 +90,8 @@
     $body .= "<?h1 $title h1?><p style='text-align: justify'>$desc</p>";
     $img = $item->{img} || "/img/talk/md10_thumbup.gif";
 
-    $body .= "<form method='POST' action='/pay/modify.bml'>";
+    my $form_action = $gift && !$val_otheruser_u ? '' : '/pay/modify.bml';
+    $body .= "<form method='POST' action=$form_action>";
     $body .= LJ::html_hidden("cart", $cart) if $cart;
 
     my $db_paid_time; my $is_perm; my $cart_perm_acct; my $cart_paid_months;
@@ -92,14 +107,21 @@
 
     my $no_purchase_button = 0;
 
-    if ($item->{options} ne "") {
-        $body .= "<?h2 ".BML::ml('.options.header')." h2?>" if $item->{options} && $itemname != "userpics";
-        $body .= $item->{options};
-        my $highest_available = 0;
-        my $bitem = ();
-        $bitem = $remote && $remote->in_class('paid') ? LJ::Pay::Payment::PayItem::Addon::Userpics::Large->get_item_data : LJ::Pay::Payment::PayItem::Addon::Userpics::Small->get_item_data;
-        my $min_packet = $remote && $remote->in_class('paid') ? LJ::Pay::Payment::PayItem::Addon::Userpics::Large->get_packet_size : LJ::Pay::Payment::PayItem::Addon::Userpics::Small->get_packet_size;
-        if ($remote && $remote->in_class('paid')) {
+    $body .= "<?h2 ".BML::ml('.options.header')." h2?>" if $item->{options} && $itemname != "userpics";
+    $body .= $item->{options};
+    my $highest_available = 0;
+    if (($gift && $val_otheruser && !$val_otheruser_u) || ($gift && !$val_otheruser)) {
+        if ($val_otheruser && !$val_otheruser_u) {
+            $body .= "<?errorbar ".BML::ml('.input.username.error_not_found', { username => $val_otheruser})." errorbar?>" unless $val_otheruser_u;
+            $body .= "<?errorbar ".BML::ml('.input.username.error_deleted', { username => $val_otheruser})." errorbar?>" if $val_otheruser_u && $val_otheruser_u->is_deleted();
+            $body .= "<?errorbar ".BML::ml('.input.username.error_self')." errorbar?>" if $val_otheruser eq $remote->{user};
+        }
+        # other user
+        $body .= "<table><tr><th><label for='forother'><b>$ML{'.input.username'}</b></label></th>";
+        $body .= "<td><input name='otheruser' type='text' size='15' maxlength='15' value='$val_otheruser' /></td></tr>";
+        $body .= "</table>";
+    } else {
+        if ($recipient && $recipient->in_class('paid')) {
             my @select_values = ();
             for ( my $i = LJ::Pay::Payment::PayItem::Addon::Packed::MAX_PACKET_COUNT; $i >= 1; $i-- ) {
                 my $item = LJ::Pay::Payment::PayItem->new_memonly(item => $bitem->{'item_name'}, qty => 12, subitem => $i);
@@ -113,8 +135,7 @@
                 $body .= LJ::html_check({ name => "item", type => "radio", selected => "", value => $bitem->{'item_name'}."-".$qty });
                 $body .= BML::ml(".userpics.price_per_months", { num => $qty, price => sprintf ("%.02f", $item->calculate_price) } ) . "</label><br/>";
             }
-            
-        } elsif ($remote) {
+        } elsif ($recipient) {
             $body .= LJ::html_hidden({ name => "item", value => $bitem->{'item_name'}."-12"});
             for ( my $i = LJ::Pay::Payment::PayItem::Addon::Packed::MAX_PACKET_COUNT; $i >= 1; $i-- ) {
                 my $item = LJ::Pay::Payment::PayItem->new_memonly(item => $bitem->{'item_name'}, qty => 12, subitem => $i);
@@ -124,39 +145,44 @@
             }
         }
     }
-    if ($gift) { $body .= "<input type='hidden' name='for' value='other'  />"; } else { $body .= "<input type='hidden' name='for' value='remote' />"; }
     if ($gift) {
-        if (defined $remote && $item->{class} ne "gifts") {
-            $body .= "<?p <strong><a href='$LJ::SITEROOT/shop/view.bml?item=$itemname'>$ML{'.item.foryou.loggedin'}</a></strong> p?>";
-        } else {
-            $body .= "<?p " . BML::ml('.item.foryou.loggedout', {'aopts' => "href='$LJ::SITEROOT/login.bml?ret=1'"}) . " p?>" unless $item->{class} eq "gifts";
+        $body .= "<input type='hidden' name='for' value='other'  />";
+    } else {
+        $body .= "<input type='hidden' name='for' value='remote' />";
+    }
+    $body .= "<input type='hidden' name='otheruser' value='$val_otheruser' />" if $val_otheruser && $val_otheruser_u;
+    if ($gift) {
+        if (!$val_otheruser) {
+            if (defined $remote && $item->{class} ne "gifts") {
+                $body .= "<?p <strong><a href='$LJ::SITEROOT/shop/view.bml?item=$itemname'>$ML{'.item.foryou.loggedin'}</a></strong> p?>";
+            } else {
+                $body .= "<?p " . BML::ml('.item.foryou.loggedout', {'aopts' => "href='$LJ::SITEROOT/login.bml?ret=1'"}) . " p?>" unless $item->{class} eq "gifts";
+            }
         }
+        unless (($gift && $val_otheruser && !$val_otheruser_u) || ($gift && !$val_otheruser)) {
+            $body .= "<div style='clear: left;'></div><?h2 $ML{'.giftoptions.header'} h2?>" unless $item->{class} eq "gifts";
 
-        $body .= "<div style='clear: left;'></div><?h2 $ML{'.giftoptions.header'} h2?>" unless $item->{class} eq "gifts";
+            # other user
+            $body .= "<table>";
 
-        # other user
-        my $checked = $GET{'for'} ? "checked='checked'" : "";
-        my $val_otheruser = LJ::ehtml($GET{'for'});
-        $body .= "<table><tr><th><label for='forother'><b>$ML{'.input.username'}</b></label></th>";
-        $body .= "<td><input name='otheruser' type='text' size='15' maxlength='15' value='$val_otheruser' /></td></tr>";
+            # gift options
+            $body .= "<tr><th>$ML{'/pay/index.bml.deliverydate.label'}</th><td>";
 
-        # gift options
-        $body .= "<tr><th>$ML{'/pay/index.bml.deliverydate.label'}</th><td>";
 
+            my @time = gmtime(time);
+            my ($year, $mon, $mday, $hour, $min) = ($time[5] + 1900,
+                                                    sprintf("%02d", $time[4] + 1),
+                                                    sprintf("%02d", $time[3]),
+                                                    $time[2],
+                                                    sprintf("%02d", $time[1]));
 
-        my @time = gmtime(time);
-        my ($year, $mon, $mday, $hour, $min) = ($time[5] + 1900,
-                                                sprintf("%02d", $time[4] + 1),
-                                                sprintf("%02d", $time[3]),
-                                                $time[2],
-                                                sprintf("%02d", $time[1]));
+            $body .= LJ::html_datetime({'notime' => 1, 'name' => "giveafter", 'default' => "$year-$mon-$mday $hour:$min:00" });
+            $body .= "</td></tr>";
 
-        $body .= LJ::html_datetime({'notime' => 1, 'name' => "giveafter", 'default' => "$year-$mon-$mday $hour:$min:00" });
-        $body .= "</td></tr>";
 
-
-        $body .= "<tr><th><label for='anongift'>$ML{'.input.anongift'}</label></th><td><input type='checkbox' name='anongift' id='anongift' /></td></tr>";
-        $body .= "</table>";
+            $body .= "<tr><th><label for='anongift'>$ML{'.input.anongift'}</label></th><td><input type='checkbox' name='anongift' id='anongift' /></td></tr>";
+            $body .= "</table>";
+        }
     }
 
 
@@ -211,7 +237,7 @@
 
         $promo .= "<p style='white-space: nowrap'><strong>".BML::ml('.promo.autopay.header')."</strong></p>";
         $promo .= "<p>" . BML::ml('.promo.autopay.setup', {'aopts' => "href='$LJ::SITEROOT/manage/payments/modify.bml'"}) . "</p><ul style='margin-left: 0; padding-left: 15px'>";
-        
+
         $promo .= "<li>".BML::ml('.promo.autopay.setup.1')."</li>";
         $promo .= "<li>".BML::ml('.promo.autopay.setup.2')."</li>";
         $promo .= "<li>".BML::ml('.promo.autopay.setup.3')."</li>";

Modified: trunk/htdocs/shop/view.bml
===================================================================
--- trunk/htdocs/shop/view.bml	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/htdocs/shop/view.bml	2010-03-22 09:54:45 UTC (rev 8322)
@@ -193,6 +193,8 @@
         } elsif ($itemname eq "rename") {
             $body .= "<input type='hidden' name='item' value='rename' />";
         } elsif ($itemname eq "userpics") {
+            return BML::redirect('/shop/userpics.bml');
+=head
             my $highest_available = 0;
             my $bitem = LJ::Pay::Payment::PayItem::Addon::Userpics->get_item_data;
             foreach my $qty (sort { $b <=> $a } keys %{$bitem->{'items'}}) {
@@ -205,6 +207,7 @@
                 $body .= "<label>" . LJ::html_check({ 'type' => "radio", 'value' => $bitem->{item_name}."-".$qty, 'name' => "item", 'selected' => $checked});
                 $body .= " $name $price</label><br />";
             }
+=cut
         } elsif ($itemname eq "vgift") {
 
             # Redirect to new VGift page
@@ -289,8 +292,10 @@
         }
 
         if ($gift && $itemname ne "diskspace") {
-            if (defined $remote && $item->{class} ne "gifts") {
+            if (defined $remote && $item->{class} ne "gifts" && $itemname ne "userpics") {
                 $body .= "<?p <strong><a href='$LJ::SITEROOT/shop/view.bml?item=$itemname'>$ML{'.item.foryou.loggedin'}</a></strong> p?>";
+            } elsif ($itemname eq 'userpics') {
+                $body .= "<?p <strong><a href='$LJ::SITEROOT/shop/userpics.bml'>$ML{'.item.foryou.loggedin'}</a></strong> p?>";
             } else {
                 $body .= "<?p " . BML::ml('.item.foryou.loggedout', {'aopts' => "href='$LJ::SITEROOT/login.bml?ret=1'"}) . " p?>" unless $item->{class} eq "gifts";
             }
@@ -364,7 +369,8 @@
     my $num = 0;
     foreach (@related) {
         my $img = $items{$_}->{imgsmall} || "/img/talk/md10_thumbup.gif";
-        $related .= "<div class='Related'><a href='/shop/view.bml?item=$_'>";
+        $related .= "<div class='Related'><a href='/shop/view.bml?item=$_'>" if $_ ne 'userpics';
+        $related .= "<div class='Related'><a href='/shop/userpics.bml'>" if $_ eq 'userpics';
         $related .= "<img src='$img' alt='' />";
         $related .= "<strong>" . $items{$_}->{title} . "</strong>";
         $related .= "<br />" . $items{$_}->{desc} . "<br />";

Modified: trunk/htdocs/shop/view.bml.text.local
===================================================================
--- trunk/htdocs/shop/view.bml.text.local	2010-03-22 09:16:03 UTC (rev 8321)
+++ trunk/htdocs/shop/view.bml.text.local	2010-03-22 09:54:45 UTC (rev 8322)
@@ -86,6 +86,9 @@
 
 .input.username|staleness=1
 .input.username=Recipient:
+.input.username.error_not_found=User [[username]] not found. Please check recipient’s name.
+.input.username.error_deleted=You can’t send a gift to [[username]] deleted. Please check recipient’s name.
+.input.username.error_self=You can’t send a gift to yourself. Please check recipient’s name or buy add-on for yourself.
 
 .intro.desc|staleness=1
 .intro.desc=Virtual gifts are icons that will display in the recipient's profile for two weeks only, after which they will be found on the virtual gift archive page.

Tags: bml, ljcom, local, 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