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

[livejournal] r22881: LJSUP-13633: Can't change individual use...

Committer: wisest-owl
LJSUP-13633: Can't change individual userhead

U   trunk/cgi-bin/LJ/User.pm
Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2012-09-13 08:45:04 UTC (rev 22880)
+++ trunk/cgi-bin/LJ/User.pm	2012-09-13 09:00:25 UTC (rev 22881)
@@ -6265,33 +6265,39 @@
 sub custom_usericon {
     my ($u) = @_;
 
-    my $url = "";
+    ## Get user's selected userhead
+    my $selected_uh_id = 0;
+    my $url = $u->prop('custom_usericon') || '';
+    if (
+           $url =~ /userhead/
+        && $url !~ /v=\d+/
+        && (my ($uh_id) = ($selected_uh_id) = $url =~ m/\/userhead\/(\d+)$/)
+    ) {
+        my $uh = LJ::UserHead->get_userhead ($uh_id);
+        if ($uh) {
+            my $uh_fs = LJ::FileStore->get_path_info ( path => "/userhead/".$uh->get_uh_id );
+            $url .= "?v=".$uh_fs->{'change_time'} if $uh_fs->{'change_time'};
+        }
+    }
 
+    ## Check for individual userhead
+    my $indiv_uh_id = 0;
     my $propval = $u->prop ('custom_usericon_individual');
     if ($propval) {
+        ## If it buyed we need to check exp date
         my $individual_uh_info = LJ::JSON->from_json ($propval);
         if ($individual_uh_info->{'date_exp'} > time) {
-            my ($uh_id) = $individual_uh_info->{'uh_id'} =~ m#uh-(\d+)#;
+            my ($uh_id) = ($indiv_uh_id) = $individual_uh_info->{'uh_id'} =~ m#uh-(\d+)#;
             my $uh = LJ::UserHead->get_userhead ($uh_id);
-            if ($uh) {
+            if ($uh && $selected_uh_id == $indiv_uh_id) {
                 my $uh_fs = LJ::FileStore->get_path_info ( path => "/userhead/".$uh_id );
                 $url = $LJ::FILEPREFIX."/userhead/".$uh_id;
                 $url .= "?v=".$uh_fs->{'change_time'} if $uh_fs->{'change_time'};
             }
         } else {
-            $u->set_custom_usericon (undef);
-        }
-    } else {
-        $url = $u->prop('custom_usericon') || '';
-        if (
-               $url =~ /userhead/
-            && $url !~ /v=\d+/
-            && (my ($uh_id) = $url =~ m/\/userhead\/(\d+)$/)
-        ) {
-            my $uh = LJ::UserHead->get_userhead ($uh_id);
-            if ($uh) {
-                my $uh_fs = LJ::FileStore->get_path_info ( path => "/userhead/".$uh->get_uh_id );
-                $url .= "?v=".$uh_fs->{'change_time'} if $uh_fs->{'change_time'};
+            ## If indiv userhead was selected and date is expired, set userhead to default
+            if ($selected_uh_id == $indiv_uh_id) {
+                $u->set_custom_usericon (undef);
             }
         }
     }

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