afuna: Cat under a blanket. Text: "Cats are just little people with Fur and Fangs" (Default)
afuna ([personal profile] afuna) wrote in [site community profile] changelog2009-06-21 03:27 am

[dw-free] Closed communities shouldn't have join option on contextual hover popup and navstrip

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

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

Don't show join option for closed communities.

Patch by [personal profile] yvi.

Files modified:
  • cgi-bin/weblib.pl
  • htdocs/js/contextualhover.js
  • htdocs/tools/endpoints/ctxpopup.bml
--------------------------------------------------------------------------------
diff -r 20a8b4b428f4 -r f1c730aaded6 cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl	Sat Jun 20 15:15:07 2009 +0000
+++ b/cgi-bin/weblib.pl	Sun Jun 21 03:25:39 2009 +0000
@@ -2544,7 +2544,8 @@ sub control_strip
             $links{'remove_friend'} = "<a href='$LJ::SITEROOT/manage/circle/add.bml?user=$journal->{user}'>$BML::ML{'web.controlstrip.links.removefeed'}</a>";
         }
         if ($journal->is_community) {
-            $links{'join_community'}   = "<a href='$LJ::SITEROOT/community/join.bml?comm=$journal->{user}'>$BML::ML{'web.controlstrip.links.joincomm'}</a>";
+            $links{'join_community'}   = "<a href='$LJ::SITEROOT/community/join.bml?comm=$journal->{user}'>$BML::ML{'web.controlstrip.links.joincomm'}</a>"
+                unless $journal->is_closed_membership;
             $links{'leave_community'}  = "<a href='$LJ::SITEROOT/community/leave.bml?comm=$journal->{user}'>$BML::ML{'web.controlstrip.links.leavecomm'}</a>";
             $links{'watch_community'}  = "<a href='$LJ::SITEROOT/manage/circle/add.bml?user=$journal->{user}&action=subscribe'>$BML::ML{'web.controlstrip.links.watchcomm'}</a>";
             $links{'unwatch_community'}   = "<a href='$LJ::SITEROOT/community/leave.bml?comm=$journal->{user}'>$BML::ML{'web.controlstrip.links.removecomm'}</a>";
@@ -2740,6 +2741,7 @@ sub control_strip
             my $watching = $remote->watches( $journal );
             my $memberof = $remote->member_of( $journal );
             my $haspostingaccess = LJ::check_rel($journal, $remote, 'P');
+            my $isclosedcommunity = $journal->is_closed_membership;
             if (LJ::can_manage_other($remote, $journal)) {
                 $ret .= "$statustext{maintainer}<br />";
                 if ($haspostingaccess) {
@@ -2758,7 +2760,13 @@ sub control_strip
                 if ($haspostingaccess) {
                     $ret .= "$links{post_to_community}&nbsp;&nbsp; ";
                 }
-                $ret .= "$links{join_community}&nbsp;&nbsp; " unless $remote->is_identity;
+                unless ($remote->is_identity) {
+                    if ($isclosedcommunity) {
+                        $ret .= "This is a closed community&nbsp;&nbsp; ";
+                    } else {
+                        $ret .= "$links{join_community}&nbsp;&nbsp; ";
+                    }
+                }
                 $ret .= $links{unwatch_community};
                 $ret .= "&nbsp;&nbsp;" . $links{track_community};
             } elsif ($memberof) {
@@ -2773,7 +2781,13 @@ sub control_strip
                 if ($haspostingaccess) {
                     $ret .= "$links{post_to_community}&nbsp;&nbsp; ";
                 }
-                $ret .= "$links{join_community}&nbsp;&nbsp; " unless $remote->is_identity;
+                unless ($remote->is_identity) {
+                    if ($isclosedcommunity) {
+                        $ret .= "This is a closed community&nbsp;&nbsp; ";
+                    } else {
+                        $ret .= "$links{join_community}&nbsp;&nbsp; ";
+                    }
+                }
                 $ret .= $links{watch_community};
                 $ret .= "&nbsp;&nbsp;" . $links{track_community};
             }
diff -r 20a8b4b428f4 -r f1c730aaded6 htdocs/js/contextualhover.js
--- a/htdocs/js/contextualhover.js	Sat Jun 20 15:15:07 2009 +0000
+++ b/htdocs/js/contextualhover.js	Sun Jun 21 03:25:39 2009 +0000
@@ -323,26 +323,31 @@ ContextualPopup.renderPopup = function (
         // member of community
         if (data.is_logged_in && data.is_comm) {
             var membership      = document.createElement("span");
-            var membershipLink  = document.createElement("a");
 
-            var membership_action = data.is_member ? "leave" : "join";
+            if (!data.is_closed_membership || data.is_member) {
+                var membershipLink  = document.createElement("a");
 
-            if (data.is_member) {
-                membershipLink.href = data.url_leavecomm;
-                membershipLink.innerHTML = "Leave";
+                var membership_action = data.is_member ? "leave" : "join";
+
+                if (data.is_member) {
+                    membershipLink.href = data.url_leavecomm;
+                    membershipLink.innerHTML = "Leave";
+                } else {
+                    membershipLink.href = data.url_joincomm;
+                    membershipLink.innerHTML = "Join community";
+                }
+
+                if (!ContextualPopup.disableAJAX) {
+                    DOM.addEventListener(membershipLink, "click", function (e) {
+                        Event.prep(e);
+                        Event.stop(e);
+                        return ContextualPopup.changeRelation(data, ctxPopupId, membership_action, e); });
+                }
+
+                membership.appendChild(membershipLink);
             } else {
-                membershipLink.href = data.url_joincomm;
-                membershipLink.innerHTML = "Join community";
+                membership.innerHTML = "Community closed";
             }
-
-            if (!ContextualPopup.disableAJAX) {
-                DOM.addEventListener(membershipLink, "click", function (e) {
-                    Event.prep(e);
-                    Event.stop(e);
-                    return ContextualPopup.changeRelation(data, ctxPopupId, membership_action, e); });
-            }
-
-            membership.appendChild(membershipLink);
             content.appendChild(membership);
         }
 
diff -r 20a8b4b428f4 -r f1c730aaded6 htdocs/tools/endpoints/ctxpopup.bml
--- a/htdocs/tools/endpoints/ctxpopup.bml	Sat Jun 20 15:15:07 2009 +0000
+++ b/htdocs/tools/endpoints/ctxpopup.bml	Sun Jun 21 03:25:39 2009 +0000
@@ -103,6 +103,7 @@
         $ret{url_joincomm}   = "$LJ::SITEROOT/community/join.bml?comm=" . $u->{user};
         $ret{url_leavecomm}  = "$LJ::SITEROOT/community/leave.bml?comm=" . $u->{user};
         $ret{is_member} = $remote->member_of( $u ) if $remote;
+        $ret{is_closed_membership} = $u->is_closed_membership;
 
         push @actions, 'join', 'leave';
     }
--------------------------------------------------------------------------------

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