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

[ljcom] r9514: LJSUP-6796. Adding userheads for nonSUP ...

Committer: gprochaev
LJSUP-6796. Adding userheads for nonSUP users

U   trunk/bin/upgrading/update-db-local.pl
U   trunk/cgi-bin/LJ/UserHead.pm
U   trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm
U   trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm
U   trunk/htdocs/admin/userheads/manage.bml
U   trunk/htdocs/stc/shop/shop.css
U   trunk/templates/Shop/UserHeads.tmpl
Modified: trunk/bin/upgrading/update-db-local.pl
===================================================================
--- trunk/bin/upgrading/update-db-local.pl	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/bin/upgrading/update-db-local.pl	2010-09-20 07:26:33 UTC (rev 9514)
@@ -2004,6 +2004,11 @@
                  "ALTER TABLE shop_userheads ADD uh_desc VARCHAR(20) DEFAULT '' AFTER uh_author");
     }
 
+    unless (column_type("shop_userheads", "uh_desc_sup")) {
+        do_alter("shop_userheads",
+                "ALTER TABLE shop_userheads ADD visibility CHAR(1) NOT NULL DEFAULT 'D' AFTER price, ADD uh_desc_sup VARCHAR(20) AFTER uh_desc");
+    }
+
     unless (column_type("smsru_phones", "phone") =~ /char/i) {
         do_alter("smsru_phones",
             "ALTER TABLE smsru_phones MODIFY phone VARCHAR(12)");

Modified: trunk/cgi-bin/LJ/UserHead.pm
===================================================================
--- trunk/cgi-bin/LJ/UserHead.pm	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/cgi-bin/LJ/UserHead.pm	2010-09-20 07:26:33 UTC (rev 9514)
@@ -4,7 +4,7 @@
 
 use base qw(Class::Accessor);
 __PACKAGE__->follow_best_practice;
-__PACKAGE__->mk_accessors( qw( uh_id uh_author uh_desc price ) );
+__PACKAGE__->mk_accessors( qw( uh_id uh_author uh_desc uh_desc_sup price visibility ) );
 
 sub new {
     my $class = shift;
@@ -69,7 +69,7 @@
     my $dbh         = LJ::get_db_writer();
     my $is_enabled  = shift || 0;
 
-    my $where = $is_enabled ? " WHERE is_enabled = 1 " : "";
+    my $where = $is_enabled ? " WHERE visibility != 'D' " : "";
 
     my $uhs = $dbh->selectall_arrayref ("SELECT * FROM shop_userheads $where ORDER BY uh_id", { Slice => {} });
 

Modified: trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/cgi-bin/LJ/Widget/Shop/LeftMenu.pm	2010-09-20 07:26:33 UTC (rev 9514)
@@ -25,20 +25,12 @@
             url => '/shop/tokens.bml',
             is_selected => $subpage eq 'wallet' ? 1 : 0,
         },
-    ];
-
-    unless (!$is_remote_sup && $LJ::DISABLED{'userhead_nonsup'}) {
-        push @$paid_services, (
-            {
-                name => BML::ml('.storefront.addons.userheads'),
-                url => '/shop/userheads.bml',
-                is_selected => $subpage eq 'userhead' ? 1 : 0,
-            },
-        );
-    }
-
-    push @$paid_services, (
         {
+            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,
@@ -53,7 +45,7 @@
             url => '/shop/renameaccount.bml',
             is_selected => $subpage eq 'renameaccount' ? 1 : 0,
         },
-    );
+    ];
 
     my %top_map = (
         paidaccount => 0,

Modified: trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/cgi-bin/LJ/Widget/Shop/View/UserHeads.pm	2010-09-20 07:26:33 UTC (rev 9514)
@@ -43,8 +43,6 @@
 
     my $remote = LJ::get_remote();
     my $is_remote_sup = LJ::SUP->is_remote_sup();
-    return LJ::Request->redirect("/shop/")
-        if !$is_remote_sup && $LJ::DISABLED{'userhead_nonsup'};
 
     my $gift = ((!$remote || LJ::Request->get_param('gift'))) || 0;
     my $recipient = $gift ? LJ::load_user(LJ::Request->get_param('giftto')) : undef;
@@ -53,11 +51,6 @@
         $self->push_error (LJ::Lang::ml('shop.error.userhead.not_personal'));
     }
 
-    if ($LJ::DISABLED{'userhead_nonsup'} && $recipient && !LJ::SUP->is_sup_enabled($recipient)) {
-        $recipient = undef;
-        $self->push_error (LJ::Lang::ml('shop.error.userhead.non-sup.disabled'));
-    }
-
     my ($sec, $min, $hour, $mday, $mon, $year) = localtime(time);
 
     # autocomplete To field on Add form
@@ -77,10 +70,18 @@
                     $_->get_price == 1.99 &&
                     LJ::Pay::can_use_sup_sms($remote);
                 $_->{sup_sms} = $sup_sms;
+                $_->{uh_desc} = $_->{uh_desc_sup} if $is_remote_sup;
                 $_;
             } @$uhs 
     ];
 
+    $uhs = [
+        grep {
+            $_->{visibility} =~ /[AS]/ && $is_remote_sup
+            || $_->{visibility} =~ /[AN]/ && !$is_remote_sup
+        } @$uhs
+    ];
+
     my %ret = (
         siteroot            => $LJ::SITEROOT,
         is_gift             => $gift,
@@ -104,6 +105,7 @@
         js_complete         => $js_complete,
         auth_token          => $authtoken,
         smspay_title        => LJ::Lang::ml('shop.view.userheads.smspay.title'),
+        is_sup              => $is_remote_sup,
 
     );
 

Modified: trunk/htdocs/admin/userheads/manage.bml
===================================================================
--- trunk/htdocs/admin/userheads/manage.bml	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/htdocs/admin/userheads/manage.bml	2010-09-20 07:26:33 UTC (rev 9514)
@@ -42,12 +42,15 @@
         my $is_enabled = $FORM{"$id-is_enabled"} eq 'on' ? 1 : 0;
         my $author = $FORM{"$id-author"};
         my $desc = $FORM{"$id-desc"};
+        my $desc_sup = $FORM{"$id-desc-sup"};
         my $price = $FORM{"$id-price"};
+        my $visibility = $FORM{"$id-visibility"};
         my $uh = LJ::UserHead->get_userhead ($FORM{"$id-uh_id"});
         $uh->set_uh_author ($author);
         $uh->set_price ($price);
         $uh->set_uh_desc ($desc);
-        $uh->set_enabled ($is_enabled);
+        $uh->set_uh_desc_sup ($desc_sup);
+        $uh->set_visibility ($visibility);
         $uh->save;
     }
 }
@@ -83,20 +86,44 @@
 
 my $uhs = LJ::UserHead->get_all_userheads();
 
+my @selects = (
+    {
+        value => 'A',
+        name  => 'Both',
+    },
+    {
+        value => 'S',
+        name  => 'SUP',
+    },
+    {
+        value => 'N',
+        name  => 'NonSUP',
+    },
+    {
+        value => 'D',
+        name  => 'Disabled',
+    },
+);
+
 $ret .= "<form method='POST'>";
 $ret .= "<table border=0 cellspacing=1 cellpadding=4>";
-$ret .= "<tr><td>Id</td><td>Img</td><td>Cost</td><td>&nbsp;</td><td>Author</td><td>Description</td></tr>";
+$ret .= "<tr><td>Id</td><td>Img</td><td>Cost</td><td>&nbsp;</td><td>Author</td><td>Description</td><td>Description SUP</td></tr>";
 foreach my $uh (@$uhs) {
-    $ret .= "<tr>";
-    $ret .= "<td><input type='hidden' name='".$uh->get_uh_id."-uh_id' value='".$uh->get_uh_id."'>".$uh->get_uh_id."</td>";
-    $ret .= "<td><img src='".$uh->get_uh_img."'></td>";
-    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-price' size='5' value='".$uh->get_price."'></td>";
-    $ret .= "<td><input type='checkbox' name='".$uh->get_uh_id."-is_enabled' ". ($uh->is_enabled ? "checked='checked'" : "") ."> available </td>";
-    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-author' value='".$uh->get_uh_author."'></td>";
-    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc' value='".$uh->get_uh_desc."'></td>";
-    $ret .= "</tr>";
+    $ret .= "<tr>\n";
+    $ret .= "<td><input type='hidden' name='".$uh->get_uh_id."-uh_id' value='".$uh->get_uh_id."'>".$uh->get_uh_id."</td>\n";
+    $ret .= "<td><img src='".$uh->get_uh_img."'></td>\n";
+    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-price' size='5' value='".$uh->get_price."'></td>\n";
+    $ret .= "<td><select name='".$uh->get_uh_id."-visibility'>\n";
+    foreach my $sel (@selects) {
+        $ret .= "\t<option value='".$sel->{'value'}."'".($uh->get_visibility eq $sel->{'value'} ? " selected='selected' " : "").">".$sel->{'name'}."</option>\n";
+    }
+    $ret .= "</select></td>\n";
+    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-author' value='".$uh->get_uh_author."'></td>\n";
+    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc' value='".$uh->get_uh_desc."'></td>\n";
+    $ret .= "<td><input type='text' name='".$uh->get_uh_id."-desc-sup' value='".$uh->get_uh_desc_sup."'></td>\n";
+    $ret .= "</tr>\n";
 }
-$ret .= "<tr><td colspan='5'><input type='submit' name='save' value='Save'></td></tr>";
+$ret .= "<tr><td colspan='5'><input type='submit' name='save' value='Save'></td></tr>\n";
 $ret .= "</table>";
 $ret .= "</form>";
 $ret .= "<hr>";

Modified: trunk/htdocs/stc/shop/shop.css
===================================================================
--- trunk/htdocs/stc/shop/shop.css	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/htdocs/stc/shop/shop.css	2010-09-20 07:26:33 UTC (rev 9514)
@@ -1133,6 +1133,11 @@
 	min-height:208px;
 	background:url(/img/shop/userheads-intro.gif) no-repeat 100% 100%;
 	}
+.b-userheads-intro_sup {
+	padding: 15px 252px 15px 15px;
+	min-height:208px;
+	background:url(/img/shop/userheads-intro-sup.gif) no-repeat 100% 100%;
+	}
 .b-shop .b-userheads-items {
 	padding: 20px 29px;
 	margin: 0;

Modified: trunk/templates/Shop/UserHeads.tmpl
===================================================================
--- trunk/templates/Shop/UserHeads.tmpl	2010-09-20 00:55:12 UTC (rev 9513)
+++ trunk/templates/Shop/UserHeads.tmpl	2010-09-20 07:26:33 UTC (rev 9514)
@@ -4,7 +4,7 @@
 <div id="shop_userheads">
 <tmpl_var js_complete>
 
-<div class="b-shop-intro b-userheads-intro">
+<div class="b-shop-intro b-userheads-intro<tmpl_if is_sup>-sup</tmpl_if>">
 	<h3><TMPL_VAR expr="ml('shop.view.userheads.promo.title')"></h3>
 	<p><TMPL_VAR expr="ml('shop.view.userheads.promo.text')"></p>
 </div>

Tags: bml, css, ljcom, pl, pm, tmpl, 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