Committer: nnikulochkina
LJSUP-13292: Allow anonymous commenting via XML-RPCU trunk/cgi-bin/LJ/Entry.pm U trunk/cgi-bin/ljprotocol.pl
Modified: trunk/cgi-bin/LJ/Entry.pm =================================================================== --- trunk/cgi-bin/LJ/Entry.pm 2012-08-14 20:42:27 UTC (rev 22643) +++ trunk/cgi-bin/LJ/Entry.pm 2012-08-15 06:52:39 UTC (rev 22644) @@ -1453,6 +1453,25 @@ return 0; } +sub remote_can_comment { + my ($self, $remote) = @_; + + return 0 unless $self->posting_comments_allowed; + + my $journalu = $self->journal; + + return 0 if LJ::is_banned($remote, $journalu); + + return 0 if $journalu->{'opt_whocanreply'} eq 'none'; + + if ($journalu->{'opt_whocanreply'} eq 'friends') { + return 0 unless $journalu->is_friend($remote); + } + + return 1; +} + + # mark/unmark entry in 'compressed' field to skip/include it in LJ::get_recent_items() call sub mark_suspended { my $self = shift; Modified: trunk/cgi-bin/ljprotocol.pl =================================================================== --- trunk/cgi-bin/ljprotocol.pl 2012-08-14 20:42:27 UTC (rev 22643) +++ trunk/cgi-bin/ljprotocol.pl 2012-08-15 06:52:39 UTC (rev 22644) @@ -4136,6 +4136,8 @@ $evt->{'reply_count'} = $replycount; + $evt->{'can_comment'} = $u ? $entry->remote_can_comment($u) : $entry->everyone_can_comment; + if ( $itemid == $sticky_id && $req->{'selecttype'} eq "lastn") { unshift @$events, $evt, }