fu: Close-up of Fu, bringing a scoop of water to her mouth (Default)
fu ([personal profile] fu) wrote in [site community profile] changelog2010-11-16 12:33 pm

[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 [personal profile] sophie.

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};
--------------------------------------------------------------------------------
yvi: Kaylee half-smiling, looking very pretty (Default)

[personal profile] yvi 2010-11-16 12:46 pm (UTC)(link)
Great to see this getting picked up!
ninetydegrees: Art & Text: heart with aroace colors, "you are loved" (Default)

[personal profile] ninetydegrees 2010-11-16 03:35 pm (UTC)(link)
Yay! This is gonna be so useful.
turlough: large orange flowers in lush green grass ((mcr) snazzy dresser)

[personal profile] turlough 2010-11-16 09:30 pm (UTC)(link)
Very useful.
matgb: Artwork of 19th century upper class anarchist, text: MatGB (Default)

[personal profile] matgb 2010-11-17 10:54 pm (UTC)(link)
The LJ patch doesn't work for RSS feeds, would it be technically possible for us to get it to work here? It'd be useful to set up things like Twitterfeeds of my posts to a Comm.
kareila: (Default)

[personal profile] kareila 2010-11-17 11:40 pm (UTC)(link)
I don't see why not. Can you submit it to [site community profile] dw_suggestions?