Refactor code that checks for posting access.
Patch by kareila.
diffs (103 lines):
diff -r ecb4f977c4a1 -r 030adc21b5aa cgi-bin/LJ/User.pm
--- a/cgi-bin/LJ/User.pm Mon Jun 28 18:07:33 2010 +0800
+++ b/cgi-bin/LJ/User.pm Mon Jun 28 18:19:02 2010 +0800
@@ -3726,7 +3726,7 @@ sub can_manage_other {
# can $u post to $targetu?
sub can_post_to {
- my ( $u, $targetu, %opts ) = @_;
+ my ( $u, $targetu ) = @_;
croak "Invalid users passed to LJ::User->can_post_to."
unless LJ::isu( $u ) && LJ::isu( $targetu );
@@ -3740,7 +3740,7 @@ sub can_post_to {
return 1 if LJ::check_rel( $targetu, $u, 'P' );
# let's check if this community is allowing post access to non-members
- if ( $targetu->prop( 'nonmember_posting' ) ) {
+ if ( $targetu->has_open_posting ) {
my ( $ml, $pl ) = LJ::get_comm_settings( $targetu );
return 1 if $pl eq 'members';
}
diff -r ecb4f977c4a1 -r 030adc21b5aa cgi-bin/weblib.pl
--- a/cgi-bin/weblib.pl Mon Jun 28 18:07:33 2010 +0800
+++ b/cgi-bin/weblib.pl Mon Jun 28 18:19:02 2010 +0800
@@ -2815,13 +2815,13 @@ sub control_strip
} elsif ($journal->is_community) {
my $watching = $remote->watches( $journal );
my $memberof = $remote->member_of( $journal );
- my $haspostingaccess = LJ::check_rel($journal, $remote, 'P');
+ my $haspostingaccess = $remote->can_post_to( $journal );
my $isclosedcommunity = $journal->is_closed_membership;
+
if ( $remote->can_manage_other( $journal ) ) {
$ret .= "$statustext{maintainer}<br />";
- if ( $haspostingaccess || $journal->has_open_posting ) {
- $ret .= "$links{post_to_community} " unless
$remote->is_identity;
- }
+ $ret .= "$links{post_to_community} "
+ if $haspostingaccess;
if ( $journal->prop( 'moderated' ) ) {
$ret .= "$links{queue} [" . LJ::get_mod_queue_count(
$journal ) . "] ";
@@ -2830,34 +2830,34 @@ sub control_strip
}
$ret .=
"$links{edit_community_invites} $links{edit_community_members}";
+
} elsif ($watching && $memberof) {
$ret .= "$statustext{memberwatcher}<br />";
- if ($haspostingaccess) {
- $ret .= "$links{post_to_community} ";
- }
+ $ret .= "$links{post_to_community} "
+ if $haspostingaccess;
$ret .= $links{leave_community};
$ret .= " " . $links{track_community};
+
} elsif ($watching) {
$ret .= "$statustext{watcher}<br />";
- if ($haspostingaccess) {
- $ret .= "$links{post_to_community} ";
- }
+ $ret .= "$links{post_to_community} "
+ if $haspostingaccess;
$ret .= $isclosedcommunity ? "This is a closed
community " :
"$links{join_community} ";
$ret .= $links{unwatch_community};
$ret .= " " . $links{track_community};
+
} elsif ($memberof) {
$ret .= "$statustext{member}<br />";
- if ($haspostingaccess) {
- $ret .= "$links{post_to_community} ";
- }
+ $ret .= "$links{post_to_community} "
+ if $haspostingaccess;
$ret .= "$links{watch_community}
$links{'leave_community'}";
$ret .= " " . $links{track_community};
+
} else {
$ret .= "$statustext{community}<br />";
- if ( $haspostingaccess || $journal->has_open_posting ) {
- $ret .= "$links{post_to_community} ";
- }
+ $ret .= "$links{post_to_community} "
+ if $haspostingaccess;
$ret .= $isclosedcommunity ? "This is a closed
community " :
"$links{join_community} ";
$ret .= $links{watch_community};
diff -r ecb4f977c4a1 -r 030adc21b5aa htdocs/poll/create.bml
--- a/htdocs/poll/create.bml Mon Jun 28 18:07:33 2010 +0800
+++ b/htdocs/poll/create.bml Mon Jun 28 18:19:02 2010 +0800
@@ -89,9 +89,7 @@ _c?>
# If remote can't make polls, make sure they maintain the authas journal
if ($remote_can_make_polls) {
my $authas_u = LJ::load_user($authas);
- if ($authas_u and ( $authas_u->equals( $remote ) or
LJ::check_rel($authas_u, $remote, 'P'))) {
- $u = $authas_u;
- }
+ $u = $authas_u if $authas_u and $remote->can_post_to( $authas_u );
} else {
$u = LJ::get_authas_user($authas);
}
_______________________________________________
dw-changelog mailing list
[email protected]
http://lists.dwscoalition.org/mailman/listinfo/dw-changelog