[dw-free] Add better community logic to /manage/circle/edit
[commit: http://hg.dwscoalition.org/dw-free/rev/fe8108115d6a]
http://bugs.dwscoalition.org/show_bug.cgi?id=1499
Add a checkbox so you can join / leave a community from manage/circle/edit.
If moderated, then you get a link to apply for membership.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=1499
Add a checkbox so you can join / leave a community from manage/circle/edit.
If moderated, then you get a link to apply for membership.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/User/Rename.pm
- cgi-bin/LJ/Community.pm
- htdocs/community/leave.bml
- htdocs/community/settings.bml
- htdocs/manage/circle/edit.bml
- htdocs/manage/circle/edit.bml.text
- htdocs/tools/endpoints/changerelation.bml
-------------------------------------------------------------------------------- diff -r b90bfe667689 -r fe8108115d6a cgi-bin/DW/User/Rename.pm --- a/cgi-bin/DW/User/Rename.pm Tue Aug 09 10:47:36 2011 +0800 +++ b/cgi-bin/DW/User/Rename.pm Tue Aug 09 11:09:05 2011 +0800 @@ -593,7 +593,7 @@ my @ids = $self->member_of_userids; my $memberships = LJ::load_userids( @ids ) || {}; foreach ( values %$memberships ) { - LJ::leave_community( $self, $_, 0 ); + $self->leave_community( $_ ); } } diff -r b90bfe667689 -r fe8108115d6a cgi-bin/LJ/Community.pm --- a/cgi-bin/LJ/Community.pm Tue Aug 09 10:47:36 2011 +0800 +++ b/cgi-bin/LJ/Community.pm Tue Aug 09 11:09:05 2011 +0800 @@ -273,6 +273,10 @@ return LJ::error( 'comm_not_found' ) unless LJ::isu( $u ) && $cu; return LJ::error( 'comm_not_comm' ) unless $cu->is_community; + # log to userlog if remote is a maintainer + $cu->log_event( 'maintainer_remove', { actiontarget => $u->id, remote => $u } ) + if $u->can_manage( $cu ); + # remove community membership return undef unless $u->remove_edge( $cu, member => {} ); @@ -635,7 +639,7 @@ return undef unless $u->is_community; my ( $membership_level ) = $u->get_comm_settings; - return $membership_level || undef; + return $membership_level || ''; } # helper methods for checking some values about communities diff -r b90bfe667689 -r fe8108115d6a htdocs/community/leave.bml --- a/htdocs/community/leave.bml Tue Aug 09 10:47:36 2011 +0800 +++ b/htdocs/community/leave.bml Tue Aug 09 11:09:05 2011 +0800 @@ -53,10 +53,6 @@ return $error->( $error_msg ) unless $remote->can_leave( $cu, errref => \$error_msg ); - # log to userlog if remote is a maintainer - $cu->log_event( 'maintainer_remove', { actiontarget => $remote->id, remote => $remote } ) - if $remote->can_manage( $cu ); - # remove user's membership to community if ($watching && !$memberof) { $remote->remove_edge( $cu, watch => {} ); diff -r b90bfe667689 -r fe8108115d6a htdocs/community/settings.bml --- a/htdocs/community/settings.bml Tue Aug 09 10:47:36 2011 +0800 +++ b/htdocs/community/settings.bml Tue Aug 09 11:09:05 2011 +0800 @@ -167,7 +167,7 @@ if ( LJ::is_enabled( 'adult_content' ) ) { my $adult_content = $POST{'adult_content'}; - $adult_content eq "none" + $adult_content = "none" unless $adult_content eq "explicit" || $adult_content eq "concepts"; $cu->set_prop('adult_content', $adult_content); } diff -r b90bfe667689 -r fe8108115d6a htdocs/manage/circle/edit.bml --- a/htdocs/manage/circle/edit.bml Tue Aug 09 10:47:36 2011 +0800 +++ b/htdocs/manage/circle/edit.bml Tue Aug 09 11:09:05 2011 +0800 @@ -188,20 +188,44 @@ $iscontent = 1; } } elsif ($type eq "comms") { + my $jointext = $ML{'.circle.member'}; + my $joinvals = { + name => "editfriend_edit_${uid}_join", + id => "editfriend_edit_${uid}_join", + value => 1, + }; + # check membership if ( $is_member_of_userid{$uid} ) { - $ret .= LJ::img( 'circle_yes', '' ); - $ret .= $ML{'.circle.member.y'}; + $jointext = $ML{'.circle.maintainer'} + if $u->can_manage( $other_u ); + $joinvals->{selected} = 1; + $joinvals->{disabled} = + $u->can_leave( $other_u ) ? 0 : 1; } else { - $ret .= LJ::img( 'circle_no', '' ); - $ret .= $ML{'.circle.member.n'}; + my $status = $other_u->membership_level; + $jointext = $status ? $ML{".circle.join.$status"} : $ML{'.circle.none'}; + if ( $status eq 'moderated' ) { + # print link to join page + my $href = "$LJ::SITEROOT/community/join?comm=" . $other_u->user; + $jointext .= " " . + LJ::Lang::ml( '.circle.join.apply', { aopts => "href='$href'" } ); + } + $joinvals->{selected} = 0; + $joinvals->{disabled} = + $u->can_join( $other_u ) ? 0 : 1; } + + $ret .= LJ::html_check( $joinvals ); + $ret .= " <label for='editfriend_edit_${uid}_join'>"; + $ret .= "$jointext</label>"; + $iscontent = 1; } $ret .= $ML{'.circle.na'} unless $iscontent; - $ret .= "</td></tr>"; + $ret .= "</td></tr>\n"; } unless ( scalar @$uids ) { @@ -419,6 +443,19 @@ nonotify => $watched_nonotify ? 0 : 1, } ); } + + if ( $other_u->is_community ) { + my $wants_member = $POST{"editfriend_edit_${uid}_join"}; + my $is_member = $u->member_of( $other_u ); + + if ( $wants_member && ! $is_member ) { + $u->join_community( $other_u ) + if $u->can_join( $other_u ); + } elsif ( $is_member && ! $wants_member ) { + $u->leave_community( $other_u ) + if $u->can_leave( $other_u ); + } + } } } diff -r b90bfe667689 -r fe8108115d6a htdocs/manage/circle/edit.bml.text --- a/htdocs/manage/circle/edit.bml.text Tue Aug 09 10:47:36 2011 +0800 +++ b/htdocs/manage/circle/edit.bml.text Tue Aug 09 11:09:05 2011 +0800 @@ -33,6 +33,16 @@ .circle.intro.nonpeople=These are the communities and feeds in your Circle. You can use the checkboxes to unsubscribe from these accounts. +.circle.join.apply=<a [[aopts]]>Apply to join?</a> + +.circle.join.closed=(Closed) + +.circle.join.moderated=(Moderated) + +.circle.join.open=(Open) + +.circle.maintainer=Maintainer + .circle.member=Member .circle.member.n=Not a member diff -r b90bfe667689 -r fe8108115d6a htdocs/tools/endpoints/changerelation.bml --- a/htdocs/tools/endpoints/changerelation.bml Tue Aug 09 10:47:36 2011 +0800 +++ b/htdocs/tools/endpoints/changerelation.bml Tue Aug 09 11:09:05 2011 +0800 @@ -89,10 +89,6 @@ return $err->( $error ) unless $remote->can_leave( $targetu, errref => \$error ); - # log to userlog if remote is a maintainer - $targetu->log_event( 'maintainer_remove', { actiontarget => $remote->id, remote => $remote } ) - if $remote->can_manage( $targetu ); - $success = $remote->leave_community( $targetu ); } elsif ( $action eq 'setBan' ) { my $list_of_banned = LJ::load_rel_user($remote, 'B') || [ ]; --------------------------------------------------------------------------------