mark: A photo of Mark kneeling on top of the Taal Volcano in the Philippines. It was a long hike. (Default)
Mark Smith ([staff profile] mark) wrote in [site community profile] changelog2010-04-20 09:19 am

[dw-free] Queue displaying even if community not moderated and queue is empty

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

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

Only show queue length prompt when the community is moderated or has items
in the queue.

Patch by [personal profile] yvi.

Files modified:
  • cgi-bin/LJ/User.pm
  • htdocs/community/manage.bml
--------------------------------------------------------------------------------
diff -r dceb5bb4ce05 -r ff5eb061b052 cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm	Tue Apr 20 02:22:07 2010 -0700
+++ b/cgi-bin/LJ/User.pm	Tue Apr 20 09:18:59 2010 +0000
@@ -3571,25 +3571,11 @@ sub can_post_to {
 }
 
 
-sub is_closed_membership {
-    my $u = shift;
-
-    return $u->membership_level eq 'closed' ? 1 : 0;
-}
-
-
-sub is_moderated_membership {
-    my $u = shift;
-
-    return $u->membership_level eq 'moderated' ? 1 : 0;
-}
-
-
-sub is_open_membership {
-    my $u = shift;
-
-    return $u->membership_level eq 'open' ? 1 : 0;
-}
+# helper methods for checking some values about communities
+sub is_closed_membership    { $_[0]->membership_level eq 'closed' ? 1 : 0;    }
+sub is_moderated_membership { $_[0]->membership_level eq 'moderated' ? 1 : 0; }
+sub is_open_membership      { $_[0]->membership_level eq 'open' ? 1 : 0;      }
+sub has_moderated_posting   { $_[0]->prop( 'moderated' );                     }
 
 
 # returns an array of maintainer userids
diff -r dceb5bb4ce05 -r ff5eb061b052 htdocs/community/manage.bml
--- a/htdocs/community/manage.bml	Tue Apr 20 02:22:07 2010 -0700
+++ b/htdocs/community/manage.bml	Tue Apr 20 09:18:59 2010 +0000
@@ -136,7 +136,12 @@ body<=
            $ret .= "</td><td align='center'>";
            if ($mods{$id}) {
                my $num = $modcount{$id} || "0"; # relying on this to be <b>-wrapped
-               $ret .= BML::ml('.commlist.moderation.num2', {'aopts' => "href='$LJ::SITEROOT/community/moderate?authas=$user'", 'num' => $num});
+
+               # only show the items in queue if the community has moderated posting (number can be 0 then) or there are
+               # posts in the queue (for example after a switch from moderated posting to non-moderated posting)
+               my $comm = LJ::load_userid( $id );
+               $ret .= BML::ml('.commlist.moderation.num2', {'aopts' => "href='$LJ::SITEROOT/community/moderate?authas=$user'", 'num' => $num})
+                   if $comm->has_moderated_posting || $num;
            } else {
                $ret .= "&nbsp";
            }
--------------------------------------------------------------------------------