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

[ljcom] r8232: LJSUP-4203

Committer: gprochaev
LJSUP-4203


U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm
A   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/DiskQuota.pm
A   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm
A   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/
A   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm
A   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm
A   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm	2010-03-02 12:34:17 UTC (rev 8231)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Boolean.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -30,7 +30,8 @@
 
     my $u;
     # activate cap if necessary
-    if (my $cap = $LJ::Pay::Payment::PayItem::Addon::bonus{$item}->{'cap'}) {
+    my $bitem = $class->get_item_data;
+    if (my $cap = $bitem->{'cap'}) {
         $u = LJ::modify_caps($userid, [], [$cap]);
     }
     return $u;
@@ -45,7 +46,8 @@
 
     my $u = '';
     # activate cap if necessary
-    if (my $cap = $LJ::Pay::Payment::PayItem::Addon::bonus{$item}->{'cap'}) {
+    my $bitem = $class->get_item_data;
+    if (my $cap = $bitem->{'cap'}) {
         $u = LJ::modify_caps($userid, [$cap], []);
     }
     return 1;
@@ -56,7 +58,7 @@
     my ($item, $qty) = ($self->{item}, $self->{qty});
     my $is_rec = shift;
 
-    my $itrec = $LJ::Pay::Payment::PayItem::Addon::bonus{$item};
+    my $itrec = $self->get_item_data;
     return 0 unless ref $itrec;
     return 0 unless $itrec->{type} eq 'bool';
     return 0 unless ref $itrec->{items}->{$qty};
@@ -68,7 +70,7 @@
     my ($class, $subitem, $qty, $short) = @_;
     my $item = $class->item;
 
-    my $bitem = $LJ::Pay::Payment::PayItem::Addon::bonus{$item};
+    my $bitem = $class->get_item_data;
     return LJ::Lang::ml($bitem->{'name'}) . ($short ? "" : (" - " . ($bitem->{'items'}->{$qty}->{'name'} || $qty)));
 }
 
@@ -77,7 +79,8 @@
     my %opts = @_;
 
     return undef unless $self->is_valid_bool_bonus(1);
-    return $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{qty}}->{'amount_rec'};
+    my $bitem = $self->get_item_data;
+    return $bitem->{items}->{$self->{qty}}->{'amount_rec'};
 }
 
 sub validate_user_input {
@@ -92,7 +95,8 @@
     my ($self, $is_gift, $cartobj) = @_;
 
     if ($self->is_valid_bool_bonus(0)) {
-        $self->{'amt'} = $LJ::Pay::Payment::PayItem::Addon::bonus{$self->{item}}->{items}->{$self->{qty}}->{'amount'};
+        my $bitem = $self->get_item_data;
+        $self->{'amt'} = $bitem->{items}->{$self->{qty}}->{'amount'};
     } else {
         $self->{'amt'} = undef;
     }

Added: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/DiskQuota.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/DiskQuota.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/DiskQuota.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -0,0 +1,7 @@
+package LJ::Pay::Payment::PayItem::Addon::DiskQuota;
+
+use strict;
+use base "LJ::Pay::Payment::PayItem::Addon::Sized";
+sub item { return 'diskquota'; } 
+
+1;

Added: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Packed.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -0,0 +1,205 @@
+package LJ::Pay::Payment::PayItem::Addon::Packed;
+
+use strict;
+
+use LJ::Pay::Util qw/_err _get_dbh/;
+use base "LJ::Pay::Payment::PayItem::Addon";
+
+use constant SECONDS_PER_MONTH => 2629743.83;
+use constant MAX_PACKET_COUNT => 3;
+
+# setup functions for can_belong_to() method in base class
+sub need_paid             { return 1;        }
+sub having_account_levels { return ('perm'); }
+sub disallowed_account_levels { return ();   }
+sub can_belong_to_special_cases { return 1; } # no special checks - only paid and perm are important
+
+use Data::Dumper;
+
+sub get_amt {
+    my $self = shift;
+    return $self->{payid} ? $self->{amt} : $self->{amt} * ($self->{subitem} || 1);
+}
+
+sub get_recbill_price_for_existing_item {
+    my $self = shift;
+    my ($recbill_item, $next_check) = @_;
+
+    my $qty = ($next_check - $recbill_item->get_exptime) / (86400*30);
+    my $price = $qty * $self->get_item_base_price / $self->get_qty;
+
+    return $price;
+}
+
+# return new packets count for item
+# set expttime in the exp hash to a new time delta
+sub _adopt_item {
+    my $self = shift;
+    my %args = @_;
+    
+    my $exp   = $args{exp};
+    my $payid = $args{payid};
+    my $u     = $args{u};
+
+    my ($item, $subitem, $qty) = ($self->{item}, $self->{subitem}, $self->{qty});
+    return _err("No subitem is given") unless $subitem;
+ 
+    my $userid = LJ::want_userid($u);
+    my $dbh = _get_dbh();
+
+    # was packets
+    my $old_size = $exp->{size};
+    
+    # will expire after
+    my $old_time = $exp->{exptime} - time();
+    
+    # new packets count
+    my $new_size = $subitem;
+    
+    # new expire time (w/o now)
+    my $new_time = $qty * SECONDS_PER_MONTH;
+    
+    if ($old_size + $new_size <= MAX_PACKET_COUNT) {
+        # user will < 3 packets
+        $exp->{add_exptime} += int (($old_size * $old_time + $new_size * $new_time) / ($old_size + $new_size));
+        return $old_size + $new_size;
+    } else {
+        my $over_size = $old_size + $new_size - MAX_PACKET_COUNT;
+        $new_size = MAX_PACKET_COUNT - $old_size;
+        
+        # count for 3 packets
+#        $exp->{add_exptime} += int (($old_size * $old_time + $new_size * $new_time) / MAX_PACKET_COUNT);
+
+        # add over packets as more time expiring
+        $exp->{add_exptime} += (MAX_PACKET_COUNT / $over_size) * $qty * SECONDS_PER_MONTH;
+        return MAX_PACKET_COUNT;
+    }
+}
+
+sub save_from_recbill {
+    my $self = shift;
+    my $item = shift;
+
+    return 1;
+}
+
+sub add_paidexp_time {
+    my $self = shift;
+    my %args = @_;
+
+    my $exp      = $args{exp};
+    my $new_size = $args{new_size};
+    my $u        = $args{u};
+
+    my $dbh = LJ::get_db_writer();
+    # insert a new row, or add time to old one
+    {
+        # expdate calculation is tricky
+        # [(expdate || NOW()) + INTERVAL $months MONTH] + INTERVAL $daysleft DAY
+
+        my $exptime = $exp->{exptime} || "UNIX_TIMESTAMP(NOW())";
+        my $userid = LJ::want_userid($u);
+        # update / insert paidexp row
+
+        $exptime = "FROM_UNIXTIME($exptime + ".$exp->{add_exptime}.")";
+        $dbh->do("REPLACE INTO paidexp (userid, item, size, expdate, daysleft) " .
+                 "VALUES (?, ?, ?, $exptime, 0)", undef, $userid, $exp->{item}, $new_size);
+        return undef if $dbh->err;
+    }
+
+    return 1;
+}
+
+sub validate_recbill_fields {
+    my $self = shift;
+    my $item = shift;
+
+    # packet good has a not null number of packets
+    #$item->{size} = 0;
+    $item->{daysleft} += 0;
+
+    return 1;
+}
+
+sub _deactivate_item {
+    my $self = shift;
+    my %args = @_;
+    
+    my $userid = LJ::want_userid($args{u});
+    my $item = $self->item;
+
+    my $u;
+    # activate cap if necessary
+    my $bitem = $self->get_item_data;
+    if (my $cap = $bitem->{'cap'}) {
+        $u = LJ::modify_caps($userid, [], [$cap]);
+    }
+    return $u;
+}
+
+sub _activate_item {
+    my $self = shift;
+    my %args = @_;
+    
+    my $userid = LJ::want_userid($args{u});
+    my $item = $self->item;
+
+    my $u = '';
+    # activate cap if necessary
+    my $bitem = $self->get_item_data;
+    if (my $cap = $bitem->{'cap'}) {
+        $u = LJ::modify_caps($userid, [$cap], []);
+    }
+    return 1;
+}
+
+sub is_valid_bool_bonus {
+    my $self = shift;
+    my ($item, $qty) = ($self->{item}, $self->{qty});
+    my $is_rec = shift;
+
+    my $itrec = $self->get_item_data;
+    return 0 unless ref $itrec;
+    return 0 unless $itrec->{type} eq 'bool';
+    return 0 unless ref $itrec->{items}->{$qty};
+    return 0 unless defined $itrec->{items}->{$qty}->{$is_rec ? 'amount_rec' : 'amount'};
+    return 1;
+}
+
+sub get_product_name {
+    my ($class, $subitem, $qty, $short) = @_;
+    my $item = $class->item;
+
+    my $bitem = $class->get_item_data;
+    return LJ::Lang::ml($bitem->{'name'}, { num => $subitem}) . ($short ? "" : (" - " . ($bitem->{'items'}->{$qty}->{'name'} || $qty)));
+}
+
+sub get_item_base_price {
+    my $self = shift;
+    my %opts = @_;
+
+    return undef unless $self->is_valid_bool_bonus(1);
+    my $bitem = $self->get_item_data;
+    return $bitem->{items}->{$self->{qty}}->{'amount_rec'};
+}
+
+sub validate_user_input {
+    my ($self, $cartobj, $errs_ref, $warn_ref) = @_;
+
+    return $self->is_valid_bool_bonus(0);
+}
+
+# fill 'amt', and, may be, 'qty' field
+# may be called on incomplete or 'bad' object (which will not pass checks in 'can_belong_to' method)
+sub calculate_price {
+    my ($self, $is_gift, $cartobj) = @_;
+
+    if ($self->is_valid_bool_bonus(0)) {
+        my $bitem = $self->get_item_data;
+        $self->{'amt'} = $bitem->{items}->{$self->{qty}}->{'amount'} * $self->{subitem};
+    } else {
+        $self->{'amt'} = undef;
+    }
+}
+
+1;

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm	2010-03-02 12:34:17 UTC (rev 8231)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Sized.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -7,6 +7,29 @@
 sub _activate_item { return 1; }
 sub _deactivate_item { return 1; }
 
+%LJ::Pay::Payment::PayItem::Addon::bonus = (
+        diskquota => {
+                # disk quota is a 'sized' item
+                # ATTENTION! Code for changing disk quota size was PARTIALLY destroed during shop refactoring.
+               'name' => 'pay.product.extrastorage',
+               'type' => 'sized',
+               'cap' => undef, # optional
+               'items' => {
+                   # 1024*10 = 10240 = 10GB
+                   10240 => {
+                       'name' => '10 GB',
+                       'qty' => {
+                           1  => { 'name' => '1 months',  'amount' => undef, 'amount_rec' =>  3, },
+                           2  => { 'name' => '2 months',  'amount' => 5,     'amount_rec' =>  5, },
+                           6  => { 'name' => '6 months',  'amount' => 14,    'amount_rec' => 14, },
+                           12 => { 'name' => '12 months', 'amount' => 24,    'amount_rec' => 24, },
+                       }
+                   },
+
+               }
+        }
+);
+
 sub _adopt_item {
     my $self = shift;
     my %args = @_;
@@ -19,7 +42,7 @@
 
     my ($item, $subitem, $qty) = ($self->{item}, $self->{subitem}, $self->{qty});
     return _err("No subitem is given") unless $subitem;
-
+    
     my $userid = LJ::want_userid($u);
 
     # actions for 'sized' bonus feature type
@@ -92,7 +115,7 @@
     my $item = shift;
 
     my $invalid = sub { _err("invalid value for element" => @_) };
-
+ 
     return $invalid->('size') unless $item->{size} > 0;
 
     return 1;
@@ -164,6 +187,7 @@
     # if no paid account in cart starting immediately, check in the database
     # to see if there is currently paid time there
     unless ($cart_paid_immed) {
+
         # sometimes users have the paid cap with no paiduser row in the database, eg when
         # they have a permanent account ... assume if they have a perm account then
         # they are paid forever
@@ -230,7 +254,7 @@
     my $userid = LJ::want_userid($u);
 
     my $size = (split("-", $subitem))[0];
-
+    
     # allow passing of an $it hash
     if (ref $item) {
         # get size from subitem
@@ -350,20 +374,20 @@
 sub get_recbill_price_for_existing_item {
     my $self = shift;
     my ($recbill_item, $next_check) = @_;
-
+    
     my $size = (split("-", $self->{'subitem'}))[0];
 
     if ($size != $recbill_item->{size}) {
-
+    
         # throw an error if we get in here attempting to do a sized downgrade,
         # the caller has made a mistake
         die("sized downgrade attempted") if $size < $recbill_item->{size};
-
+        
         my $price    = $self->get_item_base_price;
-        my $now      = time;
+        my $now      = time;   
         my $base_len = LJ::Pay::RecBill::_epoch_add_months($now, $self->{qty}) - $now;
         my $exptime  = $recbill_item->{exptime};
-
+        
         # 2 rectangles:
         # - new upgraded one ($size x _max($next_check, $exptime))
         # - existing one     ($recbill_item->{size} x $recbill_item->{exptime})

Added: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -0,0 +1,28 @@
+package LJ::Pay::Payment::PayItem::Addon::Userpics::Large;
+use strict;
+use base "LJ::Pay::Payment::PayItem::Addon::Packed";
+sub item { return 'userpic_large'; } 
+
+%LJ::Pay::Payment::PayItem::Addon::userpic_large = (
+    'name' => 'pay.product.extrauserpics_large',
+    'item_name' => 'userpic_large',
+    'type' => 'bool',
+    'cap' => 9, # cap bit to activate for user
+    'items' => {
+        # quantities
+        # * undef amount means recurring only
+        1  => { 'name' => '1 month',   'amount' => undef, 'amount_rec' =>  1, },
+        2  => { 'name' => '2 months',  'amount' => 2,     'amount_rec' =>  2, },
+        6  => { 'name' => '6 months',  'amount' => 6,     'amount_rec' =>  6, },
+        12 => { 'name' => '12 months', 'amount' => 10,    'amount_rec' => 10, }
+    }
+);
+
+sub get_packet_size { 70 }
+
+sub get_item_data {
+    my $self = shift;
+    return \%LJ::Pay::Payment::PayItem::Addon::userpic_large;
+}
+
+1;

Added: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Small.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -0,0 +1,27 @@
+package LJ::Pay::Payment::PayItem::Addon::Userpics::Small;
+use strict;
+use base "LJ::Pay::Payment::PayItem::Addon::Packed";
+sub item { return 'userpic_small'; } 
+
+%LJ::Pay::Payment::PayItem::Addon::userpic_small = (
+    'name' => 'pay.product.extrauserpics_small',
+    'item_name' => 'userpic_small',
+    'type' => 'bool',
+    'cap' => 9, # cap bit to activate for user
+    'items' => {
+        # quantities
+        # * undef amount means recurring only
+        12 => { 'name' => '12 months', 'amount' => 3,    'amount_rec' => 3, }
+    }
+);
+
+sub get_packet_size { 5 }
+
+sub need_paid { 0 }
+
+sub get_item_data {
+    my $self = shift;
+    return \%LJ::Pay::Payment::PayItem::Addon::userpic_small;
+}
+
+1;

Added: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics.pm	                        (rev 0)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -0,0 +1,26 @@
+package LJ::Pay::Payment::PayItem::Addon::Userpics;
+use strict;
+use base "LJ::Pay::Payment::PayItem::Addon::Boolean";
+sub item { return 'userpic'; } 
+
+%LJ::Pay::Payment::PayItem::Addon::userpic = (
+    'name' => 'pay.product.extrauserpics',
+    'item_name' => 'userpic',
+    'type' => 'bool',
+    'cap' => 9, # cap bit to activate for user
+    'items' => {
+        # quantities
+        # * undef amount means recurring only
+        1  => { 'name' => '1 month',   'amount' => undef, 'amount_rec' =>  1, },
+        2  => { 'name' => '2 months',  'amount' => 5,     'amount_rec' =>  5, },
+        6  => { 'name' => '6 months',  'amount' => 8,     'amount_rec' =>  8, },
+        12 => { 'name' => '12 months', 'amount' => 15,    'amount_rec' => 15, }
+    }
+);
+
+sub get_item_data {
+    my $self = shift;
+    return \%LJ::Pay::Payment::PayItem::Addon::userpic;
+}
+
+1;

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2010-03-02 12:34:17 UTC (rev 8231)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -15,7 +15,7 @@
     my $self    = shift;
     my $userid  = shift;
     my $timeval = shift;
-
+    
     my $dbh = _get_dbh();
     $dbh->do
         ("UPDATE paidexp SET lastmailed=FROM_UNIXTIME(?) WHERE userid=? AND item=?",
@@ -28,7 +28,7 @@
     my $self    = shift;
     my $userid  = shift;
     my $exptime = shift;
-
+    
     my $dbh = _get_dbh();
     $dbh->do
         ("UPDATE paidexp SET expdate=FROM_UNIXTIME(?) WHERE userid=? AND item=?",
@@ -95,7 +95,7 @@
 sub save_from_recbill {
     my $self = shift;
     my $item = shift;
-
+    
     my $dbh = _get_dbh();
     my $extra = '';
     $extra .= "expdate=FROM_UNIXTIME(".$dbh->quote($item->{'exptime'}).")," if $item->{'exptime'} > 0;
@@ -135,7 +135,7 @@
 
         # expiring bonus feature reminders
         my $subject = $level eq "soon" ? "Subscription Expiring Soon" : "Subscription Expiration Warning";
-
+    
         my $dbh = _get_dbh();
         # what time is it on the database?
         my $nowu = $dbh->selectrow_array("SELECT UNIX_TIMESTAMP()");
@@ -284,8 +284,8 @@
     my $u       = $args{u};
     my $payid   = $args{payid};
     my $time    = $args{time};
-    my $error_ref=$args{error};
-    
+    my $error_ref=$args{error};    
+
     my $timestamp;
 
     if ($time) { # else will apply $self->{qty}
@@ -302,7 +302,7 @@
         $$error_ref = "Can't activate item: $$error_ref" if $error_ref;
         return;
     }
-    
+
     unless ($self->add_paidexp_time(
                 exp         => $exp, 
                 new_size    => $new_size, 
@@ -322,47 +322,6 @@
     return 1;
 }
 
-# bonus features are of 2 types:
-# - "bool" are either on or off (userpics), 'cap' key is required
-# - "sized" have a magnitude associated with them (how much disk quota)
-%LJ::Pay::Payment::PayItem::Addon::bonus = (
-           # userpics are a 'bool' item
-           'userpic' => {
-               'name' => 'pay.product.extrauserpics',
-               'type' => 'bool',
-               'cap' => 9, # cap bit to activate for user
-               'items' => {
-                   # quantities
-                   # * undef amount means recurring only
-                   1  => { 'name' => '1 month',   'amount' => undef, 'amount_rec' =>  1, },
-                   2  => { 'name' => '2 months',  'amount' => 2,     'amount_rec' =>  2, },
-                   6  => { 'name' => '6 months',  'amount' => 6,     'amount_rec' =>  6, },
-                   12 => { 'name' => '12 months', 'amount' => 10,    'amount_rec' => 10, }
-               }
-           },
-
-           # disk quota is a 'sized' item
-           # ATTENTION! Code for changing disk quota size was PARTIALLY destroed during shop refactoring.
-           'diskquota' => {
-               'name' => 'pay.product.extrastorage',
-               'type' => 'sized',
-               'cap' => undef, # optional
-               'items' => {
-                   # 1024*10 = 10240 = 10GB
-                   10240 => {
-                       'name' => '10 GB',
-                       'qty' => {
-                           1  => { 'name' => '1 months',  'amount' => undef, 'amount_rec' =>  3, },
-                           2  => { 'name' => '2 months',  'amount' => 5,     'amount_rec' =>  5, },
-                           6  => { 'name' => '6 months',  'amount' => 14,    'amount_rec' => 14, },
-                           12 => { 'name' => '12 months', 'amount' => 24,    'amount_rec' => 24, },
-                       }
-                   },
-
-               }
-           }
-          );
-
 sub load_paidexp_row {
     my ($class, $u) = @_;
 
@@ -384,12 +343,13 @@
 
     # if no row in database, fill in $exp with good values
     $exp ||= {
-        'userid' => $userid,
-        'item' => $item,
-        'size' => 0,
-        'expdate' => undef,
-        'daysleft' => 0,
-        'exptime' => 0,
+        'userid'    => $userid,
+        'item'      => $item,
+        'subitem'   => $class->{subitem},
+        'size'      => 0,
+        'expdate'   => undef,
+        'daysleft'  => 0,
+        'exptime'   => 0,
         'unexpired' => 0,
     };
 
@@ -404,7 +364,7 @@
     my $u        = $args{u};
     my $error_ref= $args{error};
     my $new_size = $args{new_size};
-    
+
     my $qty = $args{time} || $self->{qty};
     # if $qty is > 100, then we assume it is a unixtime of when
     # their bonus item should expire
@@ -810,12 +770,12 @@
 # Get expire time for a recbillable item or paid account:
 #   my $exp_time = $recbillable_shop_item->get_expire_time;
 #   my ($exp_time, $size) = LJ::Pay::Payment::PayItem::Addon::DiskQuota->get_expire_time($u);
-# Input:
+# Input: 
 #   [optional] user object or userid
-# Output:
+# Output: 
 #   In scalar context: expire time (unixtimestamp)
 #   In list context: expire time, size (meaningful for DiskQuota only)
-#
+#   
 sub get_expire_time {
     my ($self, $u) = @_;
     my $userid =    ($u)        ? LJ::want_userid($u) :

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm	2010-03-02 12:34:17 UTC (rev 8231)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm	2010-03-03 04:49:54 UTC (rev 8232)
@@ -29,22 +29,26 @@
 
 
 my %CLASSES = (
-    'coppa'       => 'LJ::Pay::Payment::PayItem::Coppa',
-    'coupon'      => 'LJ::Pay::Payment::PayItem::Coupon',
-    'clothes'     => 'LJ::Pay::Payment::PayItem::Clothes',
-    'diskquota'   => 'LJ::Pay::Payment::PayItem::DiskQuota',
-    'paidaccount' => 'LJ::Pay::Payment::PayItem::PaidAccount', # do not use this in new code! do not delete this line!
-    'paidacct'    => 'LJ::Pay::Payment::PayItem::PaidAccount', # use this!
-    'perm'        => 'LJ::Pay::Payment::PayItem::Permanent',
-    'rename'      => 'LJ::Pay::Payment::PayItem::Rename',
-    'userpic'     => 'LJ::Pay::Payment::PayItem::Userpics',
-    'vgift'       => 'LJ::Pay::Payment::PayItem::VGift',
-    'invite'      => 'LJ::Pay::Payment::PayItem::Invite',
-    'sms-quota'   => 'LJ::Pay::Payment::PayItem::SmsQuota', # obsolete
+    'coppa'         => 'LJ::Pay::Payment::PayItem::Coppa',
+    'coupon'        => 'LJ::Pay::Payment::PayItem::Coupon',
+    'clothes'       => 'LJ::Pay::Payment::PayItem::Clothes',
+    'diskquota'     => 'LJ::Pay::Payment::PayItem::Addon::DiskQuota',
+    'paidaccount'   => 'LJ::Pay::Payment::PayItem::PaidAccount', # do not use this in new code! do not delete this line!
+    'paidacct'      => 'LJ::Pay::Payment::PayItem::PaidAccount', # use this!
+    'perm'          => 'LJ::Pay::Payment::PayItem::Permanent',
+    'rename'        => 'LJ::Pay::Payment::PayItem::Rename',
+    'userpic'       => 'LJ::Pay::Payment::PayItem::Addon::Userpics', # obsolete
+    'vgift'         => 'LJ::Pay::Payment::PayItem::VGift',
+    'invite'        => 'LJ::Pay::Payment::PayItem::Invite',
+    'sms-quota'     => 'LJ::Pay::Payment::PayItem::SmsQuota', # obsolete
+    'userpic_small' => 'LJ::Pay::Payment::PayItem::Addon::Userpics::Small',
+    'userpic_large' => 'LJ::Pay::Payment::PayItem::Addon::Userpics::Large',
 );
+
 my @FREEZABLE_CLASSES = qw/
-    LJ::Pay::Payment::PayItem::Userpics
-    LJ::Pay::Payment::PayItem::DiskQuota
+    LJ::Pay::Payment::PayItem::Addon::Userpics::Small
+    LJ::Pay::Payment::PayItem::Addon::Userpics::Large
+    LJ::Pay::Payment::PayItem::Addon::DiskQuota
 /;
 
 foreach my $c (values %CLASSES) {
@@ -78,9 +82,9 @@
     my %args = @_;
 
     my $class = ref($s) || $s;
-    if ($class eq 'LJ::Pay::Payment::PayItem') {
+    if ($class eq 'LJ::Pay::Payment::PayItem') { 
         # parent class call -> need factory
-        my $child_class = $class->get_class_for_item($args{item})
+        my $child_class = $class->get_class_for_item($args{item}) 
             or return _err("No class for item '$args{item}'");
         return $child_class->new_memonly(%args);
     } else {
@@ -150,6 +154,7 @@
 sub sort_order     { 3 }
 sub is_recbillable { 0 }
 sub apply_item     { 1 } # by default do nothing.
+
 sub validate_recbill_fields {
     my $self = shift;
     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