Igor Gariev (gariev) wrote in changelog,
Igor Gariev
gariev
changelog

[livejournal] r17457: LJSUP-6864: Sort by poster

Committer: gariev
LJSUP-6864: Sort by poster

U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/ljlib.pl
U   trunk/cgi-bin/ljviews.pl
Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2010-09-27 14:14:23 UTC (rev 17456)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2010-09-28 06:46:19 UTC (rev 17457)
@@ -80,6 +80,11 @@
         $viewsome = $viewall || LJ::check_priv($remote, 'canview', 'suspended');
     }
 
+    my $posteru_filter;
+    if ($get->{'poster'}) {
+        $posteru_filter = LJ::load_user($get->{'poster'});
+    }
+    
     ## load the itemids
     my @itemids;
     my $err;
@@ -99,6 +104,7 @@
         'order' => ($u->{'journaltype'} eq "C" || $u->{'journaltype'} eq "Y")  # community or syndicated
             ? "logtime" : "",
         'err' => \$err,
+        ($posteru_filter) ?  ('posterid'  => $posteru_filter->{'userid'}) : (),
     });
 
     my $is_prev_exist = scalar @items - $itemshow > 0 ? 1 : 0;
@@ -271,10 +277,13 @@
         my $newskip = $skip - $itemshow;
         $newskip = 0 if $newskip <= 0;
         $nav->{'forward_skip'} = $newskip;
-        $nav->{'forward_url'} = LJ::make_link("$p->{base_url}/", { skip     => ($newskip                   || ""),
-                                                                   tag      => (LJ::eurl($get->{tag})      || ""),
-                                                                   security => (LJ::eurl($get->{security}) || ""),
-                                                                   mode     => (LJ::eurl($get->{mode})     || ""), });
+        $nav->{'forward_url'} = LJ::make_link("$p->{base_url}/", { 
+            skip     => ($newskip                   || ""),
+            tag      => (LJ::eurl($get->{tag})      || ""),
+            security => (LJ::eurl($get->{security}) || ""),
+            mode     => (LJ::eurl($get->{mode})     || ""), 
+            poster   => ($posteru_filter) ? $posteru_filter->{user} : "", 
+        });
         $nav->{'forward_count'} = $itemshow;
     }
 
@@ -289,10 +298,13 @@
             $nav->{'backward_url'} = "$p->{'base_url'}/$date_slashes";
         } elsif ($is_prev_exist) {
             my $newskip = $skip + $itemshow;
-            $nav->{'backward_url'} = LJ::make_link("$p->{'base_url'}/", { skip     => ($newskip                   || ""),
-                                                                          tag      => (LJ::eurl($get->{tag})      || ""),
-                                                                          security => (LJ::eurl($get->{security}) || ""),
-                                                                          mode     => (LJ::eurl($get->{mode})     || ""), });
+            $nav->{'backward_url'} = LJ::make_link("$p->{'base_url'}/", { 
+                skip     => ($newskip                   || ""),
+                tag      => (LJ::eurl($get->{tag})      || ""),
+                security => (LJ::eurl($get->{security}) || ""),
+                mode     => (LJ::eurl($get->{mode})     || ""), 
+                poster   => ($posteru_filter) ? $posteru_filter->{user} : "", 
+            });
             $nav->{'backward_skip'} = $newskip;
         }
     }

Modified: trunk/cgi-bin/ljlib.pl
===================================================================
--- trunk/cgi-bin/ljlib.pl	2010-09-27 14:14:23 UTC (rev 17456)
+++ trunk/cgi-bin/ljlib.pl	2010-09-28 06:46:19 UTC (rev 17457)
@@ -982,6 +982,7 @@
 #           -- 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
@@ -1167,17 +1168,25 @@
         $sql_select = "AND $sort_key <= $notafter";
     }
 
+
+    my $posterwhere;
+    if ($opts->{'posterid'} && $opts->{'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
     };
-
+    
     unless ($logdb) {
         $$err = "nodb" if ref $err eq "SCALAR";
         return ();

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2010-09-27 14:14:23 UTC (rev 17456)
+++ trunk/cgi-bin/ljviews.pl	2010-09-28 06:46:19 UTC (rev 17457)
@@ -1195,6 +1195,11 @@
         $viewsome = $viewall || LJ::check_priv($remote, 'canview', 'suspended');
     }
 
+    my $posteru_filter;
+    if ($get->{'poster'}) {
+        $posteru_filter = LJ::load_user($get->{'poster'});
+    }
+ 
     ## load the itemids
     my @itemids;
     my $err;
@@ -1210,6 +1215,7 @@
         'order' => ($u->{'journaltype'} eq "C" || $u->{'journaltype'} eq "Y")  # community or syndicated
             ? "logtime" : "",
         'err' => \$err,
+        ($posteru_filter) ?  ('posterid'  => $posteru_filter->{'userid'}) : (),
     });
 
     my $is_prev_exist = scalar @items - $itemshow > 0 ? 1 : 0;
@@ -1448,6 +1454,9 @@
     my ($skip_f, $skip_b) = (0, 0);
     my %skiplinks;
 
+    ### filter by poster in skip links
+    my $poster_filter = ($posteru_filter) ? "poster=$posteru_filter->{user}" : "";
+
     ### if we've skipped down, then we can skip back up
 
     if ($skip) {
@@ -1455,7 +1464,14 @@
         my $newskip = $skip - $itemshow;
         if ($newskip <= 0) { $newskip = ""; }
         else { $newskip = "?skip=$newskip"; }
-
+        
+        if ($poster_filter) {
+            if ($newskip) {
+                $newskip .= "&$poster_filter";
+            } else {
+                $newskip = "?$poster_filter";
+            }
+        }
         $skiplinks{'skipforward'} =
             LJ::fill_var_props($vars, 'LASTN_SKIP_FORWARD', {
                 "numitems" => $itemshow,
@@ -1470,15 +1486,18 @@
     unless ($item_total != $itemshow) {
         $skip_b = 1 if $is_prev_exist;
 
-        if ($skip==$maxskip) {
+        if ($skip>=$maxskip) {
+            my $url = "$journalbase/" . sprintf("%04d/%02d/%02d/", $lastyear, $lastmonth, $lastday);
+            $url .= "?$poster_filter" if $poster_filter;
             $skiplinks{'skipbackward'} =
                 LJ::fill_var_props($vars, 'LASTN_SKIP_BACKWARD', {
                     "numitems" => "Day",
-                    "url" => "$journalbase/" . sprintf("%04d/%02d/%02d/", $lastyear, $lastmonth, $lastday),
+                    "url" => $url,
                 });
         } else {
             my $newskip = $skip + $itemshow;
             $newskip = "?skip=$newskip";
+            $newskip .= "&$poster_filter" if $poster_filter;
             $skiplinks{'skipbackward'} =
                 LJ::fill_var_props($vars, 'LASTN_SKIP_BACKWARD', {
                     "numitems" => $itemshow,

Tags: gariev, livejournal, pl, pm
Subscribe
  • Post a new comment

    Error

    Anonymous comments are disabled in this journal

    default userpic

    Your reply will be screened

    Your IP address will be recorded 

  • 0 comments