madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20296: LJSUP-10119: disabled dealayed entries f...

Committer: sbelyaev
LJSUP-10119: disabled dealayed entries flag is added
U   trunk/cgi-bin/LJ/S2/DayPage.pm
U   trunk/cgi-bin/LJ/S2/MonthPage.pm
U   trunk/cgi-bin/LJ/S2/RecentPage.pm
U   trunk/cgi-bin/LJ/User.pm
U   trunk/cgi-bin/LJ/Widget/EntryForm.pm
U   trunk/cgi-bin/ljprotocol.pl
U   trunk/htdocs/editjournal.bml
U   trunk/htdocs/update.bml
Modified: trunk/cgi-bin/LJ/S2/DayPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/DayPage.pm	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/cgi-bin/LJ/S2/DayPage.pm	2011-10-12 15:24:39 UTC (rev 20296)
@@ -108,10 +108,14 @@
     # load tags
     my $tags = LJ::Tags::get_logtags($u, \@itemids);
     
-    my @ditems = LJ::DelayedEntry->get_entries_for_day($u, $year, $month, $day, $dateformat, $secwhere);
-    foreach my $ditem (@ditems) {
-        if ($ditem) {
-            push @items, $ditem;
+    my @ditems = ();
+    if ( !$LJ::DELAYED_ENTRIES_DISABLED ) {
+        @ditems = LJ::DelayedEntry->get_entries_for_day($u, $year, $month, $day, $dateformat, $secwhere);
+
+        foreach my $ditem (@ditems) {
+            if ($ditem) {
+                push @items, $ditem;
+            }
         }
     }
 

Modified: trunk/cgi-bin/LJ/S2/MonthPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/MonthPage.pm	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/cgi-bin/LJ/S2/MonthPage.pm	2011-10-12 15:24:39 UTC (rev 20296)
@@ -78,9 +78,13 @@
     my @items;
     push @items, $_ while $_ = $sth->fetchrow_hashref;
     
-    my @ditems = LJ::DelayedEntry->get_entries_for_month($u, $year, $month, $dateformat, $secwhere);
-    foreach my $ditem (@ditems) {
-        push @items, $ditem;
+    my @ditems = ();
+    if ( !$LJ::DELAYED_ENTRIES_DISABLED ) {
+        @ditems = LJ::DelayedEntry->get_entries_for_month($u, $year, $month, $dateformat, $secwhere);
+
+        foreach my $ditem (@ditems) {
+            push @items, $ditem;
+        }
     }
     
     @items = sort { $a->{'alldatepart'} cmp $b->{'alldatepart'} } @items;

Modified: trunk/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/cgi-bin/LJ/S2/RecentPage.pm	2011-10-12 15:24:39 UTC (rev 20296)
@@ -79,12 +79,14 @@
     my $usual_skip =  $delayed_entries_count - $skip > $itemshow ? 
                                             $skip - $delayed_entries_count + $has_sticky :
                                             $skip ? $skip : 0;
+    if (!$LJ::DELAYED_ENTRIES_DISABLED) {
+        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 (!$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 = [];

Modified: trunk/cgi-bin/LJ/User.pm
===================================================================
--- trunk/cgi-bin/LJ/User.pm	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/cgi-bin/LJ/User.pm	2011-10-12 15:24:39 UTC (rev 20296)
@@ -7852,7 +7852,9 @@
     my $list = LJ::MemCache::get($memkey);
     if ($list) {
         my $list_create_time = shift @$list;
-        LJ::DelayedEntry->get_daycount_query($u, $list, $secwhere);
+        if (!$LJ::DELAYED_ENTRIES_DISABLED) {
+            LJ::DelayedEntry->get_daycount_query($u, $list, $secwhere);
+        }
         return $list if $list_create_time >= $u->timeupdate;
     }
 
@@ -7887,7 +7889,9 @@
     LJ::MemCache::set($memkey, [time, @days]);
 
     # not cached part
-    LJ::DelayedEntry->get_daycount_query($u, \@days, $secwhere);
+    if (!$LJ::DELAYED_ENTRIES_DISABLED) {
+        LJ::DelayedEntry->get_daycount_query($u, \@days, $secwhere);
+    }
     $release_lock->();
     return \@days;
 }

Modified: trunk/cgi-bin/LJ/Widget/EntryForm.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/EntryForm.pm	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/cgi-bin/LJ/Widget/EntryForm.pm	2011-10-12 15:24:39 UTC (rev 20296)
@@ -420,12 +420,19 @@
     $out .= "<div id='metainfo-wrap'><ul id='metainfo'>";
 
 
+    my $can_edit_date = 1;
     # login info
     $out .= $opts->{'auth'};
     if ($opts->{'mode'} eq "update") {
         # communities the user can post in
         my $usejournal = $opts->{'usejournal'};
         if ($usejournal) {
+            my $posterid = $remote->userid;
+            my $ownerid = LJ::load_user($usejournal)->userid;
+            my $dbh = LJ::get_db_writer();
+            $can_edit_date = !!($dbh->selectrow_array("SELECT COUNT(*) FROM reluser ".
+                                                     "WHERE userid=$ownerid AND targetid=$posterid ".
+                                                     "AND type IN ('A','M','N')")) || 0;
             $out .= "<li id='usejournal_single' class='pkg'>\n";
             $out .= "<label for='usejournal' class='left'>" .
                 BML::ml('entryform.postto') . "</label>\n";
@@ -524,12 +531,13 @@
         "</noscript>";
 
     my $help_icon = LJ::help_icon("24hourshelp");
+    my $hide_link = $can_edit_date ? '' : 'style="display: none;"'; 
 
-    if ( $opts->{'mode'} eq "edit" ) {
+    if ( $opts->{'mode'} eq "edit" && $can_edit_date ) {
         $out .= qq{ <li class='pkg' id='currentdate'><label class='title'>$BML::ML{'entryform.date'}</label>
                 <span class='wrap'>
                     $monthlong, $mday, $year, $hour:$min
-                    <a href='javascript:void(0)' onclick='editdate();' id='currentdate-edit'>$BML::ML{'entryform.date.edit'}</a>
+                    <a $hide_link href='javascript:void(0)' onclick='editdate();' id='currentdate-edit'>$BML::ML{'entryform.date.edit'}</a>
                     $help_icon
                   </span>
                 </li> };
@@ -537,7 +545,7 @@
         $out .= qq{ <li class='pkg' id='currentdate'><label class='title'>$BML::ML{'entryform.post'}</label>
                 <span class='wrap'>
                     $BML::ML{'entryform.post.right.now'}
-                    <a href='javascript:void(0)' onclick='editdate();' id='currentdate-edit'>$BML::ML{'entryform.date.edit'}</a>
+                    <a $hide_link href='javascript:void(0)' onclick='editdate();' id='currentdate-edit'>$BML::ML{'entryform.date.edit'}</a>
                     $help_icon
                 </span>
             </li>};
@@ -777,10 +785,11 @@
                     if ( $sticky_entry eq $opts->{jitemid} ) {
                         return 'checked' 
                     }
-                }
-                
+                }   
             };
 
+            my $disabled = !($remote->can_manage($journalu) || 0);
+
             my $selected = $is_checked->();
             my $sticky_check = LJ::html_check({
                 'type' => "check",
@@ -788,6 +797,7 @@
                 'value' => 'sticky',
                 'name' => 'sticky_type',
                 'id' => 'sticky_type',
+                'disabled' => $disabled,
                 'selected' => $selected,
                 $opts->{'prop_opt_preformatted'} || $opts->{'event_format'},
                 'label' => "",
@@ -1640,10 +1650,20 @@
             my $need_moderated = ( $moderated =~ /^[1A]$/ ) ? 1 : 0;
             my $can_post = ($u->{'journaltype'} eq 'C' && !$need_moderated) ||
                             $can_manage;
+   
+            my $ownerid = $u->userid;
+            my $posterid = $remote->userid;
 
+            # don't moderate admins, moderators & pre-approved users
+            my $dbh = LJ::get_db_writer();
+            my $relcount = $dbh->selectrow_array("SELECT COUNT(*) FROM reluser ".
+                                                 "WHERE userid=$ownerid AND targetid=$posterid ".
+                                                 "AND type IN ('A','M','N')");
+        
+
             $site_data->{$login}->{'is_replace_sticky'} = $u->has_sticky_entry;
             $site_data->{$login}->{'can_create_sticky'} = $can_manage;
-            $site_data->{$login}->{'can_post_delayed'} = int $can_post;
+            $site_data->{$login}->{'can_post_delayed'} = (int $can_post) || !!$relcount;
         }
         $site->{remote_permissions} = $site_data;
     });

Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/cgi-bin/ljprotocol.pl	2011-10-12 15:24:39 UTC (rev 20296)
@@ -2074,7 +2074,10 @@
     # it... where clause there is: < $LJ::EndOfTime).  but this way we can
     # have entries that don't show up on friends view, now that we don't have
     # the hints table to not insert into.
-    my $rlogtime = $LJ::EndOfTime - $now;
+    my $rlogtime = $LJ::EndOfTime;
+    unless ($req->{'props'}->{'opt_backdated'}) {
+        $rlogtime -= $now;
+    }
 
     my $dupsig = Digest::MD5::md5_hex(join('', map { $req->{$_} }
                                            qw(subject event usejournal security allowmask)));
@@ -2141,7 +2144,7 @@
         LJ::run_hook('spam_community_detector', $uowner, $req, \$need_moderated);
     }
 
-    if ( $req->{ver} > 1 ) {
+    if ( $req->{ver} > 1  && !$LJ::DELAYED_ENTRIES_DISABLED ) {
         my $use_delayed = $req->{'custom_time'} ||
                     !(exists $flags->{'use_custom_time'});
         if ( $use_delayed && LJ::DelayedEntry::is_future_date($req) ) {
@@ -2990,9 +2993,18 @@
     }
 
     # compatible with depricated 'opt_backdated'
-    if ( $oldevent->{'rlogtime'} == $LJ::EndOfTime ) {
+    if ($req->{'props'}->{'opt_backdated'} eq "1" &&
+        $oldevent->{'rlogtime'} != $LJ::EndOfTime) {
         my $dberr;
         LJ::run_hooks('report_entry_update', $ownerid, $itemid);
+        $uowner->log2_do(undef, "UPDATE log2 SET rlogtime=$LJ::EndOfTime WHERE ".
+                         "journalid=$ownerid AND jitemid=$itemid");
+        return fail($err,501,$dberr) if $dberr;
+    }
+    if ($req->{'props'}->{'opt_backdated'} eq "0" &&
+        $oldevent->{'rlogtime'} == $LJ::EndOfTime) {
+        my $dberr;
+        LJ::run_hooks('report_entry_update', $ownerid, $itemid);
         $uowner->log2_do(\$dberr, "UPDATE log2 SET rlogtime=$LJ::EndOfTime-UNIX_TIMESTAMP(logtime) ".
                          "WHERE journalid=$ownerid AND jitemid=$itemid");
         return fail($err,501,$dberr) if $dberr;
@@ -3130,7 +3142,7 @@
 
     $skip = 500 if $skip > 500;
 
-    if ( $req->{ver} > 1 ) {
+    if ( $req->{ver} > 1 && !$LJ::DELAYED_ENTRIES_DISABLED ) {
         my $res = {};
 
         if ( $req->{delayedid} ) {

Modified: trunk/htdocs/editjournal.bml
===================================================================
--- trunk/htdocs/editjournal.bml	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/htdocs/editjournal.bml	2011-10-12 15:24:39 UTC (rev 20296)
@@ -449,8 +449,6 @@
                             'delayedid'  => $delayedid,
                             '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);
 

Modified: trunk/htdocs/update.bml
===================================================================
--- trunk/htdocs/update.bml	2011-10-12 14:09:58 UTC (rev 20295)
+++ trunk/htdocs/update.bml	2011-10-12 15:24:39 UTC (rev 20296)
@@ -512,8 +512,6 @@
                     'sticky'      => $sticky,
                     'custom_time' => $custom_time,
                     'tz'          => $timezone, 
-                    'do_not_add_rss_friends' => $POST{'do_not_add_rss_friends'} ||
-                                                    $GET{'do_not_add_rss_friends'}
                     );
 
         $flags->{'use_custom_time'} = 1; 

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