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

[ljcom] r9335: LJSUP-6515. Custom Userheads.

Committer: gprochaev
LJSUP-6515. Custom Userheads.

U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem/RecBillAble.pm
U   trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm
U   trunk/cgi-bin/LJ/Pay/RecBill/Item.pm
U   trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm
U   trunk/htdocs/shop/index.bml.text.local
Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon/Userpics/Large.pm	2010-08-16 07:07:45 UTC (rev 9335)
@@ -1,5 +1,8 @@
 package LJ::Pay::Payment::PayItem::Addon::Userpics::Large;
 use strict;
+
+sub is_recbillable { 1 }
+
 use base "LJ::Pay::Payment::PayItem::Addon::Packed";
 sub item { return 'userpic_large'; } 
 
@@ -20,8 +23,6 @@
 
 sub get_packet_size { 70 }
 
-sub is_recbillable { 1 }
-
 sub get_item_data {
     my $self = shift;
     return \%LJ::Pay::Payment::PayItem::Addon::userpic_large;

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/Addon.pm	2010-08-16 07:07:45 UTC (rev 9335)
@@ -6,6 +6,7 @@
 use LJ::Pay::Util qw/_err _get_dbh _debug/;
 use LJ::TimeUtil;
 
+sub is_recbillable { 1 } 
 sub should_recheck_cart { return 1; }
 sub _activate_item { die 'Must be redeclared in child class'; }
 sub _adopt_item { die 'Must be redeclared in child class'; }
@@ -383,7 +384,7 @@
         $$error_ref = "Can't activate item: $$error_ref" if $error_ref;
         return;
     }
-    
+
     unless ($item_to_deliver->add_paidexp_time(
                 exp         => $exp, 
                 new_size    => $new_size, 
@@ -406,7 +407,7 @@
 sub load_paidexp_row {
     my ($class, $u) = @_;
 
-    my $item = $class->item;
+    my $item = $class->paidexp_item;
 
     # allow u/payitem objects passed optionally
     my $userid = LJ::want_userid($u);

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem/RecBillAble.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem/RecBillAble.pm	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem/RecBillAble.pm	2010-08-16 07:07:45 UTC (rev 9335)
@@ -106,22 +106,22 @@
 
 sub validate_recbill_fields {
     my $self = shift;
-    _err("Must be redefined in child class");
+    $self->is_recbillable ? _err("Must be redefined in child class") : 1;
 }
 
 sub load_for_recbill {
     my $self = shift;
-    _err("Must be redefined in child class");
+    $self->is_recbillable ? _err("Must be redefined in child class") : 1;
 }
 
 sub set_exptime {
     my $self = shift;
-    _err("Must be redefined in child class");
+    $self->is_recbillable ? _err("Must be redefined in child class") : 1;
 }
 
 sub set_lastmailed {
     my $self = shift;
-    _err("Must be redefined in child class");
+    $self->is_recbillable ? _err("Must be redefined in child class") : 1;
 }
 
 1;

Modified: trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/cgi-bin/LJ/Pay/Payment/PayItem.pm	2010-08-16 07:07:45 UTC (rev 9335)
@@ -46,6 +46,7 @@
     'userpic_small' => 'LJ::Pay::Payment::PayItem::Addon::Userpics::Small',
     'userpic_large' => 'LJ::Pay::Payment::PayItem::Addon::Userpics::Large',
     'tokens'        => 'LJ::Pay::Payment::PayItem::WalletTokens',
+    'userhead'      => 'LJ::Pay::Payment::PayItem::UserHead',
 );
 
 my @FREEZABLE_CLASSES = qw/
@@ -65,6 +66,12 @@
     return $CLASSES{$item};
 }
 
+sub paidexp_item {
+    my $self = shift;
+
+    return $self->item;
+}
+
 sub new {
     my $class = shift;
 
@@ -87,7 +94,12 @@
     my $class = ref($s) || $s;
     if ($class eq 'LJ::Pay::Payment::PayItem') { 
         # parent class call -> need factory
-        my $child_class = $class->get_class_for_item($args{item}) 
+        my $item = $args{item};
+
+        ## Exception: UserHeads has a 'uh-\d+' coding in a paidexp table
+        $item = ($item =~ m#uh-\d+#) ? 'userhead' : $item;
+        ## 
+        my $child_class = $class->get_class_for_item($item) 
             or return _err("No class for item '$args{item}'");
         return $child_class->new_memonly(%args);
     } else {

Modified: trunk/cgi-bin/LJ/Pay/RecBill/Item.pm
===================================================================
--- trunk/cgi-bin/LJ/Pay/RecBill/Item.pm	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/cgi-bin/LJ/Pay/RecBill/Item.pm	2010-08-16 07:07:45 UTC (rev 9335)
@@ -194,9 +194,12 @@
 
     return $invalid->('userid')
         unless $self->{userid} > 0;
-    return $invalid->('name')
-        unless $item_obj->isa('LJ::Pay::Payment::PayItem::RecBillAble');
 
+    if ($item_obj->is_recbillable) {
+        return $invalid->('name')
+            unless $item_obj->isa('LJ::Pay::Payment::PayItem::RecBillAble');
+    }
+
     return $invalid->('exptime') unless $self->{exptime} > 0;
 
     $self->{lastmailed} = undef unless $self->{lastmailed} > 0;

Modified: trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm	2010-08-16 07:07:45 UTC (rev 9335)
@@ -26,6 +26,11 @@
             is_selected => $subpage eq 'wallet' ? 1 : 0,
         },
         {
+            name => BML::ml('.storefront.addons.userheads'),
+            url => '/shop/userheads.bml',
+            is_selected => $subpage eq 'userhead' ? 1 : 0,
+        },
+        {
             name => BML::ml('.storefront.addons.extrauserpics'),
             url => '/shop/userpics.bml',
             is_selected => $subpage eq 'userpics' ? 1 : 0,

Modified: trunk/htdocs/shop/index.bml.text.local
===================================================================
--- trunk/htdocs/shop/index.bml.text.local	2010-08-13 08:15:24 UTC (rev 9334)
+++ trunk/htdocs/shop/index.bml.text.local	2010-08-16 07:07:45 UTC (rev 9335)
@@ -17,6 +17,8 @@
 
 .storefront.addons.storage=Extra Storage Space
 
+.storefront.addons.userheads=Custom User Heads
+
 .storefront.addons.subhead.others|staleness=1
 .storefront.addons.subhead.others=For others:
 

Tags: 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