[dw-free] All users can_manage themselves
[commit: http://hg.dwscoalition.org/dw-free/rev/c1529ebb1660]
http://bugs.dwscoalition.org/show_bug.cgi?id=679
Remove redundant equality checks. Some found from code-merge from LiveJournal.
Patch by
kareila.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=679
Remove redundant equality checks. Some found from code-merge from LiveJournal.
Patch by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/LJ/Entry.pm
- cgi-bin/LJ/S2/DayPage.pm
- cgi-bin/LJ/S2/EntryPage.pm
- cgi-bin/LJ/S2/FriendsPage.pm
- cgi-bin/LJ/S2/MonthPage.pm
- cgi-bin/talklib.pl
- htdocs/talkread.bml
-------------------------------------------------------------------------------- diff -r 7e819df12b80 -r c1529ebb1660 cgi-bin/LJ/Entry.pm --- a/cgi-bin/LJ/Entry.pm Mon May 11 17:15:01 2009 +0000 +++ b/cgi-bin/LJ/Entry.pm Mon May 11 17:20:25 2009 +0000 @@ -821,10 +821,7 @@ sub comments_manageable_by { return 0 unless $self->valid; return 0 unless $remote; my $u = $self->{u}; - return - $remote->{userid} == $u->{userid} || - $remote->{userid} == $self->posterid || - LJ::can_manage($remote, $u); + return $remote->{userid} == $self->posterid || LJ::can_manage($remote, $u); } # instance method: returns bool, if remote user can view this entry diff -r 7e819df12b80 -r c1529ebb1660 cgi-bin/LJ/S2/DayPage.pm --- a/cgi-bin/LJ/S2/DayPage.pm Mon May 11 17:15:01 2009 +0000 +++ b/cgi-bin/LJ/S2/DayPage.pm Mon May 11 17:20:25 2009 +0000 @@ -172,8 +172,7 @@ sub DayPage 'count' => $replycount, 'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0, 'enabled' => ($u->{'opt_showtalklinks'} eq "Y" && ! $logprops{$itemid}->{'opt_nocomments'}) ? 1 : 0, - 'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote && - ($remote->{'user'} eq $u->{'user'} || LJ::can_manage($remote, $u))) ? 1 : 0, + 'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote && LJ::can_manage($remote, $u)) ? 1 : 0, }); $comments->{show_postlink} = $comments->{enabled}; $comments->{show_readlink} = $comments->{enabled} && ($replycount || $comments->{screened}); diff -r 7e819df12b80 -r c1529ebb1660 cgi-bin/LJ/S2/EntryPage.pm --- a/cgi-bin/LJ/S2/EntryPage.pm Mon May 11 17:15:01 2009 +0000 +++ b/cgi-bin/LJ/S2/EntryPage.pm Mon May 11 17:20:25 2009 +0000 @@ -457,8 +457,7 @@ sub EntryPage_entry 'count' => $replycount, 'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0, 'enabled' => ($viewall || ($u->{'opt_showtalklinks'} eq "Y" && !$entry->prop("opt_nocomments"))) ? 1 : 0, - 'screened' => ($entry->prop("hasscreened") && $remote && - ($remote->{'user'} eq $u->{'user'} || LJ::can_manage($remote, $u))) ? 1 : 0, + 'screened' => ($entry->prop("hasscreened") && $remote && LJ::can_manage($remote, $u)) ? 1 : 0, }); $comments->{show_postlink} = $comments->{enabled} && $get->{mode} ne 'reply'; $comments->{show_readlink} = $comments->{enabled} && ($replycount || $comments->{screened}) && $get->{mode} eq 'reply'; diff -r 7e819df12b80 -r c1529ebb1660 cgi-bin/LJ/S2/FriendsPage.pm --- a/cgi-bin/LJ/S2/FriendsPage.pm Mon May 11 17:15:01 2009 +0000 +++ b/cgi-bin/LJ/S2/FriendsPage.pm Mon May 11 17:20:25 2009 +0000 @@ -285,8 +285,7 @@ sub FriendsPage 'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0, 'enabled' => ($friends{$friendid}->{'opt_showtalklinks'} eq "Y" && ! $logprops{$datakey}->{'opt_nocomments'}) ? 1 : 0, - 'screened' => ($logprops{$datakey}->{'hasscreened'} && $remote && - ($remote->{'user'} eq $fr->{'user'} || LJ::can_manage($remote, $fr))) ? 1 : 0, + 'screened' => ($logprops{$datakey}->{'hasscreened'} && $remote && LJ::can_manage($remote, $fr)) ? 1 : 0, }); $comments->{show_postlink} = $comments->{enabled}; $comments->{show_readlink} = $comments->{enabled} && ($replycount || $comments->{screened}); diff -r 7e819df12b80 -r c1529ebb1660 cgi-bin/LJ/S2/MonthPage.pm --- a/cgi-bin/LJ/S2/MonthPage.pm Mon May 11 17:15:01 2009 +0000 +++ b/cgi-bin/LJ/S2/MonthPage.pm Mon May 11 17:20:25 2009 +0000 @@ -149,8 +149,7 @@ sub MonthPage 'count' => $replycount, 'maxcomments' => ($replycount >= LJ::get_cap($u, 'maxcomments')) ? 1 : 0, 'enabled' => ($u->{'opt_showtalklinks'} eq "Y" && ! $logprops{$itemid}->{'opt_nocomments'}) ? 1 : 0, - 'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote && - ($remote->{'user'} eq $u->{'user'} || LJ::can_manage($remote, $u))) ? 1 : 0, + 'screened' => ($logprops{$itemid}->{'hasscreened'} && $remote && LJ::can_manage($remote, $u)) ? 1 : 0, }); my $userlite_poster = $userlite_journal; diff -r 7e819df12b80 -r c1529ebb1660 cgi-bin/talklib.pl --- a/cgi-bin/talklib.pl Mon May 11 17:15:01 2009 +0000 +++ b/cgi-bin/talklib.pl Mon May 11 17:20:25 2009 +0000 @@ -340,8 +340,7 @@ sub can_screen { sub can_screen { my ($remote, $u, $up, $userpost) = @_; return 0 unless $remote; - return 1 if $remote->{'user'} eq $u->{'user'} || - $remote->{'user'} eq (ref $up ? $up->{'user'} : $up) || + return 1 if $remote->{'user'} eq (ref $up ? $up->{'user'} : $up) || LJ::can_manage($remote, $u); return 0; } @@ -978,8 +977,7 @@ sub load_comments my $should_show = $post->{'state'} eq 'D' ? 0 : 1; unless ($viewall) { $should_show = 0 if - $post->{'state'} eq "S" && ! ($remote && ($remote->{'userid'} == $u->{'userid'} || - $remote->{'userid'} == $uposterid || + $post->{'state'} eq "S" && ! ($remote && ($remote->{'userid'} == $uposterid || $remote->{'userid'} == $post->{'posterid'} || LJ::can_manage($remote, $u) )); } diff -r 7e819df12b80 -r c1529ebb1660 htdocs/talkread.bml --- a/htdocs/talkread.bml Mon May 11 17:15:01 2009 +0000 +++ b/htdocs/talkread.bml Mon May 11 17:20:25 2009 +0000 @@ -219,10 +219,7 @@ body<= )); } - my $showmultiform = $remote && - ($remote->{'user'} eq $u->{'user'} || - $remote->{'user'} eq $up->{'user'} || - LJ::can_manage($remote, $u)); + my $showmultiform = $remote && ( $remote->{'user'} eq $up->{'user'} || LJ::can_manage($remote, $u) ); my $multiform_selects = 0; # are there select boxes? don't show form if not. my $event = $item->{'event'}; --------------------------------------------------------------------------------