Committer: ssafronova
LJSUP-4203: Userpic Add-on - LJSUP-4457: move bulk code to class structure - some bugfixU branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm U branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm U branches/shop/htdocs/pay/modify.bml
Modified: branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm =================================================================== --- branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm 2009-08-03 03:43:10 UTC (rev 7527) +++ branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm 2009-08-03 06:20:00 UTC (rev 7528) @@ -138,6 +138,9 @@ return 0 unless defined $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{qty}}; + my $rcptuser = LJ::load_userid($self->{'rcptid'}); + return 0 unless $rcptuser; + # can't buy paid time for permanent accounts if ($rcptuser->in_class('perm')) { my $dispname = $self->product_name("short"); Modified: branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm =================================================================== --- branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm 2009-08-03 03:43:10 UTC (rev 7527) +++ branches/shop/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm 2009-08-03 06:20:00 UTC (rev 7528) @@ -23,7 +23,7 @@ my $userid = $u->{userid}; # easy/obvious checks - return undef unless $userid && item_is_bonus($item, 'sized'); + return undef unless $userid && LJ::Pay::Payment::PayItem::Addon::item_is_bonus($item, 'sized'); # if the caller doesn't specify a qty they are trying to add, just # validate items already in the cart @@ -233,10 +233,12 @@ return 0 unless defined $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{subitem}} and defined $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{subitem}}->{qty}->{$self->{qty}}; - # can't buy paid time for permanent accounts - if ($rcptuser->in_class('perm')) { - my $dispname = $self->product_name("short"); - $errs_ref->[0] = BML::ml('.error.cantbuyitemforperm', {'item' => "<b>$dispname</b>"}); + my $dispname = LJ::Pay::product_name($item, "short"); + my $rcptuser = LJ::load_userid($self->{'rcptid'}); + return 0 unless $rcptuser; + + unless (can_apply_sized_bonus($rcptuser, $cartobj, $self->{'item'}, $self->{'subitem'}, $self->{'qty'})) { + $errs_ref->[0] = BML::ml('.error.cantbuyitem', {'item' => "<b>$dispname</b>"}); return 0; } Modified: branches/shop/htdocs/pay/modify.bml =================================================================== --- branches/shop/htdocs/pay/modify.bml 2009-08-03 03:43:10 UTC (rev 7527) +++ branches/shop/htdocs/pay/modify.bml 2009-08-03 06:20:00 UTC (rev 7528) @@ -743,7 +743,7 @@ my @errs; my $can_be_added = $item->can_be_added($cartobj, \@errs); - return BML::redirect("/pay/?c=$cart") if not $can_be_added and not $err_msg; # nothing to say? draw the cart silently + return BML::redirect("/pay/?c=$cart") if not $can_be_added and not @errs; # nothing to say? draw the cart silently return $err->(@errs) unless $can_be_added; return $err->($ML{'.error.cantspecifydateforself'}) @@ -752,23 +752,6 @@ my $err_msg = $item->set_giveafter($POST{giveafter_yyyy}, $POST{giveafter_mm}, $POST{giveafter_dd}, $rcptuser->timezone); return $err->($err_msg) if $err_msg; - # must be logged in and purchasing 'sized' bonus features for self - if (LJ::Pay::is_bonus($itemname, 'sized')) { - my $dispname = LJ::Pay::product_name($item, "short"); - - # must be logged in - return $err->(BML::ml('.error.notloggedinforitem', {'aopts' => "href='$LJ::SITEROOT/login.bml?ret=1'", 'item' => "<b>$dispname</b>"})) - unless $remote; - - # can't buy as a gift - return $err->(BML::ml('.error.cantbuyitemasgift', {'item' => "<b>$dispname</b>"})) - unless $remote->{'userid'} == $item->{'rcptid'}; - - # shouldn't get this far, did they spoof the form values? - return $err->(BML::ml('.error.cantbuyitem', {'item' => "<b>$dispname</b>"})) - unless LJ::Pay::can_apply_sized_bonus($rcptuser, $cartobj, $item->{'item'}, $item->{'subitem'}, $item->{'qty'}); - } - # buying bonus-feature, lots of extra checks if (LJ::Pay::is_bonus($itemname) && ! $POST{'action:additem:confirm'}) {