kareila: (Default)
kareila ([personal profile] kareila) wrote in [site community profile] changelog2009-09-25 05:35 pm

[dw-free] duplicated viewall code in cgi-bin/LJ/S2/*.pm

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

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

Cleanup of several lines of code into one equivalent line.

Patch by [personal profile] kareila.

Files modified:
  • cgi-bin/LJ/S2/DayPage.pm
  • cgi-bin/LJ/S2/MonthPage.pm
  • cgi-bin/LJ/User.pm
--------------------------------------------------------------------------------
diff -r 491eaf27c733 -r e513e5d66d7c cgi-bin/LJ/S2/DayPage.pm
--- a/cgi-bin/LJ/S2/DayPage.pm	Thu Sep 24 21:01:08 2009 -0500
+++ b/cgi-bin/LJ/S2/DayPage.pm	Fri Sep 25 12:34:59 2009 -0500
@@ -59,17 +59,7 @@ sub DayPage
         if ($remote->{'userid'} == $u->{'userid'} || $viewall) {
             $secwhere = "";   # see everything
         } elsif ( $remote->is_individual ) {
-
-            # if we're viewing a community, we intuit the security mask from the membership
-            my $gmask = 0;
-            if ( $u->is_community ) {
-                $gmask = 1
-                    if $remote->member_of( $u );
-
-            } else {
-                $gmask = $u->trustmask( $remote );
-            }
-
+            my $gmask = $u->is_community ? $remote->member_of( $u ) : $u->trustmask( $remote );
             $secwhere = "AND (security='public' OR (security='usemask' AND allowmask & $gmask))"
                 if $gmask;
         }
diff -r 491eaf27c733 -r e513e5d66d7c cgi-bin/LJ/S2/MonthPage.pm
--- a/cgi-bin/LJ/S2/MonthPage.pm	Thu Sep 24 21:01:08 2009 -0500
+++ b/cgi-bin/LJ/S2/MonthPage.pm	Fri Sep 25 12:34:59 2009 -0500
@@ -59,17 +59,7 @@ sub MonthPage
         if ($remote->{'userid'} == $u->{'userid'} || $viewall) {
             $secwhere = "";   # see everything
         } elsif ( $remote->is_individual ) {
-
-            # if we're viewing a community, we intuit the security mask from the membership
-            my $gmask = 0;
-            if ( $u->is_community ) {
-                $gmask = 1
-                    if $remote->member_of( $u );
-
-            } else {
-                $gmask = $u->trustmask( $remote );
-            }
-
+            my $gmask = $u->is_community ? $remote->member_of( $u ) : $u->trustmask( $remote );
             $secwhere = "AND (l.security='public' OR (l.security='usemask' AND l.allowmask & $gmask))"
                 if $gmask;
         }
diff -r 491eaf27c733 -r e513e5d66d7c cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Thu Sep 24 21:01:08 2009 -0500
+++ b/cgi-bin/LJ/User.pm	Fri Sep 25 12:34:59 2009 -0500
@@ -7654,17 +7654,7 @@ sub get_daycounts
             $secwhere = "";   # see everything
             $memkind = 'a'; # all
         } elsif ( $remote->is_individual ) {
-
-            # if we're viewing a community, we intuit the security mask from the membership
-            my $gmask = 0;
-            if ( $u->is_community ) {
-                $gmask = 1
-                    if $remote->member_of( $u );
-
-            } else {
-                $gmask = $u->trustmask( $remote );
-            }
-
+            my $gmask = $u->is_community ? $remote->member_of( $u ) : $u->trustmask( $remote );
             if ( $gmask ) {
                 $secwhere = "AND (security='public' OR (security='usemask' AND allowmask & $gmask))";
                 $memkind = 'g' . $gmask; # friends case: allowmask == gmask == 1
--------------------------------------------------------------------------------

Post a comment in response:

This account has disabled anonymous posting.
If you don't have an account you can create one now.
HTML doesn't work in the subject.
More info about formatting

If you are unable to use this captcha for any reason, please contact us by email at support@dreamwidth.org