[dw-free] Add "poster" support to core2
[commit: http://hg.dwscoalition.org/dw-free/rev/d00378df389a]
http://bugs.dwscoalition.org/show_bug.cgi?id=707
Add a ?poster= argument which can be used in communities to pull up entries
per-user.
Patch from LiveJournal. Packaged for Dreamwidth by
sophie.
Files modified:
http://bugs.dwscoalition.org/show_bug.cgi?id=707
Add a ?poster= argument which can be used in communities to pull up entries
per-user.
Patch from LiveJournal. Packaged for Dreamwidth by
![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Files modified:
- cgi-bin/DW/Logic/LogItems.pm
- cgi-bin/LJ/S2/RecentPage.pm
-------------------------------------------------------------------------------- diff -r 40b50d31b671 -r d00378df389a cgi-bin/DW/Logic/LogItems.pm --- a/cgi-bin/DW/Logic/LogItems.pm Tue Nov 16 18:52:05 2010 +0800 +++ b/cgi-bin/DW/Logic/LogItems.pm Tue Nov 16 19:15:30 2010 +0800 @@ -345,6 +345,7 @@ sub watch_items # -- viewall: if set, no security is used. # -- dateformat: if "S2", uses S2's 'alldatepart' format. # -- itemids: optional arrayref onto which itemids should be pushed +# -- posterid: optional, return (community) posts made by this poster only # returns: array of hashrefs containing keys: # -- itemid (the jitemid) # -- posterid @@ -506,13 +507,20 @@ sub recent_items $sql_select = "AND $sort_key <= $notafter"; } + my $posterwhere; + if ( $args{posterid} && $args{posterid} =~ /^(\d+)$/ ) { + $posterwhere = " AND posterid=$1"; + } else { + $posterwhere = ""; + } + $sql = qq{ SELECT jitemid AS 'itemid', posterid, security, $extra_sql DATE_FORMAT(eventtime, "$dateformat") AS 'alldatepart', anum, DATE_FORMAT(logtime, "$dateformat") AS 'system_alldatepart', allowmask, eventtime, logtime FROM log2 USE INDEX ($sort_key) - WHERE journalid=$userid $sql_select $secwhere $jitemidwhere $securitywhere + WHERE journalid=$userid $sql_select $secwhere $jitemidwhere $securitywhere $posterwhere ORDER BY journalid, $sort_key $sql_limit }; diff -r 40b50d31b671 -r d00378df389a cgi-bin/LJ/S2/RecentPage.pm --- a/cgi-bin/LJ/S2/RecentPage.pm Tue Nov 16 18:52:05 2010 +0800 +++ b/cgi-bin/LJ/S2/RecentPage.pm Tue Nov 16 19:15:30 2010 +0800 @@ -120,6 +120,11 @@ sub RecentPage $remote->view_priv_check( $u, $get->{viewall}, 'lastn' ); } + my $posteru_filter; + if ( defined( $get->{poster} ) ) { + $posteru_filter = LJ::load_user( $get->{poster} ); + } + ## load the itemids my @itemids; my $err; @@ -136,6 +141,7 @@ sub RecentPage dateformat => 'S2', order => ( $u->is_community || $u->is_syndicated ) ? 'logtime' : '', err => \$err, + posterid => $posteru_filter ? $posteru_filter->id : undef, ); my $is_prev_exist = scalar @items - $itemshow > 0 ? 1 : 0; @@ -230,7 +236,8 @@ sub RecentPage style => $mine || "", s2id => LJ::eurl( $get->{s2id} ) || "", tag => LJ::eurl( $get->{tag} ) || "", - security => LJ::eurl( $get->{security} ) || "" } ); + security => LJ::eurl( $get->{security} ) || "", + poster => $posteru_filter ? $posteru_filter->user : "" } ); $nav->{'forward_count'} = $itemshow; $p->{head_content} .= qq{<link rel="next" href="$nav->{forward_url}" />\n} } @@ -251,7 +258,8 @@ sub RecentPage style => $mine || "", s2id => LJ::eurl( $get->{s2id} ) || "", tag => LJ::eurl( $get->{tag} ) || "", - security => LJ::eurl( $get->{security} ) || "" } ); + security => LJ::eurl( $get->{security} ) || "", + poster => $posteru_filter ? $posteru_filter->user : "" } ); $nav->{'backward_skip'} = $newskip; } $p->{head_content} .= qq{<link rel="prev" href="$nav->{backward_url}" />\n}; --------------------------------------------------------------------------------
no subject