Refactoring: Move some community-related functions out of 
cgi-bin/LJ/User.pm to cgi-bin/LJ/Community.pm (keep same LJ::User package)

        Patch by kareila. 

diffs (105 lines):

diff -r 7c0d6bf01040 -r 45c7c3d47bed cgi-bin/LJ/Community.pm
--- a/cgi-bin/LJ/Community.pm   Wed Sep 08 16:33:53 2010 +0800
+++ b/cgi-bin/LJ/Community.pm   Wed Sep 08 17:06:41 2010 +0800
@@ -279,7 +279,6 @@ sub leave_community {
     return 1;
 }
 
-# name: LJ::join_community
 # des: Makes a user join a community.  Takes care of all 
[special[reluserdefs]] and watch stuff.
 # args: u joining, u of comm, watch?, noauto?
 # des-watch: 1 to add this comm to user's watch list, else not
@@ -617,4 +616,38 @@ sub get_pending_members_count {
     return $pending_count;
 }
 
+# returns the membership level of a community
+sub membership_level {
+    my ( $u ) = @_;
+
+    return undef unless $u->is_community;
+
+    my ( $membership_level ) = $u->get_comm_settings;
+    return $membership_level || undef;
+}
+
+# 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' );                     }
+sub has_open_posting        { $_[0]->prop( 'nonmember_posting' ) ? 1 : 0;     }
+
+# returns an array of maintainer userids
+sub maintainer_userids {
+    my ( $u ) = @_;
+
+    return () unless $u->is_community;
+    return @{LJ::load_rel_user_cache( $u->id, 'A' )};
+}
+
+# returns an array of moderator userids
+sub moderator_userids {
+    my ( $u ) = @_;
+
+    return () unless $u->is_community && $u->has_moderated_posting;
+    return @{LJ::load_rel_user_cache( $u->id, 'M' )};
+}
+
+
 1;
diff -r 7c0d6bf01040 -r 45c7c3d47bed cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm        Wed Sep 08 16:33:53 2010 +0800
+++ b/cgi-bin/LJ/User.pm        Wed Sep 08 17:06:41 2010 +0800
@@ -43,6 +43,7 @@ use DW::User::ContentFilters;
 use DW::User::ContentFilters;
 use DW::User::Edges;
 
+use LJ::Community;
 use LJ::Subscription;
 use LJ::Identity;
 use LJ::Auth;
@@ -3973,43 +3974,6 @@ sub can_post_to {
 }
 
 
-# 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' );                     }
-sub has_open_posting        { $_[0]->prop( 'nonmember_posting' ) ? 1 : 0;     }
-
-
-# returns an array of maintainer userids
-sub maintainer_userids {
-    my $u = shift;
-
-    return () unless $u->is_community;
-    return @{LJ::load_rel_user_cache( $u->id, 'A' )};
-}
-
-
-# returns the membership level of a community
-sub membership_level {
-    my $u = shift;
-
-    return undef unless $u->is_community;
-
-    my ( $membership_level ) = $u->get_comm_settings;
-    return $membership_level || undef;
-}
-
-
-# returns an array of moderator userids
-sub moderator_userids {
-    my $u = shift;
-
-    return () unless $u->is_community && $u->prop( 'moderated' );
-    return @{LJ::load_rel_user_cache( $u->id, 'M' )};
-}
-
-
 # What journals can this user post to?
 sub posting_access_list {
     my $u = shift;
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog

Reply via email to