Committer: wisest-owl
LJSUP-13388: LJ Shop - StylesU trunk/bin/upgrading/en.dat U trunk/bin/upgrading/update-db.pl U trunk/cgi-bin/LJ/S2Theme.pm U trunk/cgi-bin/LJ/Widget/ThemeChooser.pm
Modified: trunk/bin/upgrading/en.dat =================================================================== --- trunk/bin/upgrading/en.dat 2012-11-19 13:07:01 UTC (rev 23321) +++ trunk/bin/upgrading/en.dat 2012-11-19 13:34:44 UTC (rev 23322) @@ -1107,6 +1107,8 @@ customize.cats.premium|staleness=1 customize.cats.premium=Premium +customize.cats.purchased=Purchased + customize.cats.special|staleness=1 customize.cats.special=Special Modified: trunk/bin/upgrading/update-db.pl =================================================================== --- trunk/bin/upgrading/update-db.pl 2012-11-19 13:07:01 UTC (rev 23321) +++ trunk/bin/upgrading/update-db.pl 2012-11-19 13:34:44 UTC (rev 23322) @@ -21,6 +21,8 @@ use LJ::S2; use MogileFS::Admin; +use LJ::Pay::Theme; + my $opt_sql = 0; my $opt_drop = 0; my $opt_pop = 0; @@ -404,6 +406,7 @@ $dbh->do("INSERT INTO s2info (s2lid, infokey, value) VALUES (?,'redist_uniq',?)", undef, $id, $base); } + } die "Can't generate ID for '$base'" unless $id; @@ -470,6 +473,20 @@ exit 1; } + my %th_hash = (); + LJ::S2::load_layer_info(\%th_hash, [ $id ]); + if ($th_hash{$id}{'is_buyable'}) { + my $s2_theme = LJ::S2Theme->new (themeid => $id); + my @s2_theme_cats = $s2_theme->cats; + my $theme_shop = LJ::Pay::Theme->load_by_s2lid ($id); + print "Create/modify $base($id) in shop table\n"; + $theme_shop = LJ::Pay::Theme->new () unless $theme_shop; + $theme_shop->name ($th_hash{$id}{'name'}); + $theme_shop->s2tid ($id); + $theme_shop->save_to_db; + $theme_shop->add_cat ($_) foreach @s2_theme_cats; + } + if ($opt_compiletodisk) { open( CO, '>', "$LD/$base.pl" ) or die; print CO $compiled; Modified: trunk/cgi-bin/LJ/S2Theme.pm =================================================================== --- trunk/cgi-bin/LJ/S2Theme.pm 2012-11-19 13:07:01 UTC (rev 23321) +++ trunk/cgi-bin/LJ/S2Theme.pm 2012-11-19 13:34:44 UTC (rev 23322) @@ -431,7 +431,9 @@ $layout_class = "LJ::S2Theme::$layout_class"; # make this theme an object of the lowest level class that's defined - if (eval { $theme_class->init }) { + if ($outhash{$themeid}{'is_buyable'}) { + bless $self, "LJ::S2Theme::LJShopStyle"; + } elsif (eval { $theme_class->init }) { bless $self, $theme_class; } elsif (eval { $layout_class->init }) { bless $self, $layout_class; @@ -725,5 +727,6 @@ sub setup_props { () } sub ordering_props { () } sub custom_props { () } +sub is_buyable { 0 } 1; Modified: trunk/cgi-bin/LJ/Widget/ThemeChooser.pm =================================================================== --- trunk/cgi-bin/LJ/Widget/ThemeChooser.pm 2012-11-19 13:07:01 UTC (rev 23321) +++ trunk/cgi-bin/LJ/Widget/ThemeChooser.pm 2012-11-19 13:34:44 UTC (rev 23322) @@ -129,6 +129,8 @@ foreach my $theme (@themes_this_page) { next unless defined $theme; + next if $theme->is_buyable; + # figure out the type(s) of theme this is so we can modify the output accordingly my %theme_types; if ($theme->themeid) {