[dw-free] update communitylib.pl to use user methods
[commit: http://hg.dwscoalition.org/dw-free/rev/5b6db07594f7]
http://bugs.dwscoalition.org/show_bug.cgi?id=2849
Take into account that postlevel may be empty (for open posting)
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=2849
Take into account that postlevel may be empty (for open posting)
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Community.pm
- t/console-community.t
-------------------------------------------------------------------------------- diff -r 3e1dc42af96f -r 5b6db07594f7 cgi-bin/LJ/Community.pm --- a/cgi-bin/LJ/Community.pm Wed Sep 08 17:19:47 2010 +0800 +++ b/cgi-bin/LJ/Community.pm Wed Sep 08 17:30:13 2010 +0800 @@ -15,7 +15,6 @@ package LJ::User; package LJ::User; use strict; -use warnings; use LJ::Event::CommunityInvite; use LJ::Event::CommunityJoinRequest; use LJ::Event::CommunityJoinApprove; @@ -305,7 +304,8 @@ sub join_community { $addpostacc = $canpost ? 1 : 0; } else { my $crow = $cu->get_community_row; - $addpostacc = $crow->{postlevel} eq 'members' ? 1 : 0; + $addpostacc = $crow->{postlevel} eq 'members' ? 1 : 0 + if defined $crow->{postlevel}; } } @@ -337,7 +337,7 @@ sub get_community_row { $dbr->selectrow_array('SELECT membership, postlevel FROM community WHERE userid=?', undef, $cu->{userid}); return if $dbr->err; - return unless $membership && $postlevel; + return unless $membership; # return result hashref my $row = { diff -r 3e1dc42af96f -r 5b6db07594f7 t/console-community.t --- a/t/console-community.t Wed Sep 08 17:19:47 2010 +0800 +++ b/t/console-community.t Wed Sep 08 17:30:13 2010 +0800 @@ -38,6 +38,7 @@ ok( $u2->member_of( $comm ), "User is cu ok( $u2->member_of( $comm ), "User is currently member of community." ); is($run->("community " . $comm->user . " remove " . $u2->user), "success: User " . $u2->user . " removed from " . $comm->user); +delete $LJ::REQ_CACHE_REL{$comm->userid."-".$u2->userid."-E"}; ok( ! $u2->member_of( $comm ), "User removed from community." ); # test case where user's removing themselves @@ -45,4 +46,5 @@ ok( $u->member_of( $comm2 ), "User is cu ok( $u->member_of( $comm2 ), "User is currently member of community." ); is($run->("community " . $comm2->user . " remove " . $u->user), "success: User " . $u->user . " removed from " . $comm2->user); +delete $LJ::REQ_CACHE_REL{$comm2->userid."-".$u->userid."-E"}; ok( ! $u->member_of( $comm2 ), "User removed self from community." ); --------------------------------------------------------------------------------