madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20212: LJSUP-9999

Committer: sbelyaev
LJSUP-9999
U   trunk/cgi-bin/LJ/DelayedEntry.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/LJ/User.pm
U   trunk/cgi-bin/ljlib.pl
U   trunk/htdocs/editjournal.bml
Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2011-10-04 05:57:48 UTC (rev 20211)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2011-10-04 06:19:08 UTC (rev 20212)
@@ -788,7 +788,7 @@
 }
 
 sub get_daycount_query {
-    my ($class, $journal) = @_;
+    my ($class, $journal, $list, $secwhere) = @_;
     my $dbcr = LJ::get_cluster_def_reader($journal);
 
     my $remote = LJ::get_remote();
@@ -796,14 +796,12 @@
     return undef unless __delayed_entry_can_see( $journal,
                                                  $remote  );
     
-    my $secwhere = __delayed_entry_secwhere( $journal,
-                                             $journal->userid,
-                                             $remote->userid );
-
     my $sth = $dbcr->prepare("SELECT year, month, day, COUNT(*) " .
                              "FROM delayedlog2 WHERE journalid=? $secwhere GROUP BY 1, 2, 3");
     $sth->execute($journal->userid);
-    return $sth;
+    while (my ($y, $m, $d, $c) = $sth->fetchrow_array) {
+        push @$list, [ int($y), int($m), int($d), int($c) ];
+    }
 }
 
 sub get_entries_for_day_row {
@@ -1454,7 +1452,6 @@
     if ($poster->can_moderate($uowner)) {
         return 1;
     }
-    warn "cannot see";
 
     return 0;
 }

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-10-04 05:57:48 UTC (rev 20211)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-10-04 06:19:08 UTC (rev 20212)
@@ -71,32 +71,26 @@
         $viewsome = $viewall || LJ::check_priv($remote, 'canview', 'suspended');
     }
 
-    my $delayed_entries = [];
+    my $delayed_entries;
+    
+    # calculate recent entries count
+    my $has_sticky = $u->has_sticky_entry;
     my $delayed_entries_count = LJ::DelayedEntry->get_entries_count($u);
-    my $usual_skip = $delayed_entries_count ? $skip - $delayed_entries_count : 0;
+    my $usual_skip =  $delayed_entries_count - $skip > $itemshow ? 
+                                            $skip - $delayed_entries_count + $has_sticky :
+                                            $skip ? $skip : 0;
 
-    if ( $u->has_sticky_entry && !$skip) {
-        $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow - 1) ;
-    } elsif ( $u->has_sticky_entry && $skip) {
-        $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip - 1, $itemshow);
-    } else {
-        $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow + 1);
-    }
+    if (!$skip) {
+        $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip, $itemshow - $has_sticky);
+    } elsif ( $skip) {
+        $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($u, $skip - $has_sticky, $itemshow);
+    }    
 
     if (!$delayed_entries) {
         $delayed_entries = [];
     }
 
-    if ( $skip && $usual_skip < 0 && $u->has_sticky_entry ) {
-        $usual_skip = 1;
-    } elsif ( $skip && $usual_skip < 0 ) {
-        $usual_skip = 0;
-    }
-
     my $itemshow_usual = $itemshow - scalar(@$delayed_entries);
-    if ( $itemshow <= scalar(@$delayed_entries) ) {
-            $itemshow_usual -= 1;
-    }
     if ( $itemshow_usual < 0 ) {
         $itemshow_usual = 0;
     }
@@ -122,16 +116,17 @@
             ? "logtime" : "",
         'err' => \$err,
         'poster'  => $get->{'poster'} || '',
-        'show_sticky_on_top' => !$skip,
+        'show_sticky_on_top' => 1,
     }) if ($itemshow_usual >= 0) ;
     
     my $is_prev_exist = scalar @items + scalar(@$delayed_entries) - $itemshow > 0 ? 1 : 0;
     if ($is_prev_exist) {
         if ( scalar(@$delayed_entries) > $itemshow ) {
             pop @$delayed_entries;
-        } elsif ( scalar(@items) + scalar(@$delayed_entries) > $itemshow ) {
-            pop @items if scalar(@items);
         }
+        if ( scalar(@items) + scalar(@$delayed_entries) > $itemshow ) {        
+            pop @items;
+        } 
     }
 
     die $err if $err;
@@ -170,7 +165,7 @@
          !$u->has_sticky_entry()) ) {
         __append_delayed( $u, $delayed_entries,  $p->{'entries'} );
     }
-  warn scalar (@items); 
+  
   ENTRY:
     foreach my $item (@items)
     {
@@ -181,7 +176,7 @@
         my $entry_obj = LJ::Entry->new($u, ditemid => $ditemid);
         
         # append delayed entries
-        if ( $entry_obj->is_sticky() && $sticky_appended) {
+        if ( $entry_obj->is_sticky() && $sticky_appended ) {
             __append_delayed( $u, $delayed_entries,  $p->{'entries'});
             $sticky_appended = 1;
         }
@@ -377,8 +372,12 @@
             'post_url' => $posturl,
             'count' => 0,
             'maxcomments' => 0,
+            'maxcomments' => 0,
             'enabled' => $delayed_entry->comments_shown,
             'locked' => !$delayed_entry->posting_comments_allowed,
+            'maxcomments' => 0,
+            'enabled' => $delayed_entry->comments_shown,
+            'locked' => !$delayed_entry->posting_comments_allowed,
             'screened' => 0,
             'show_readlink' => 0,
             'show_postlink' => 0,

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-10-04 05:57:48 UTC (rev 20211)
+++ trunk/cgi-bin/LJ/User.pm	2011-10-04 06:19:08 UTC (rev 20212)
@@ -7836,12 +7836,7 @@
     my $list = LJ::MemCache::get($memkey);
     if ($list) {
         my $list_create_time = shift @$list;
-        my $sth = LJ::DelayedEntry->get_daycount_query($u, $secwhere);
-        if ($sth) {
-            while (my ($y, $m, $d, $c) = $sth->fetchrow_array) {
-                push @$list, [ int($y), int($m), int($d), int($c) ];
-            }
-        }
+        LJ::DelayedEntry->get_daycount_query($u, $list, $secwhere);
         return $list if $list_create_time >= $u->timeupdate;
     }
 

Modified: trunk/cgi-bin/ljlib.pl
===================================================================
--- trunk/cgi-bin/ljlib.pl	2011-10-04 05:57:48 UTC (rev 20211)
+++ trunk/cgi-bin/ljlib.pl	2011-10-04 06:19:08 UTC (rev 20212)
@@ -1140,7 +1140,8 @@
     if ($skip > $maxskip) { $skip = $maxskip; }
     my $itemload = $itemshow + $skip;
     my $usual_show  = $itemshow;
-    
+    my $skip_sticky = $skip;    
+
     if ( $show_sticky_on_top && $sticky )
     {
         if($skip > 0) {
@@ -1316,7 +1317,7 @@
 
     if ( $sticky && $show_sticky_on_top ) {
         # build request to receive sticky entries
-        if (!$skip) {
+        if ( !$skip_sticky ) {
             $sticky_sql = "$sql AND jitemid = $sticky ";
             $sticky_sql .= "ORDER BY journalid, $sort_key ";
         }
@@ -1364,7 +1365,10 @@
         }
     };
 
-    $absorb_data->($sticky_sql) if ( $sticky && !$skip && $show_sticky_on_top);
+    
+    if ( $sticky && !$skip_sticky && $show_sticky_on_top ) {
+        $absorb_data->($sticky_sql);
+    }
     $absorb_data->($sql);
     $flush->();
 

Modified: trunk/htdocs/editjournal.bml
===================================================================
--- trunk/htdocs/editjournal.bml	2011-10-04 05:57:48 UTC (rev 20211)
+++ trunk/htdocs/editjournal.bml	2011-10-04 06:19:08 UTC (rev 20212)
@@ -431,15 +431,20 @@
                 return LJ::bad_input($ML{'error.invalidform'}) unless LJ::check_form_auth();
 
                 my $timezone = $POST{'timezone'} || $GET{'timezone'};
+                my $sticky = $POST{'sticky_type'} || $GET{'sticky_type'};
+                my $custom_time = $POST{'custom_time'} || $GET{'custom_time'};
                 $timezone =  sprintf("%+.4d", $timezone);
                 my %req = (
                             'ver' => 2,
                             'username' => $remote->{'user'},
                             'usejournal' => $usejournal,
-                            tz           => $timezone,
+                            'tz'         => $timezone,
                             'itemid'     => $itemid,
                             'delayedid'  => $delayedid,
-                            'type'       => $POST{'type'} || $POST{'type'},
+                            'sticky'     => $sticky,
+                            'custom_time' => $custom_time,
+                            'do_not_add_rss_friends' => $POST{'do_not_add_rss_friends'} ||
+                                                        $GET{'do_not_add_rss_friends'}
                             );
                 LJ::entry_form_decode(\%req, \%POST);
 

Tags: bml, livejournal, madeon, 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