Committer: amyshkin
LJSUP-9796: Ability to view and create Scheduled and sticky Entries via XML-RPCU branches/delayed_entries/cgi-bin/ljprotocol.pl
Modified: branches/delayed_entries/cgi-bin/ljprotocol.pl =================================================================== --- branches/delayed_entries/cgi-bin/ljprotocol.pl 2011-09-19 07:01:04 UTC (rev 20069) +++ branches/delayed_entries/cgi-bin/ljprotocol.pl 2011-09-19 09:03:44 UTC (rev 20070) @@ -2950,6 +2950,8 @@ $ownerid = $req->{journalid}; $uowner = LJ::load_userid( $req->{journalid} ); } + + my $sticky_id = $uowner->prop("sticky_entries") || undef; my $dbr = LJ::get_db_reader(); my $sth; @@ -3069,6 +3071,10 @@ } $where .= "AND $rtime_what > $rtime_after "; $orderby = "ORDER BY $rtime_what"; + + unless ($skip) { + $where .= "OR jitemid=$sticky_id"; + } } elsif ($req->{'selecttype'} eq "one" && $req->{'itemid'} eq "-1") { @@ -3246,7 +3252,13 @@ $evt->{'poster'} = LJ::get_username($dbr, $jposterid) if $jposterid != $ownerid; $evt->{'url'} = LJ::item_link($uowner, $itemid, $anum); $evt->{'reply_count'} = $replycount; - push @$events, $evt; + + if ( $itemid == $sticky_id && $req->{'selecttype'} eq "lastn") { + unshift @$events, $evt, + } + else { + push @$events, $evt; + } } # load properties. Even if the caller doesn't want them, we need @@ -3284,6 +3296,10 @@ $value =~ s/\n/ /g; $evt->{'props'}->{$name} = $value; } + + if ( $itemid == $sticky_id ) { + $evt->{'props'}->{'sticky'} = 1; + } } }