fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-06-25 02:03 pm

[dw-free] replace ljmood.pl with DW::Mood.pm

[commit: http://hg.dwscoalition.org/dw-free/rev/c77c702ba49d]

http://bugs.dwscoalition.org/show_bug.cgi?id=2690

Create a function to look up the user's current moodthemeid.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/DW/Mood.pm
  • cgi-bin/LJ/S2.pm
  • cgi-bin/LJ/Widget/MoodThemeChooser.pm
  • cgi-bin/LJ/Widget/NavStripChooser.pm
  • htdocs/community/moderate.bml
--------------------------------------------------------------------------------
diff -r 49f12658bc9d -r c77c702ba49d cgi-bin/DW/Mood.pm
--- a/cgi-bin/DW/Mood.pm	Fri Jun 25 21:57:59 2010 +0800
+++ b/cgi-bin/DW/Mood.pm	Fri Jun 25 22:09:07 2010 +0800
@@ -343,6 +343,9 @@ sub public_themes {
 
 package LJ::User;
 
+# user method for accessing the currently selected moodtheme
+sub moodtheme { return $_[0]->{moodthemeid}; }
+
 # user method for expiring moodtheme cache
 # NOTE: any code that updates the moodthemes table needs to use this!
 sub delete_moodtheme_cache { $_[0]->memc_delete( 'moodthemes' ); }
diff -r 49f12658bc9d -r c77c702ba49d cgi-bin/LJ/S2.pm
--- a/cgi-bin/LJ/S2.pm	Fri Jun 25 21:57:59 2010 +0800
+++ b/cgi-bin/LJ/S2.pm	Fri Jun 25 22:09:07 2010 +0800
@@ -1864,7 +1864,9 @@ sub Entry
     }
 
     if (my $mid = $p->{'current_moodid'}) {
-        my $theme = defined $arg->{'moodthemeid'} ? $arg->{'moodthemeid'} : $u->{'moodthemeid'};
+        my $theme = $arg->{'moodthemeid'};
+        # if moodthemeid not given, look up the user's if we have it
+        $theme = $u->moodtheme if ! defined $theme && LJ::isu( $u );
         my %pic;
         my $mobj = DW::Mood->new( $theme );
         $e->{mood_icon} = Image( $pic{pic}, $pic{w}, $pic{h} )
diff -r 49f12658bc9d -r c77c702ba49d cgi-bin/LJ/Widget/MoodThemeChooser.pm
--- a/cgi-bin/LJ/Widget/MoodThemeChooser.pm	Fri Jun 25 21:57:59 2010 +0800
+++ b/cgi-bin/LJ/Widget/MoodThemeChooser.pm	Fri Jun 25 22:09:07 2010 +0800
@@ -33,7 +33,7 @@ sub render_body {
     my $getextra = $u->user ne $remote->user ? "?authas=" . $u->user : "";
     my $getsep = $getextra ? "&" : "?";
 
-    my $preview_moodthemeid = defined $opts{preview_moodthemeid} ? $opts{preview_moodthemeid} : $u->{moodthemeid};
+    my $preview_moodthemeid = defined $opts{preview_moodthemeid} ? $opts{preview_moodthemeid} : $u->moodtheme;
     my $forcemoodtheme = defined $opts{forcemoodtheme} ? $opts{forcemoodtheme} : $u->{opt_forcemoodtheme} eq 'Y';
 
     my $ret = "<fieldset><legend>" . $class->ml('widget.moodthemechooser.title') . "</legend>";
diff -r 49f12658bc9d -r c77c702ba49d cgi-bin/LJ/Widget/NavStripChooser.pm
--- a/cgi-bin/LJ/Widget/NavStripChooser.pm	Fri Jun 25 21:57:59 2010 +0800
+++ b/cgi-bin/LJ/Widget/NavStripChooser.pm	Fri Jun 25 22:09:07 2010 +0800
@@ -28,8 +28,6 @@ sub render_body {
 
     my $u = $class->get_effective_remote();
     die "Invalid user." unless LJ::isu($u);
-
-    my $preview_moodthemeid = defined $opts{preview_moodthemeid} ? $opts{preview_moodthemeid} : $u->{moodthemeid};
 
     my $ret = "<fieldset><legend>" . $class->ml('widget.navstripchooser.title') . "</legend>";
     $ret .= "</fieldset>" if $u->prop('stylesys') == 2;
diff -r 49f12658bc9d -r c77c702ba49d htdocs/community/moderate.bml
--- a/htdocs/community/moderate.bml	Fri Jun 25 21:57:59 2010 +0800
+++ b/htdocs/community/moderate.bml	Fri Jun 25 22:09:07 2010 +0800
@@ -451,7 +451,7 @@ body<=
             $current{'Mood'} = $props->{'current_mood'};
             LJ::CleanHTML::clean_subject(\$current{'Mood'});
             if ( my $mid = $props->{current_moodid} ) {
-                my $theme = DW::Mood->new( $up->{moodthemeid} );
+                my $theme = $up ? DW::Mood->new( $up->moodtheme ) : undef;
                 my %pic;
                 my $name = DW::Mood->mood_name( $mid );
                 if ( $theme && $theme->get_picture( $mid, \%pic ) ) {
--------------------------------------------------------------------------------