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

[livejournal] r19327: LJSUP-9111: When entering an empty field...

Committer: gariev
LJSUP-9111: When entering an empty field or non-existent user is given us the entire list of posts

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	2011-06-20 10:19:41 UTC (rev 19326)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-06-20 10:21:59 UTC (rev 19327)
@@ -88,11 +88,7 @@
         $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;
@@ -113,7 +109,7 @@
         'order' => ($u->{'journaltype'} eq "C" || $u->{'journaltype'} eq "Y")  # community or syndicated
             ? "logtime" : "",
         'err' => \$err,
-        ($posteru_filter) ?  ('posterid'  => $posteru_filter->{'userid'}) : (),
+        'poster'  => $get->{'poster'} || '',
     });
 
     my $is_prev_exist = scalar @items - $itemshow > 0 ? 1 : 0;
@@ -284,7 +280,7 @@
         'skip' => $skip,
         'count' => $itemnum,
     };
-
+ 
     # if we've skipped down, then we can skip back up
     if ($skip) {
         my $newskip = $skip - $itemshow;
@@ -295,7 +291,7 @@
             tag      => (LJ::eurl($get->{tag})      || ""),
             security => (LJ::eurl($get->{security}) || ""),
             mode     => (LJ::eurl($get->{mode})     || ""), 
-            poster   => ($posteru_filter) ? $posteru_filter->{user} : "", 
+            poster   => (LJ::eurl($get->{'poster'}) || ""),
         });
         $nav->{'forward_count'} = $itemshow;
     }
@@ -316,7 +312,7 @@
                 tag      => (LJ::eurl($get->{tag})      || ""),
                 security => (LJ::eurl($get->{security}) || ""),
                 mode     => (LJ::eurl($get->{mode})     || ""), 
-                poster   => ($posteru_filter) ? $posteru_filter->{user} : "", 
+                poster   => (LJ::eurl($get->{'poster'}) || ""),
             });
             $nav->{'backward_skip'} = $newskip;
         }

Modified: trunk/cgi-bin/ljlib.pl
===================================================================
--- trunk/cgi-bin/ljlib.pl	2011-06-20 10:19:41 UTC (rev 19326)
+++ trunk/cgi-bin/ljlib.pl	2011-06-20 10:21:59 UTC (rev 19327)
@@ -1020,7 +1020,8 @@
 #           -- viewsome: if set, suspended flag is not 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
+#           -- posterid: [userid] optional, return (community) posts made by this poster only
+#           -- poster: [username] optional, return (community) posts made by this poster only
 # returns: array of hashrefs containing keys:
 #          -- itemid (the jitemid)
 #          -- posterid
@@ -1220,6 +1221,14 @@
     my $posterwhere;
     if ($opts->{'posterid'} && $opts->{'posterid'} =~ /^(\d+)$/) {
         $posterwhere = " AND posterid=$1";
+    } elsif ($opts->{'poster'}) {
+        my $posteru = LJ::load_user($opts->{'poster'});
+        unless ($posteru) {
+            $$err = "No such user: " . LJ::ehtml($opts->{'poster'}) 
+                if ref $err eq "SCALAR";
+            return;
+        }
+        $posterwhere = " AND posterid=$posteru->{userid}";
     } else {
         $posterwhere = '';
     }

Modified: trunk/cgi-bin/ljviews.pl
===================================================================
--- trunk/cgi-bin/ljviews.pl	2011-06-20 10:19:41 UTC (rev 19326)
+++ trunk/cgi-bin/ljviews.pl	2011-06-20 10:21:59 UTC (rev 19327)
@@ -1196,11 +1196,6 @@
         $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;
@@ -1217,7 +1212,7 @@
         'order' => ($u->{'journaltype'} eq "C" || $u->{'journaltype'} eq "Y")  # community or syndicated
             ? "logtime" : "",
         'err' => \$err,
-        ($posteru_filter) ?  ('posterid'  => $posteru_filter->{'userid'}) : (),
+        'poster'  => $get->{'poster'},
     });
 
     my $is_prev_exist = scalar @items - $itemshow > 0 ? 1 : 0;
@@ -1461,7 +1456,7 @@
     my %skiplinks;
 
     ### filter by poster in skip links
-    my $poster_filter = ($posteru_filter) ? "poster=$posteru_filter->{user}" : "";
+    my $poster_filter = ($get->{'poster'}) ? "poster=" . LJ::eurl($get->{'poster'}) : "";
 
     ### if we've skipped down, then we can skip back up
 

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