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

[livejournal] r17123: LJSUP-6515. Custom Userheads.

Committer: gprochaev
LJSUP-6515. Custom Userheads.


U   trunk/htdocs/js/contextualhover.js
U   trunk/htdocs/manage/profile/index.bml
U   trunk/htdocs/manage/profile/index.bml.text
U   trunk/htdocs/tools/endpoints/ctxpopup.bml
U   trunk/htdocs/tools/endpoints/ctxpopup.bml.text
Modified: trunk/htdocs/js/contextualhover.js
===================================================================
--- trunk/htdocs/js/contextualhover.js	2010-08-13 07:28:05 UTC (rev 17122)
+++ trunk/htdocs/js/contextualhover.js	2010-08-16 07:06:11 UTC (rev 17123)
@@ -463,6 +463,16 @@
 		content.appendChild(document.createElement('br'));
 	}
 	
+	// buy the same userhead
+	if (data.is_logged_in && data.is_person && ! data.is_requester && data.url_message) {
+		jQuery('<a/>', {
+			href: data.url_buy_userhead,
+			text: data.ml_buy_same_userhead
+		})
+		.appendTo(content);
+		content.appendChild(document.createElement('br'));
+	}
+
 	// send message
 	if (data.is_logged_in && data.is_person && ! data.is_requester && data.url_message) {
 		jQuery('<a/>', {

Modified: trunk/htdocs/manage/profile/index.bml
===================================================================
--- trunk/htdocs/manage/profile/index.bml	2010-08-13 07:28:05 UTC (rev 17122)
+++ trunk/htdocs/manage/profile/index.bml	2010-08-16 07:06:11 UTC (rev 17123)
@@ -7,6 +7,7 @@
     use vars qw(%POST %GET $headextra @errors);
     use LJ::Setting;
     use LJ::TimeUtil;
+    use LJ::UserHead;
 
     LJ::set_active_crumb('editprofile');
     LJ::need_res('stc/lj_base.css', 'stc/lj_settings.css');
@@ -18,6 +19,14 @@
         return $ad_full_width . $str;
     };
 
+    # epoch -> pretty
+    my $date_format = sub {
+        my $date = localtime( shift() );
+        return "$1 $2, $3"
+          if $date =~ /^\w+\s+(\w+)\s+(\d+)\s+[\d:]+\s+(\d+)/;
+        return "[ $ML{'.error.invaliddate'} ]";
+    };
+
     return $print_with_ad->(LJ::server_down_html()) if $LJ::SERVER_DOWN;
 
     my $remote = LJ::get_remote()
@@ -220,6 +229,56 @@
                                     'size' => '50', 'maxlength' => '100' });
         }
 
+        ## USERHEADS
+        if ($u->is_personal) {
+            $ret .= "<a name='userheads'></a><div class='section_head'>$ML{'.section.userheads'}</div>\n";
+
+            $ret .= "<table>\n";
+
+            $ret .= "<tr><td class='field_name'>$ML{'.fn.active.userhead'}</td><td>";
+            my $uh_prop = $u->custom_usericon;
+            my $class = LJ::Pay::Payment::PayItem->get_class_for_item('userhead');
+            my $uhs = $class->get_expire_times ($u);
+            if ($uh_prop) {
+                ## Try to fetch expire date by userhead user's prop
+                ## At first we try to find uh in a shop
+                my $uhs_all = LJ::UserHead->get_all_userheads ();
+                my ($uh) = grep { $_->get_uh_img eq $uh_prop } @$uhs_all;
+                if ($uh) {
+                    ## we found a uh. get id and look at paid exp for expire date
+                    $ret .= "<img src='".$uh->get_uh_img."' border='0'>";
+                    ## whether the user bought userhead?
+                    if (my ($found_uh) = grep { $_->{item} == "uh_".$uh->get_uh_id } @$uhs) {
+                        $ret .= LJ::Lang::ml('.section.userheads.expire_date', { date => $date_format->($found_uh->{expdate}) });
+                    }
+                } else {
+                    if ($uh_prop =~ /^http/) {
+                        $ret .= "<img src='$uh_prop'>";
+                    } else {
+                        $ret .= "<img src='$LJ::FILEPREFIX/$uh_prop'>";
+                    }
+                }
+            } else {
+                $ret .= "<img src='$LJ::DEFAULT_USERHEAD'>&nbsp; $ML{'.fn.userheads.default_userhead'}";
+            }
+            $ret .= "</td></tr>";
+            $ret .= "<tr><td class='field_name'>$ML{'.fn.userheads.collection'}</td><td>";
+            if (scalar @$uhs) {
+                $ret .= LJ::Lang::ml('.section.userhead.apply.href', { aopts => "href='$LJ::SITEROOT/shop/userheads.bml'" } );
+                $ret .= "<br><input type='radio' name='uh_id' value='default'><img src='$LJ::DEFAULT_USERHEAD'>&nbsp; $ML{'.fn.userheads.default_userhead'}</br>";
+                foreach my $uh (@$uhs) {
+                    my ($uh_id) = $uh->{item} =~ /uh-(\d+)/;
+                    my $uh_obj = LJ::UserHead->get_userhead ($uh_id);
+                    $ret .= "<input type='radio' name='uh_id' value='$uh_id'><img src='".$uh_obj->get_uh_img."' border='0'> ".LJ::Lang::ml('.section.userheads.expire_date', { date => $date_format->($uh->{expdate}) })."<br/> <!--(<a href='/shop/'>extend</a>)--><hr>";
+                }
+            } else {
+                $ret .= LJ::Lang::ml('.section.userhead.no_userheads', { url => $LJ::SITEROOT."/shop/userheads.bml" });
+            }
+            $ret .= "</td></tr>\n\n";
+
+            $ret .= "</table>\n";
+        }
+
         ## INTERESTS
 
         {
@@ -761,6 +820,15 @@
             LJ::set_interests($u, \%interests, \@valid_ints);
         }
 
+        ## save the changed userhead
+        if ($POST{'uh_id'} eq 'default') {
+            $u->set_custom_usericon (undef);
+        } else {
+            my $uh = LJ::UserHead->get_userhead ($POST{'uh_id'});
+            $u->set_custom_usericon ($uh->get_uh_img)
+                if $uh;
+         }
+
         # actions if email changed
         if ($email_changed) {
             my $aa = {};

Modified: trunk/htdocs/manage/profile/index.bml.text
===================================================================
--- trunk/htdocs/manage/profile/index.bml.text	2010-08-13 07:28:05 UTC (rev 17122)
+++ trunk/htdocs/manage/profile/index.bml.text	2010-08-16 07:06:11 UTC (rev 17123)
@@ -104,6 +104,8 @@
 
 .error.year.outofrange=Invalid birthday year.
 
+.fn.active.userhead=Active Userhead
+
 .fn.bio=Tell other users about yourself or your journal. If you want to display graphics, counters, or other HTML, you can enter it here.
 
 .fn.birthday=Birthday
@@ -161,6 +163,10 @@
 
 .fn.userpic=Default userpic
 
+.fn.userheads.default_userhead=Default userhead
+
+.fn.userheads.collection=Collection
+
 .fn.zip=ZIP Code
 
 .friendof=Show other users who have friended you, but you have not friended
@@ -354,6 +360,14 @@
 .section.theme|staleness=1
 .section.theme=Community Theme
 
+.section.userheads=Userheads
+
+.section.userhead.no_userheads=No custom userheads. You can <a href='[[url]]'>buy it now</a>.
+
+.section.userheads.expire_date=Expire [[date]]
+
+.section.userhead.apply.href=Click userhead to apply (or <a [[aopts]]>buy more userheads</a>):
+
 .section.web=Web Page
 
 .security.visibility.everybody=Everybody

Modified: trunk/htdocs/tools/endpoints/ctxpopup.bml
===================================================================
--- trunk/htdocs/tools/endpoints/ctxpopup.bml	2010-08-13 07:28:05 UTC (rev 17122)
+++ trunk/htdocs/tools/endpoints/ctxpopup.bml	2010-08-16 07:06:11 UTC (rev 17123)
@@ -71,6 +71,8 @@
 
     $ret{url_addfriend} = "$LJ::SITEROOT/friends/add.bml?user=" . $u->{user};
 
+    $ret{url_buy_userhead} = $LJ::SITEROOT."/shop/userheads.bml";
+
     my $up = $u->userpic;
     if ($up) {
         $ret{url_userpic} = $up->url;
@@ -114,7 +116,7 @@
     my @ml_keys = qw/ 
         add_friend ban community feed join_community journal leave 
         lists_as_friend loading mutual_friend profile remove_friend
-        report send_gift send_message stop_community subscribe_feed
+        report send_gift buy_same_userhead send_message stop_community subscribe_feed
         this_is_you unban unsubscribe_feed updating view watch_community
         your_friend you_member you_subscribed you_watching
     /;

Modified: trunk/htdocs/tools/endpoints/ctxpopup.bml.text
===================================================================
--- trunk/htdocs/tools/endpoints/ctxpopup.bml.text	2010-08-13 07:28:05 UTC (rev 17122)
+++ trunk/htdocs/tools/endpoints/ctxpopup.bml.text	2010-08-16 07:06:11 UTC (rev 17123)
@@ -9,6 +9,8 @@
 
 .ban=Ban user
 
+.buy_same_userhead=Buy the same user head
+
 .community=Community
 
 .editalias.title|staleness=1

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