madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20115: LJSUP-9823, LJSUP-9822, LJSUP-9829: logi...

Committer: sbelyaev
LJSUP-9823, LJSUP-9822, LJSUP-9829: logic has chaneged
U   branches/delayed_entries/cgi-bin/LJ/DelayedEntry/Scheduler.pm
U   branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm
U   branches/delayed_entries/cgi-bin/LJ/S2/RecentPage.pm
U   branches/delayed_entries/cgi-bin/LJ/Widget/EntryForm.pm
U   branches/delayed_entries/cgi-bin/weblib.pl
U   branches/delayed_entries/htdocs/update.bml
Modified: branches/delayed_entries/cgi-bin/LJ/DelayedEntry/Scheduler.pm
===================================================================
--- branches/delayed_entries/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2011-09-22 09:39:59 UTC (rev 20114)
+++ branches/delayed_entries/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2011-09-23 01:14:32 UTC (rev 20115)
@@ -55,7 +55,7 @@
 
     my $entries = __load_delayed_entries($dbh);
     foreach my $entry(@$entries) {
-        my $post_status = $entry->convert($clusterid);
+        my $post_status = $entry->convert();
         
         # do we need to send error
         if ( $post_status->{error_message} ) {

Modified: branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm	2011-09-22 09:39:59 UTC (rev 20114)
+++ branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm	2011-09-23 01:14:32 UTC (rev 20115)
@@ -3,11 +3,9 @@
 use strict;
 use warnings;
 require 'ljprotocol.pl';
-use DateTime;
-use Storable;
-use POSIX;
 use LJ::User;
-
+use Storable;
+                
 sub create {
     my ( $class, $req, $opts ) = @_;
 
@@ -17,11 +15,10 @@
     __assert( $req );
 
     my $self = bless {}, $class;
-    
+
     my $journal = $opts->{journal};
     my $poster = $opts->{poster};
     $req->{'event'} =~ s/\r\n/\n/g;
-    
 
     my $data_ser = __serialize($journal, $req);
 
@@ -169,6 +166,7 @@
     my ($req) = @_;
     my $now = __get_now();
     my $request_time = __get_datatime($req);
+
     return $request_time ge $now;
 }
 
@@ -266,7 +264,6 @@
     return 0;
 }
 
-
 sub group_names {
     return undef;
 }
@@ -517,7 +514,7 @@
     __assert( $self->{journal} );
     __assert( $self->{poster} );
 
-    $req->{timezone} = $req->{timezone} || $self->data->{timezone};
+    $req->{tz} = $req->{tz} || $self->data->{tz};
 
     my $journalid = $self->journal->userid;
     my $posterid = $self->poster->userid;
@@ -543,14 +540,9 @@
     my $qposttime   = $dbh->quote($posttime);
     my $utime       = $dbh->selectrow_array("SELECT UNIX_TIMESTAMP($qposttime)");
 
-    my $rlogtime    = $LJ::EndOfTime;
-    unless ( $req->{'props'}->{'do_not_add_rss_friends'} ) {
-        $rlogtime -= $now;
-    }
-
+    my $rlogtime    = $LJ::EndOfTime -= $now;
     my $rposttime   = $LJ::EndOfTime - $utime;
     $self->{taglist} = __extract_tag_list(\$req->{props}->{taglist});
-
     $req->{'event'} =~ s/\r\n/\n/g; # compact new-line endings to more comfort chars count near 65535 limit
 
     $self->journal->do("UPDATE delayedlog2 SET posterid=$posterid, " .
@@ -1077,11 +1069,13 @@
 }
 
 sub convert {
-    my ($self, $clusterid) = @_;
+    my ($self) = @_;
     my $req = $self->{data};
 
     my $journal    = $self->journal;
     my $journalid  = $journal->userid;
+    my $clusterid  = $journal->clusterid;
+
     my $poster     = $self->poster;
     my $posterid   = $poster->userid;
 
@@ -1439,8 +1433,6 @@
     return 0;
 }
 
- 
-
 sub item_link {
     my ($u, $delayedid, @args) = @_;
     # XXX: should have an option of returning a url with escaped (&)
@@ -1525,14 +1517,14 @@
 sub __get_datatime {
     my ($req) = @_;
     __assert($req);
-    __assert($req->{timezone});
+    __assert($req->{'tz'});
 
     my $dt = DateTime->new(   year      => $req->{'year'}, 
                               month     => $req->{'mon'},
                               day       => $req->{'day'}, 
                               hour      => $req->{'hour'},
                               minute    => $req->{'min'},
-                              time_zone => $req->{timezone}, );
+                              time_zone => $req->{tz}, );
 
     #if ($dt->is_dst) {
     #    $dt->subtract( hours => 1 );

Modified: branches/delayed_entries/cgi-bin/LJ/S2/RecentPage.pm
===================================================================
--- branches/delayed_entries/cgi-bin/LJ/S2/RecentPage.pm	2011-09-22 09:39:59 UTC (rev 20114)
+++ branches/delayed_entries/cgi-bin/LJ/S2/RecentPage.pm	2011-09-23 01:14:32 UTC (rev 20115)
@@ -127,7 +127,7 @@
         if ( scalar(@$delayed_entries) > $itemshow ) {
             pop @$delayed_entries;
         } elsif ( scalar(@items) + scalar(@$delayed_entries) > $itemshow ) {
-            pop @items;
+            pop @items if scalar(@items);
         }
     }
 

Modified: branches/delayed_entries/cgi-bin/LJ/Widget/EntryForm.pm
===================================================================
--- branches/delayed_entries/cgi-bin/LJ/Widget/EntryForm.pm	2011-09-22 09:39:59 UTC (rev 20114)
+++ branches/delayed_entries/cgi-bin/LJ/Widget/EntryForm.pm	2011-09-23 01:14:32 UTC (rev 20115)
@@ -380,7 +380,15 @@
     my $errors = $self->errors;
     my $onload = $self->onload;
 
+    $out .= LJ::html_hidden({
+        name => 'timezone',
+        value => 'guess',
+        id => 'journal_timezone',
+    });
+    $out .= "<script>try { \$('journal_timezone').value = - (new Date).getTimezoneOffset()/0.6; } catch(e) {} </script>";
     $out .= "<div id='metainfo-wrap'><ul id='metainfo'>";
+
+
     # login info
     $out .= $opts->{'auth'};
     if ($opts->{'mode'} eq "update") {
@@ -483,7 +491,6 @@
     $date_diff_input .= "<noscript>" .  LJ::html_hidden("date_diff_nojs", "1") .
         "</noscript>";
 
-    my $timeZones = option($remote);
     my $help_icon = LJ::help_icon("24hourshelp");
 
     if ( $opts->{'mode'} eq "edit" ) {
@@ -503,6 +510,7 @@
                 </span>
             </li>};
     }
+
     $out .= qq{ <li class='pkg' id='modifydate'><label class='title'>$BML::ML{'entryform.postponed.until'}</label>
                 <span class='wrap'>
                     <input type="hidden" name="date_ymd_mm" value="$mon" />
@@ -514,7 +522,6 @@
                         <input type='text' name='hour' value='$hour' class='input-num' /> : <input type='text' value='$min' name='min' class='input-num' />
                         <?de $BML::ML{'entryform.date.24hournote'} de?>
                     </span>
-                    <span class='timezone'>$timeZones</span>
                 </span>
             </li>
         <li>
@@ -1589,52 +1596,4 @@
     return $out;
 }
 
-# this one returns a $key => $value list, ordered by keys this way:
-# US goes first, then Canada, then all the rest
-sub timezone_options {
-    my $map = DateTime::TimeZone::links();
-    
-    my ( @options, %options );
-    
-    push @options, '' => BML::ml('setting.timezone.option.select');
-    
-    foreach my $key ( sort keys %$map ) {
-        if ( $key =~ m!^US/! && $key ne 'US/Pacific-New' ) {
-            $options{ $map->{$key} } = $key;
-            push @options, $map->{$key} => $key;
-        }
-    }
-    
-    foreach my $key ( sort keys %$map ) {
-        if ( $key =~ m!^Canada/! ) {
-            $options{ $map->{$key} } = $key;
-            push @options, $map->{$key} => $key;
-        }
-    }
-    
-    foreach my $key ( DateTime::TimeZone::all_names() ) {
-        next if $options{$key};
-        push @options, $key => $key;
-    }
-    
-    return @options;
-}
-
-sub option {
-    my ($u) = @_;
-    
-    my $timezone = $u ? $u->prop("timezone") : undef;
-    my @options = timezone_options;
-    
-    my $ret = LJ::html_select({
-        name => "delayed_timezone",
-        selected => $timezone,
-        class => "select select-timezone",
-    }, @options);
-    
-    $ret .= "<br />";
-    
-    return $ret;
-}
-
 1;

Modified: branches/delayed_entries/cgi-bin/weblib.pl
===================================================================
--- branches/delayed_entries/cgi-bin/weblib.pl	2011-09-22 09:39:59 UTC (rev 20114)
+++ branches/delayed_entries/cgi-bin/weblib.pl	2011-09-23 01:14:32 UTC (rev 20115)
@@ -1113,7 +1113,6 @@
     # time is sync'd with their computer clock. otherwise, the JS didn't run,
     # so let's guess at their timezone.
     if ($POST->{'date_diff'} || $POST->{'date_diff_nojs'} || $different) {
-        delete $req->{'tz'};
         $req->{'year'} = $year;
         $req->{'mon'} = $mon;
         $req->{'day'} = $day;

Modified: branches/delayed_entries/htdocs/update.bml
===================================================================
--- branches/delayed_entries/htdocs/update.bml	2011-09-22 09:39:59 UTC (rev 20114)
+++ branches/delayed_entries/htdocs/update.bml	2011-09-23 01:14:32 UTC (rev 20115)
@@ -456,19 +456,22 @@
             $$body .= "<?p <strong>$ML{'.loggingin'}</strong> $ML{'.servermsg'} p?><div style='margin-left: 40px'><b>$login_message</b></div>";
         }
 
+        my $timezone = $POST{'timezone'} || $GET{'timezone'};
+        $timezone =  sprintf("%+.4d", $timezone);
         my %req = (
                     'ver'         => $LJ::PROTOCOL_VER,
                     'username'    => $user,
                     'password'    => $POST{'password'},
                     'usejournal'  => ($usejournalu) ? $usejournalu->user : undef,
-                    'tz'          => 'guess',
-                    'timezone'    => $POST{'delayed_timezone'} || $GET{'delayed_timezone'},
+                    'tz'          => $timezone, 
                     'type'        => $POST{'type'} || $GET{'type'},
-                    'ver'         => 3,
+                    'ver'         => 2,
+                    'type'        => 'posted',
                     'do_not_add_rss_friends' => $POST{'do_not_add_rss_friends'} ||
                                                     $GET{'do_not_add_rss_friends'}
                     );
 
+        $flags->{'ignore_type'} = 1; 
         LJ::entry_form_decode(\%req, \%POST);
         if ($req{'event'} eq "") {
             $errors->{'entry'} = $ML{'.error.noentry'};
@@ -570,8 +573,8 @@
                     my @after_entry_post_extra_options = LJ::run_hooks('after_entry_post_extra_options', user => $ju, itemlink => $itemlink);
                     my $after_entry_post_extra_options = join('', map {$_->[0]} @after_entry_post_extra_options) || '';
 
-                    $$body .= " p?><?p $ML{'.success.links'} p?><ul>" . $writersblocklink;
-                        "<li><a href=\"$itemlink\">$ML{'.success.links.view'}</a></li>" .
+                    $$body .= " p?><?p $ML{'.success.links'} p?><ul>" . $writersblocklink.
+                        "<li><a href=\"$itemlink\">$ML{'.success.links.view'}</a></li>";
                         my $item_text;
                         if ($itemid) {
                             $item_text = "journal=$juser&itemid=$itemid";

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