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

[livejournal] r23342: LJSUP-13388: LJ Shop - Styles

Committer: wisest-owl
LJSUP-13388: LJ Shop - Styles

U   trunk/cgi-bin/LJ/Customize.pm
U   trunk/cgi-bin/LJ/S2.pm
U   trunk/cgi-bin/LJ/S2Theme.pm
U   trunk/cgi-bin/LJ/Widget/ThemeChooser.pm
Modified: trunk/cgi-bin/LJ/Customize.pm
===================================================================
--- trunk/cgi-bin/LJ/Customize.pm	2012-11-21 12:31:52 UTC (rev 23341)
+++ trunk/cgi-bin/LJ/Customize.pm	2012-11-21 12:41:58 UTC (rev 23342)
@@ -328,6 +328,11 @@
             next unless LJ::run_hook("layer_is_active", $theme->uniq) && LJ::run_hook("layer_is_active", $theme->layout_uniq);
         }
 
+        if ($theme->is_buyable) {
+            my $shop_theme = LJ::Pay::Theme->load_by_s2lid ($theme->s2lid);
+            next if $shop_theme && $shop_theme->is_disabled;
+        }
+
         my $theme_name = LJ::ejs($theme->name);
         my $layout_name = LJ::ejs($theme->layout_name);
         my $designer_name = LJ::ejs($theme->designer);
@@ -648,12 +653,20 @@
 sub get_cats {
     my $class = shift;
     my $u = shift;
-        
+ 
+    my %purchased = $LJ::DISABLED{'lj_shop_styles'} ? () : (
+        purchased => {
+            text => LJ::Lang::ml('customize.cats.purchased'),
+            main => 1,
+            order => 3,
+        },
+    );
+
     my @categories = (
         all => {
             text => LJ::Lang::ml('customize.cats.all'),
             main => 1,
-            order => 3,
+            order => 4,
         },
         featured => {
             text => LJ::Lang::ml('customize.cats.featured'),
@@ -665,15 +678,16 @@
             main => 1,
             order => 2,
         },
+        %purchased,
         special => {
             text => LJ::Lang::ml('customize.cats.special'),
             main => 1,
-            order => 4,
+            order => 5,
         },
         custom => {
             text => LJ::Lang::ml('customize.cats.custom'),
             main => 1,
-            order => 5,
+            order => 6,
         },
         sup => {
             text => LJ::Lang::ml('customize.cats.sup'),

Modified: trunk/cgi-bin/LJ/S2.pm
===================================================================
--- trunk/cgi-bin/LJ/S2.pm	2012-11-21 12:31:52 UTC (rev 23341)
+++ trunk/cgi-bin/LJ/S2.pm	2012-11-21 12:41:58 UTC (rev 23342)
@@ -593,7 +593,7 @@
                             "FROM s2layers l, s2info i ".
                             "WHERE l.userid=? AND l.s2lid=i.s2lid AND ".
                             "i.infokey IN ($extrainfo 'type', 'name', 'langcode', ".
-                            "'majorversion', '_previews')");
+                            "'majorversion', '_previews', 'is_buyable')");
     $sth->execute($userid);
     die $dbr->errstr if $dbr->err;
     while (my ($key, $val, $id, $bid, $type) = $sth->fetchrow_array) {
@@ -604,6 +604,7 @@
         $layers{$id}->{$key} = $val;
     }
 
+
     foreach (keys %layers) {
         # setup uniq alias.
         if ($layers{$_}->{'uniq'} ne "") {

Modified: trunk/cgi-bin/LJ/S2Theme.pm
===================================================================
--- trunk/cgi-bin/LJ/S2Theme.pm	2012-11-21 12:31:52 UTC (rev 23341)
+++ trunk/cgi-bin/LJ/S2Theme.pm	2012-11-21 12:41:58 UTC (rev 23342)
@@ -186,7 +186,12 @@
         my $theme = $class->new( themeid => $layer );
 
         # we have a theme, now see if it's in the given category
-        foreach my $possible_cat ($theme->cats) {
+        my @theme_cats = $theme->cats;
+        if ($theme->is_buyable) {
+            my $shop_theme = LJ::Pay::Theme->load_by_s2lid ($theme->s2lid);
+            @theme_cats = @{$shop_theme->get_cats};
+        }
+        foreach my $possible_cat (@theme_cats) {
             next unless $possible_cat eq $cat;
             push @themes, $theme;
             last;
@@ -241,6 +246,17 @@
     return @themes;
 }
 
+sub load_purchased {
+    my $class = shift;
+    my $u     = shift;
+
+    die "Invalid user object." unless LJ::isu($u);
+
+    my @shop_themes = LJ::Pay::Theme->get_purchased ($u);
+
+    return @shop_themes;
+}
+
 sub load_by_search {
     my $class = shift;
     my $term = shift;
@@ -366,6 +382,7 @@
     my $layers = LJ::S2::get_public_layers();
     my $is_custom = 0;
     my %outhash = ();
+
     unless ($layers->{$themeid} && $layers->{$themeid}->{uniq}) {
         if ($opts{user}) {
             my $u = $opts{user};
@@ -431,7 +448,7 @@
     $layout_class = "LJ::S2Theme::$layout_class";
 
     # make this theme an object of the lowest level class that's defined
-    if ($outhash{$themeid}{'is_buyable'}) {
+    if ($layers->{$themeid}->{'is_buyable'} || $outhash{$themeid}{'is_buyable'}) {
         bless $self, "LJ::S2Theme::LJShopStyle";
     } elsif (eval { $theme_class->init }) {
         bless $self, $theme_class;

Modified: trunk/cgi-bin/LJ/Widget/ThemeChooser.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/ThemeChooser.pm	2012-11-21 12:31:52 UTC (rev 23341)
+++ trunk/cgi-bin/LJ/Widget/ThemeChooser.pm	2012-11-21 12:41:58 UTC (rev 23342)
@@ -46,6 +46,9 @@
     } elsif ($cat eq "custom") {
         push @getargs, "cat=custom";
         @themes = LJ::S2Theme->load_by_user($u);
+    } elsif ($cat eq "purchased") {
+        push @getargs, "cat=purchased";
+        @themes = LJ::S2Theme->load_purchased($u);
     } elsif ($cat) {
         push @getargs, "cat=$cat";
         @themes = LJ::S2Theme->load_by_cat($cat);
@@ -129,7 +132,10 @@
     foreach my $theme (@themes_this_page) {
         next unless defined $theme;
 
-        next if $theme->is_buyable;
+        if ($theme->is_buyable) {
+            my $shop_theme = LJ::Pay::Theme->load_by_s2lid ($theme->s2lid);
+            next if $shop_theme && $shop_theme->is_disabled;
+        }
 
         # figure out the type(s) of theme this is so we can modify the output accordingly
         my %theme_types;
@@ -140,6 +146,7 @@
         }
         $theme_types{upgrade} = 1 if !$filter_available && !$theme->available_to($u);
         $theme_types{special} = 1 if LJ::run_hook("layer_is_special", $theme->uniq);
+        $theme_types{shop_item} = 1 if !$theme_types{current} && $theme->is_buyable;
 
         
         my ($theme_class, $theme_options, $theme_icons) = ("", "", "");
@@ -169,6 +176,10 @@
             $theme_class .= " special" if $viewing_featured && LJ::run_hook("should_see_special_content", $u);
             $theme_icons .= LJ::run_hook("customize_available_until", $theme);
         }
+        if ($theme_types{shop_item}) {
+            $theme_class .= " shop-item";
+            $theme_options .= LJ::run_hook("customize_shop_item_options", $u, $theme);
+        }
         $theme_icons .= "</div><!-- end .theme-icons -->" if $theme_icons;
 
         my $theme_layout_name = $theme->layout_name;

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