madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20920: LJSUP-10439: Interface of delayed entrie...

Committer: sbelyaev
LJSUP-10439: Interface of delayed entries manage page is updated.
U   trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
U   trunk/cgi-bin/LJ/DelayedEntry.pm
U   trunk/cgi-bin/LJ/Widget/EntryChooser.pm
U   trunk/htdocs/manage/scheduled_posts.bml
U   trunk/htdocs/manage/scheduled_posts.bml.text
U   trunk/templates/Widgets/entry_chooser.tmpl
Modified: trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-01-18 06:16:33 UTC (rev 20919)
+++ trunk/cgi-bin/LJ/DelayedEntry/Scheduler.pm	2012-01-18 08:34:34 UTC (rev 20920)
@@ -34,13 +34,13 @@
     my $email = $poster->email_raw;
     
     LJ::send_mail({
-        'to' => $email,
-        'from' => $LJ::ADMIN_EMAIL,
-        'fromname' => $LJ::SITENAME,
-        'charset' => 'utf-8',
-        'subject' => LJ::Lang::get_text($poster->prop('browselang'),
+        'to'        => $email,
+        'from'      => $LJ::ADMIN_EMAIL,
+        'fromname'  => $LJ::SITENAME,
+        'charset'   => 'utf-8',
+        'subject'   => LJ::Lang::get_text($poster->prop('browselang'),
                                         'email.delayed_error.subject'),
-        'body' =>  LJ::Lang::get_text($poster->prop('browselang'),
+        'body'      =>  LJ::Lang::get_text($poster->prop('browselang'),
                                         'email.delayed_error.body',
         {subject => $subject, reason=>$error}),
     });    

Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2012-01-18 06:16:33 UTC (rev 20919)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2012-01-18 08:34:34 UTC (rev 20920)
@@ -6,6 +6,8 @@
 use LJ::User;
 use Storable;
 
+#common methodss
+
 sub create_from_url {
     my ($class, $url, $opts) = @_;
 
@@ -18,7 +20,11 @@
 
     return undef;
 }
-    
+
+sub is_delayed {
+    return 1;
+}
+
 sub create {
     my ( $class, $req, $opts ) = @_;
 
@@ -110,10 +116,131 @@
     return $self;
 }
 
-sub valid {
-    return 1;
+
+sub update {
+    my ($self, $req) = @_;
+    __assert( $self->{delayed_id}, "no delayed id" );
+    __assert( $self->{journal}, "no journal" );
+    __assert( $self->{poster}, "no poster" );
+
+    $req->{tz} = $req->{tz} || $self->data->{tz};
+
+    my $journalid = $self->journal->userid;
+    my $posterid  = $self->poster->userid;
+    my $subject   = $req->{subject};
+    my $posttime  = __get_datetime($req);
+    my $delayedid = $self->{delayed_id};
+    my $dbh       = LJ::get_db_writer();
+    my $data_ser  = __serialize($req);
+
+    my $security  = "public";
+    my $uselogsec = 0;
+
+    if ($req->{'security'} eq "usemask" || $req->{'security'} eq "private") {
+        $security = $req->{'security'};
+    }
+
+    if ($req->{'security'} eq "usemask") {
+        $uselogsec = 1;
+    }
+
+    my $now = time();
+    my $dt = DateTime->new(   year       => $req->{year},
+                              month      => $req->{mon},
+                              day        => $req->{day},
+                              hour       => $req->{hour},
+                              minute     => $req->{min},
+                              time_zone  => $req->{tz} );
+    
+    my $utime       = $dt->epoch;
+
+    my $allowmask   = $req->{'allowmask'}+0;
+    my $rlogtime    = $LJ::EndOfTime - $now;
+    my $rposttime   = $LJ::EndOfTime - $utime;
+    my $sticky_type = $req->{sticky} ? 1 : 0;   
+ 
+    $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=?, " .
+                        "subject=?, posttime = ?, " . 
+                        "security=?, allowmask=?, " .    
+                        "year=?, month=?, day=?, " .
+                        "rlogtime=?, revptime=?, is_sticky=? " .
+                        "WHERE journalid=? AND delayedid=?",
+                        undef, 
+                        $posterid, LJ::text_trim($req->{'subject'}, 30, 0), 
+                        $posttime, $security, $allowmask, 
+                        $req->{year}, $req->{mon}, $req->{day},
+                        $rlogtime, $rposttime, $sticky_type, $journalid, $delayedid );
+
+    $self->journal->do( "UPDATE delayedblob2 SET request_stor=?" . 
+                        "WHERE journalid=? AND delayedid=?", undef, 
+                        $data_ser, $journalid, $delayedid );
+    $self->{data} = $req;
+
+    my $memcache_key = "delayed_entry:$journalid:$delayedid";
+    LJ::MemCache::set($memcache_key, $data_ser, 3600);
 }
 
+sub convert {
+    my ($self) = @_;
+    my $req = $self->{data};
+    
+    my $flags = { 'noauth' => 1,
+                  'use_custom_time' => 0, 
+                  'u' => $self->poster };
+
+    my $err = 0;
+    my $res = LJ::Protocol::do_request("postevent", $req, \$err, $flags);
+    my $fail = !defined $res->{itemid} && $res->{message};
+    
+    return { 'delete_entry' => (!$fail || $err < 500), 
+             'res' => $res };
+}
+
+sub convert_from_data {
+    my ($self, $req) = @_;
+    my $flags = { 'noauth' => 1,
+                  'use_custom_time' => 0,
+                  'u' => $self->poster };
+
+    my $err = 0;
+    my $res = LJ::Protocol::do_request("postevent", $req, \$err, $flags);
+    my $fail = !defined $res->{itemid} && $res->{message};
+    if ($fail) {
+        $self->update($req);
+    }
+    return { 'delete_entry' => (!$fail || $err < 500), 
+             'res' => $res };
+}
+
+sub delete {
+    my ($self) = @_;
+    __assert( $self->{delayed_id}, "no delayed id" );
+    __assert( $self->{journal}, "no journal" );
+
+    my $journal = $self->{journal};
+    my $journalid = $journal->userid;
+    my $delayed_id = $self->{delayed_id};
+
+    $journal->do( "DELETE FROM delayedlog2 " .
+                  "WHERE delayedid = $delayed_id AND " .
+                  "journalid = " . $journalid);
+
+    $journal->do( "DELETE FROM delayedblob2 " .
+                  "WHERE delayedid = $delayed_id AND " .
+                  "journalid = " . $journalid);
+
+    $self->{delayed_id} = undef;
+    $self->{journal}    = undef;
+    $self->{poster}     = undef;
+    $self->{data}       = undef;
+
+    my $memcache_key    = "delayed_entry:$journalid:$delayed_id";
+    LJ::MemCache::delete($memcache_key);
+}
+
 sub delayedid {
     my ($self) = @_;
     return $self->{delayed_id};
@@ -155,8 +282,13 @@
 }
 
 sub timezone {
+    my $remote = LJ::get_remote();
+    return $remote->prop("timezone");
+}
+
+sub post_timezone {
     my ($self) = @_;
-    return $self->data->{'tz'}
+    return $self->data->{'tz'};
 }
 
 sub logtime {
@@ -181,7 +313,6 @@
     return $dt->epoch;
 }
 
-
 sub posttime {
     my ($self, $u) = @_;
     my $posttime = $self->system_posttime;
@@ -201,6 +332,16 @@
                                                $dt->minute );
 }
 
+sub eventtime_mysql {
+    my ($self) = @_;
+    return $self->posttime;
+}
+
+sub logtime_mysql {
+    my ($self) = @_;
+    return $self->system_posttime;
+}
+
 sub alldatepart {
     my ($self, $style) = @_;
     my $mysql_time = $self->posttime;
@@ -236,25 +377,11 @@
     return $self->data->{security};
 }
 
-sub mood {
-    my ($self) = @_;
-    #warn "TODO: add mood";
-    return 0;
-}
-
 sub props {
     my ($self) = @_;
     return $self->data->{props};
 }
 
-sub is_future_date {
-    my ($req) = @_;
-    my $now = __get_now();
-    my $request_time = __get_datetime($req);
-
-    return $request_time ge $now;
-}
-
 sub visible_to {
     my ($self, $remote, $opts) = @_;
     return 0 unless $self->valid;
@@ -282,17 +409,17 @@
                 }
             }
         }
-        
+
         # can't see suspended entries
         return 0 if $self->is_suspended_for($remote);
-    }   
-            
+    }
+
     # public is okay
     return 1 if $self->security eq "public";
-    
+
     # must be logged in otherwise
     return 0 unless $remote;
-        
+
     my $userid   = int($self->journalid);
     my $remoteid = int($remote->userid);
 
@@ -376,46 +503,11 @@
     return 1;
 }
 
-sub get_suspended_mark {
-    return 0;
-} 
-
 sub should_show_suspend_msg_to {
     my ( $self, $u ) = @_;
     return $self->is_suspended && !$self->is_suspended_for($u) ? 1 : 0;
 }
 
-sub is_delayed {
-    return 1;
-}
-
-# no anum for delayed entries
-sub correct_anum {
-    my ($self) = @_;
-    return 0;
-}
-
-sub anum {
-    my ($self) = @_;
-    return 0;
-}
-
-# no ditemid
-sub ditemid {
-    my ($self) = @_;
-    return 0;
-}
-
-# no jitemid
-sub jitemid {
-    my ($self) = @_;
-    return 0;
-}
-
-sub group_names {
-    return undef;
-}
-
 # returns a LJ::Userpic object for this post, or undef
 # currently this is for the permalink view, not for the friends view
 # context.  TODO: add a context option for friends page, and perhaps
@@ -440,37 +532,6 @@
     return $up->userpic;
 }
 
-# for delayed entry always false
-sub comments_shown {
-    my ($self) = @_;
-    return 0;
-}
-
-sub posting_comments_allowed {
-    my ($self) = @_;
-    return 0;
-}
-
-sub everyone_can_comment {
-    my ($self) = @_;
-    return 0;
-}
-
-sub registered_can_comment {
-    my ($self) = @_;
-    return 0;
-}
-
-sub friends_can_comment {
-    my ($self) = @_;
-    return 0;
-}
-
-sub tag_map {
-    my ($self) = @_;
-    return {};
-}
-
 sub subject_html {
     my ($self) = @_;
     my $subject = $self->subject;
@@ -485,101 +546,6 @@
     return $subject;
 }
 
-# instance method.  returns HTML-cleaned/formatted version of the event
-# optional $opt may be:
-#    undef:   loads the opt_preformatted key and uses that for formatting options
-#    1:       treats entry as preformatted (no breaks applied)
-#    0:       treats entry as normal (newlines convert to HTML breaks)
-#    hashref: passed to LJ::CleanHTML::clean_event verbatim
-sub event_html
-{
-    my ($self, $opts) = @_;
-
-    if (! defined $opts) {
-        $opts = {};
-    } elsif (! ref $opts) {
-        $opts = { preformatted => $opts };
-    }
-
-    unless ( exists $opts->{'preformatted'} ) {
-        $opts->{'preformatted'} = $self->prop('opt_preformatted');
-    }
-
-    my $remote = LJ::get_remote();
-    my $suspend_msg = $self->should_show_suspend_msg_to($remote) ? 1 : 0;
-    $opts->{suspend_msg} = $suspend_msg;
-    $opts->{unsuspend_supportid} = $suspend_msg ? $self->prop("unsuspend_supportid") : 0;
-
-    if($opts->{no_cut_expand}) {
-        $opts->{expand_cut} = 0;
-        $opts->{cuturl} = $self->prop('reposted_from') || $self->url . '?page=' . $opts->{page} . '&cut_expand=1';
-    } elsif (!$opts->{cuturl}) {
-        $opts->{expand_cut} = 1;
-        $opts->{cuturl}     = $self->prop('reposted_from') || $self->url;
-    }
-
-    $opts->{journalid} = $self->journalid;
-    $opts->{posterid} = $self->posterid;
-    $opts->{entry_url} = $self->prop('reposted_from') || $self->url;
-
-    my $event = $self->event;
-    LJ::CleanHTML::clean_event(\$event, $opts);
-
-    #LJ::expand_embedded($self->journal, $self->ditemid, LJ::User->remote, \$event);
-    return $event;
-}
-
-sub verticals_list {
-    my ($self) = @_;
-
-    my $verticals_list = $self->prop("verticals_list");
-    return () unless $verticals_list;
-
-    my @verticals = split(/\s*,\s*/, $verticals_list);
-    return @verticals ? @verticals : ();
-}
-
-sub eventtime_mysql {
-    my ($self) = @_;
-    return $self->posttime;
-}
-
-sub logtime_mysql {
-    my ($self) = @_;
-    return $self->system_posttime;
-}
-
-sub verticals_list_for_ad {
-    my ($self) = @_;
-
-    my @verticals = $self->verticals_list;
-    my @verticals_for_ad;
-    if (@verticals) {
-        foreach my $vertname (@verticals) {
-            my $vertical = LJ::Vertical->load_by_name($vertname);
-            next unless $vertical;
-
-            push @verticals_for_ad, $vertical->ad_name;
-        }
-    }
-
-    # remove parent verticals if any of their subverticals are in the list
-    my %vertical_in_list = map { $_ => 1 } @verticals_for_ad;
-    foreach my $vertname (@verticals_for_ad) {
-        my $vertical = LJ::Vertical->load_by_name($vertname);
-        next unless $vertical;
-
-        foreach my $child ($vertical->children) {
-            if ($vertical_in_list{$child->ad_name}) {
-                delete $vertical_in_list{$vertical->ad_name};
-            }
-        }
-    }
-    @verticals_for_ad = keys %vertical_in_list;
-
-    return @verticals_for_ad ? @verticals_for_ad : ();
-}
-
 sub tags {
     my ($self) = @_;
     return @{$self->{taglist}};
@@ -597,61 +563,6 @@
     return $result;
 }
 
-# raw utf8 text, with no HTML cleaning
-sub subject_raw {
-    my ($self) = @_;
-    return $self->subject;
-}
-
-sub event_raw {
-    my ($self) = @_;
-    return $self->event;
-}
-
-sub is_public {
-    my ($self) = @_;
-    return 0;
-}
-
-sub delete {
-    my ($self) = @_;
-    __assert( $self->{delayed_id}, "no delayed id" );
-    __assert( $self->{journal}, "no journal" );
-
-    my $journal = $self->{journal};
-    my $journalid = $journal->userid;
-    my $delayed_id = $self->{delayed_id};
-
-    $journal->do( "DELETE FROM delayedlog2 " .
-                  "WHERE delayedid = $delayed_id AND " .
-                  "journalid = " . $journalid);
-
-    $journal->do( "DELETE FROM delayedblob2 " .
-                  "WHERE delayedid = $delayed_id AND " .
-                  "journalid = " . $journalid);
-
-    $self->{delayed_id} = undef;
-    $self->{journal}    = undef;
-    $self->{poster}     = undef;
-    $self->{data}       = undef;
-    
-    my $memcache_key    = "delayed_entry:$journalid:$delayed_id";
-    LJ::MemCache::delete($memcache_key);
-}
-
-sub comments_manageable_by {
-    my ($self, $remote) = @_;
-    return 0 unless $remote;
-
-    my $u = $self->{journal};
-
-    return
-        $remote->userid == $u->userid ||
-        $remote->userid == $self->posterid ||
-        $remote->can_manage($u) ||
-        $remote->can_sweep($u);
-}
-
 sub should_block_robots {
     my ($self) = @_;
     return 1 if $self->journal->prop('opt_blockrobots');
@@ -665,72 +576,7 @@
     return 0;
 }
 
-sub update {
-    my ($self, $req) = @_;
-    __assert( $self->{delayed_id}, "no delayed id" );
-    __assert( $self->{journal}, "no journal" );
-    __assert( $self->{poster}, "no poster" );
 
-    $req->{tz} = $req->{tz} || $self->data->{tz};
-
-    my $journalid = $self->journal->userid;
-    my $posterid  = $self->poster->userid;
-    my $subject   = $req->{subject};
-    my $posttime  = __get_datetime($req);
-    my $delayedid = $self->{delayed_id};
-    my $dbh       = LJ::get_db_writer();
-    my $data_ser  = __serialize($req);
-
-    my $security  = "public";
-    my $uselogsec = 0;
-
-    if ($req->{'security'} eq "usemask" || $req->{'security'} eq "private") {
-        $security = $req->{'security'};
-    }
-
-    if ($req->{'security'} eq "usemask") {
-        $uselogsec = 1;
-    }
-
-    my $now = time();
-    my $dt = DateTime->new(   year       => $req->{year},
-                              month      => $req->{mon},
-                              day        => $req->{day},
-                              hour       => $req->{hour},
-                              minute     => $req->{min},
-                              time_zone  => $req->{tz} );
-    
-    my $utime       = $dt->epoch;
-
-    my $allowmask   = $req->{'allowmask'}+0;
-    my $rlogtime    = $LJ::EndOfTime - $now;
-    my $rposttime   = $LJ::EndOfTime - $utime;
-    my $sticky_type = $req->{sticky} ? 1 : 0;   
- 
-    $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=?, " .
-                        "subject=?, posttime = ?, " . 
-                        "security=?, allowmask=?, " .    
-                        "year=?, month=?, day=?, " .
-                        "rlogtime=?, revptime=?, is_sticky=? " .
-                        "WHERE journalid=? AND delayedid=?",
-                        undef, 
-                        $posterid, LJ::text_trim($req->{'subject'}, 30, 0), 
-                        $posttime, $security, $allowmask, 
-                        $req->{year}, $req->{mon}, $req->{day},
-                        $rlogtime, $rposttime, $sticky_type, $journalid, $delayedid );
-
-    $self->journal->do( "UPDATE delayedblob2 SET request_stor=?" . 
-                        "WHERE journalid=? AND delayedid=?", undef, 
-                        $data_ser, $journalid, $delayedid );
-    $self->{data} = $req;
-
-    my $memcache_key = "delayed_entry:$journalid:$delayedid";
-    LJ::MemCache::set($memcache_key, $data_ser, 3600);
-}   
-
 sub update_tags {
     my ($self, $tags) = @_;
     $self->props->{taglist} = $tags;
@@ -881,8 +727,8 @@
         or die "get cluster for journal failed";
 
     my ($delayeds) =  $dbcr->selectcol_arrayref("SELECT delayedid " .
-                                              "FROM delayedlog2 WHERE journalid=$journalid AND posterid = $userid ".
-                                              "LIMIT 1");    
+                                                "FROM delayedlog2 WHERE journalid=$journalid AND posterid = $userid ".
+                                                "LIMIT 1");    
     return @$delayeds;
 }
 
@@ -1020,194 +866,6 @@
     return $id || 0;
 }
 
-
-sub get_daycount_query {
-    my ($class, $journal, $list, $secwhere) = @_;
-    my $dbcr = LJ::get_cluster_def_reader($journal);
-
-    my $remote = LJ::get_remote();
-    return undef unless $remote;
-    my $sql_poster = '';
-    if (! __delayed_entry_can_see( $journal, $remote ) ) {
-        $sql_poster = 'AND posterid = ' . $remote->userid . " ";
-    }
-
-    my $sth = $dbcr->prepare("SELECT year, month, day, COUNT(*) " .
-                             "FROM delayedlog2 WHERE journalid=? $sql_poster $secwhere GROUP BY 1, 2, 3");
-    $sth->execute($journal->userid);
-    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 {
-    my ( $class, $journal, $year, $month, $day ) = @_;
-    my $entries = [];
-
-    my $remote = LJ::get_remote();
-    return undef unless $remote;
-    return undef unless __delayed_entry_can_see( $journal,
-                                                 $remote );
-
-    my $secwhere = __delayed_entry_secwhere( $journal,
-                                             $journal->userid,
-                                             $remote->userid );
-
-    my $dbcr = LJ::get_cluster_def_reader($journal) 
-        or die "get cluster for journal failed";
-
-    my $jouralid = $journal->userid;
-    return $dbcr->selectcol_arrayref("SELECT delayedid ".
-                            "FROM delayedlog2 ".
-                            "WHERE journalid=$jouralid " .
-                            "AND year=$year AND month=$month AND day=$day ".
-                            "$secwhere LIMIT 2000");
-}
-
-sub get_entries_for_day {
-    my ($class, $journal, $year, $month, $day, $dateformat) = @_;
-    my $entries = [];
-
-    my $remote = LJ::get_remote();
-    return undef unless $remote;
-    return undef unless __delayed_entry_can_see( $journal,
-                                                 $remote );
-
-    my $secwhere = __delayed_entry_secwhere( $journal,
-                                             $journal->userid,
-                                             $remote->userid );
-
-    my $dbcr = LJ::get_cluster_def_reader($journal) 
-        or die "get cluster for journal failed";
-
-    $dbcr = $dbcr->prepare("SELECT l.delayedid, l.posterid, l.day, ".
-                            "DATE_FORMAT(l.posttime, '$dateformat') AS 'alldatepart', ".
-                            "l.security, l.allowmask ".
-                            "FROM delayedlog2 l ".
-                            "WHERE l.journalid=? AND l.year=? AND l.month=? AND day=?".
-                            "$secwhere LIMIT 2000");
-    $dbcr->execute($journal->userid, $year, $month, $day);
-
-    my @items;
-    push @items, $_ while $_ = $dbcr->fetchrow_hashref;
-    return @items;
-}
-
-sub getevents {
-    my ( $self, $req, $flags, $err, $res ) = @_;
-
-    return 0 if $req->{itemid};
-    $flags->{allow_anonymous} = 1;
-    return 0 unless LJ::Protocol::authenticate($req, $err, $flags);
-
-    $flags->{'ignorecanuse'} = 1; # later we will check security levels, so allow some access to communities
-    return 0 unless LJ::Protocol::check_altusage($req, $err, $flags);
-
-    my $u = $flags->{'u'};
-    my $uowner = $flags->{'u_owner'} || $u;
-
-    ### shared-journal support
-    my $userid = ($u ? $u->{'userid'} : 0);
-    my $ownerid = $flags->{'ownerid'};
-    if( $req->{journalid} ){
-        $ownerid = $req->{journalid};
-        $uowner = LJ::load_userid( $req->{journalid} );
-    }
-
-    my $limit = $req->{howmany} || 0;
-    my $skip = $req->{'skip'} || 0;
-    if ($skip > 500) { $skip = 500; }
-    
-    my $dbcr = LJ::get_cluster_def_reader($uowner) 
-        or die "get cluster for journal failed";
-
-    my $sql_limit = '';
-    if ($skip || $limit) {
-        $sql_limit = "LIMIT $skip, $limit";
-    }
-
-    my $date_limit = '';
-    if ($req->{year}) {
-        $date_limit .= "AND year = " . $req->{year} . " ";
-    }
-
-    if ($req->{month}) {
-        $date_limit .= "AND month = " . $req->{month} . " ";
-    }
-
-    if ($req->{day}) {
-        $date_limit .= "AND day = " . $req->{day} . " ";
-    }
-
-    return undef unless __delayed_entry_can_see( $uowner,
-                                                 $u );
-
-    my $secwhere = __delayed_entry_secwhere( $uowner,
-                                             $ownerid,
-                                             $userid );
-
-    my $entriesids =  $dbcr->selectcol_arrayref("SELECT delayedid " .
-                                                "FROM delayedlog2 WHERE journalid=$ownerid $secwhere $date_limit ".
-                                                "ORDER BY revptime $sql_limit");
-
-    my $i = 0;
-    my @results = [];
-    foreach my $delayedid (@$entriesids) {
-        my $entry_obj = LJ::DelayedEntry->get_entry_by_id(  $u,
-                                                            $delayedid,
-                                                            { userid => $userid } );
-        next unless $entry_obj;
-        ++$i;
-        $res->{"events_${i}_itemid"} = 0;
-        $res->{"events_${i}_delayedid"} = $delayedid;
-        $res->{"events_${i}_poster"} = $entry_obj->poster;
-        $res->{"events_${i}_subject"} = $entry_obj->subject;
-        $res->{"events_${i}_event"} = $entry_obj->event;
-        $res->{"events_${i}_allowmask"} = $entry_obj->allowmask;
-        $res->{"events_${i}_security"} = $entry_obj->security;
-        $res->{"events_${i}_eventtime"} = $entry_obj->posttime;
-        $res->{"events_${i}_itemid"} = $entry_obj->jitemid;
-        $res->{"events_${i}_anum"} = $entry_obj->correct_anum;
-        $res->{"events_${i}_sticky"} = $entry_obj->is_sticky;
-    }
-
-    $res->{'events_count'}  = $i;
-    $res->{'success'} = 'OK';
-
-    return $i;
-}
-
-sub get_entries_for_month {
-    my ($class, $journal, $year, $month, $dateformat) = @_;
-    my $entries = [];
-    
-    my $remote = LJ::get_remote();
-
-    return undef unless $remote;
-    return undef unless __delayed_entry_can_see( $journal,
-                                                 $remote );
-    
-    my $secwhere = __delayed_entry_secwhere( $journal,
-                                             $journal->userid,
-                                             $remote->userid );
-    
-    my $dbcr = LJ::get_cluster_def_reader($journal) 
-                            or die "get cluster for journal failed";
-    
-    $dbcr = $dbcr->prepare("SELECT l.delayedid, l.posterid, l.day, ".
-                          "DATE_FORMAT(l.posttime, '$dateformat') AS 'alldatepart', ".
-                          "l.security, l.allowmask ".
-                          "FROM delayedlog2 l ".
-                          "WHERE l.journalid=? AND l.year=? AND l.month=? ".
-                          "$secwhere LIMIT 2000");
-
-    $dbcr->execute($journal->userid, $year, $month);
-
-    my @items;
-    push @items, $_ while $_ = $dbcr->fetchrow_hashref;
-    return @items;
-}
-
 sub get_itemid_after2  {
     return get_itemid_near2(@_, "after");
 }
@@ -1237,7 +895,7 @@
         warn "Can't connect to cluster reader. Cluster: " . $u->clusterid;
         return 0;
     }
-    
+
     my ($stime, $is_current_sticky) = $dbr->selectrow_array( "SELECT revptime, is_sticky FROM delayedlog2 WHERE ".
                                         "journalid=$jid AND delayedid=$delayedid");
     return 0 unless $stime;
@@ -1259,7 +917,7 @@
             if ($new_stime < $stime) {
                 $stime = $new_stime;
             }
- 
+
             $sql_item_rule = "(revptime $cmp1 ? )";
         } else {
             $sql_item_rule = "(revptime $cmp1 ? AND is_sticky = 0 )";
@@ -1276,49 +934,11 @@
     return $result_ref->[0];
 }
 
-sub handle_prefetched_props {
-    my ($self) = @_;
-    #stab
-    return;
-}
-
 sub can_delete_delayed_item {
     my ($class, $u, $usejournal_u) = @_;
     return LJ::can_delete_journal_item($u, $usejournal_u);
 }
 
-sub convert {
-    my ($self) = @_;
-    my $req = $self->{data};
-    
-    my $flags = { 'noauth' => 1,
-                  'use_custom_time' => 0, 
-                  'u' => $self->poster };
-
-    my $err = 0;
-    my $res = LJ::Protocol::do_request("postevent", $req, \$err, $flags);
-    my $fail = !defined $res->{itemid} && $res->{message};
-    
-    return { 'delete_entry' => (!$fail || $err < 500), 
-             'res' => $res };
-}
-
-sub convert_from_data {
-    my ($self, $req) = @_;
-    my $flags = { 'noauth' => 1,
-                  'use_custom_time' => 0,
-                  'u' => $self->poster };
-
-    my $err = 0;
-    my $res = LJ::Protocol::do_request("postevent", $req, \$err, $flags);
-    my $fail = !defined $res->{itemid} && $res->{message};
-    if ($fail) {
-        $self->update($req);
-    }
-    return { 'delete_entry' => (!$fail || $err < 500), 
-             'res' => $res };
-}
-
 sub can_post_to {
     my ($uowner, $poster) = @_;
     
@@ -1329,7 +949,7 @@
     my $moderated = $uowner->prop('moderated') || '';
     my $need_moderated = ( $moderated =~ /^[1A]$/ ) ? 1 : 0;
     my $can_post = ($uowner->is_community() && !$need_moderated) || $can_manage;
-   
+
     if ($can_post) {
         return 1;
     }
@@ -1477,7 +1097,6 @@
 
     LJ::MemCache::incr($stat_key, 1) ||
         (LJ::MemCache::add($stat_key, 0),  LJ::MemCache::incr($stat_key, 1));
-
 }
 
 sub __serialize {
@@ -1501,17 +1120,6 @@
     return LJ::JSON->from_json( $req );
 }
 
-sub __get_now {
-    my $dt = DateTime->now->set_time_zone('UTC');
-
-    # make the proper date format
-    return sprintf("%04d-%02d-%02d %02d:%02d",  $dt->year, 
-                                                $dt->month,
-                                                $dt->day, 
-                                                $dt->hour,
-                                                $dt->minute );
-}
-
 sub __get_datetime {
     my ($req, $dont_use_tz) = @_;
     __assert($req, "No request");
@@ -1547,4 +1155,3 @@
 }
 
 1;
-

Modified: trunk/cgi-bin/LJ/Widget/EntryChooser.pm
===================================================================
--- trunk/cgi-bin/LJ/Widget/EntryChooser.pm	2012-01-18 06:16:33 UTC (rev 20919)
+++ trunk/cgi-bin/LJ/Widget/EntryChooser.pm	2012-01-18 08:34:34 UTC (rev 20920)
@@ -5,7 +5,7 @@
 use base qw( LJ::Widget::Template );
 
 sub need_res {
-	qw(stc/widgets/entrychooser.css);
+    qw(stc/widgets/entrychooser.css);
 }
 
 sub template_filename {
@@ -31,7 +31,8 @@
             : '';
 
         my $entry_is_delayed = $entry->is_delayed;
-        my $entry_is_sticky  = $entry->is_sticky;
+        my $entry_is_sticky  = ($entry->is_sticky
+                                    && LJ::is_enabled('sticky_entries'));
 
         ### security indicator
         my $entry_security = 'public';
@@ -72,10 +73,11 @@
         my ($year, $mon, $mday, $hour, $min) = split(/\D/, $alldateparts);
         my $monthlong = BML::ml(LJ::Lang::month_long_langcode($mon));
 
-        my $date_display = "$monthlong $mday, $year, $hour:$min";
+        my $datetext = $entry->is_delayed ? BML::ml('.postpone.entry') : '';
+        my $date_display = "$datetext $monthlong $mday, $year, $hour:$min";
 
         my $entry_text_display =
-            LJ::ehtml( LJ::durl( $entry->event_raw ) );
+            LJ::ehtml( LJ::durl( $entry->event ) );
         $entry_text_display =~ s{\n}{<br />}g;
 
         my $entry_taglist = '';

Modified: trunk/htdocs/manage/scheduled_posts.bml
===================================================================
--- trunk/htdocs/manage/scheduled_posts.bml	2012-01-18 06:16:33 UTC (rev 20919)
+++ trunk/htdocs/manage/scheduled_posts.bml	2012-01-18 08:34:34 UTC (rev 20920)
@@ -30,7 +30,7 @@
     my $only_me_checked = $GET{'only_me'};
 
     my $remote = LJ::get_remote();
-    
+
     return "<?needlogin?>" unless $remote;
 
     if ($remote->underage) {
@@ -157,6 +157,19 @@
         $ret .= "<p><a href='$LJ::SITEROOT/manage/$page_name'>" . BML::ml('.lnk.journal') . "</a></p>";
     }
 
+    my $timezone = $remote->prop("timezone");
+    if ($timezone) {
+        $ret .= BML::ml('.date.your_time_zone');
+        $ret .= '<a href="http://www.ljdev16.livejournal.ru/manage/settings/?cat=display">(';
+        $ret .= $timezone;
+        $ret .= ')</a>';
+    } else {
+        $ret .= BML::ml('.date.gmt');
+        $ret .= '<a href="http://www.ljdev16.livejournal.ru/manage/settings/?cat=display">';
+        $ret .= BML::ml('.date.set_time_zone');
+        $ret .= '</a>';
+    }
+
     $ret .= $entry_chooser->( \@recent_entries,
                                 first_page   => $skip ? 0 : 1,
                                 prev         => $skip > $items_per_page ? $skip - $items_per_page : 0,

Modified: trunk/htdocs/manage/scheduled_posts.bml.text
===================================================================
--- trunk/htdocs/manage/scheduled_posts.bml.text	2012-01-18 06:16:33 UTC (rev 20919)
+++ trunk/htdocs/manage/scheduled_posts.bml.text	2012-01-18 08:34:34 UTC (rev 20920)
@@ -9,9 +9,17 @@
 
 .date.scheduled=Schedule for:
 
+.date.gmt=Date are displayed in the GMT format.
+
+.date.set_time_zone=Set your time zone now.
+
+.date.your_time_zone=Dates are displayed in your timezone 
+
 .btn.search=Search
 
 .input.journal=Show entries from community
 
 .newpost=New Sheduled Entry
 
+.postpone.entry=Postponed to 
+

Modified: trunk/templates/Widgets/entry_chooser.tmpl
===================================================================
--- trunk/templates/Widgets/entry_chooser.tmpl	2012-01-18 06:16:33 UTC (rev 20919)
+++ trunk/templates/Widgets/entry_chooser.tmpl	2012-01-18 08:34:34 UTC (rev 20920)
@@ -1,37 +1,37 @@
 <TMPL_IF expr="link_prev || link_next">
-    <p class='i-qotd-nav'>
-        <TMPL_IF link_prev>
-            <a class='i-qotd-nav-prev' href='<TMPL_VAR link_prev>'>prev</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>
-        </TMPL_IF>
+	<p class='i-qotd-nav'>
+		<TMPL_IF link_prev>
+			<a class='i-qotd-nav-prev' href='<TMPL_VAR link_prev>'>prev</a>
+		<TMPL_ELSE>
+			<span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>
+		</TMPL_IF>
 
-        <TMPL_IF link_next>
-            <a class='i-qotd-nav-next' href='<TMPL_VAR link_next>'>next</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>
-        </TMPL_IF>
-    </p>
+		<TMPL_IF link_next>
+			<a class='i-qotd-nav-next' href='<TMPL_VAR link_next>'>next</a>
+		<TMPL_ELSE>
+			<span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>
+		</TMPL_IF>
+	</p>
 </TMPL_IF>
 
 <TMPL_UNLESS entries>
-    <p class='i-bubble b-bubble-warning b-bubble-noarrow'><TMPL_VAR expr="ml('/editjournal.bml.no_entries_to_edit')"></p>
+	<p class='i-bubble b-bubble-warning b-bubble-noarrow'><TMPL_VAR expr="ml('/editjournal.bml.no_entries_to_edit')"></p>
 </TMPL_UNLESS>
 
 <TMPL_IF entries>
-    <ul class='b-editentries'>
-        <TMPL_LOOP entries>
-            <li class='b-editentry'>
+	<ul class='b-editentries'>
+		<TMPL_LOOP entries>
+			<li class='b-editentry'>
 
-                <p class='b-editentry-ctrls'>
-                    <TMPL_IF entry_can_edit>
-                        <a href='<TMPL_VAR edit_link ESCAPE=HTML>' class='b-editentry-edit-btn b-editentry-ctrl-btn'></a>
-                    <TMPL_ELSE>
-                        <a href='<TMPL_VAR delete_link ESCAPE=HTML>' class='b-editentry-del-btn b-editentry-ctrl-btn'></a>
-                    </TMPL_IF>
-                </p>
+				<p class='b-editentry-ctrls'>
+					<TMPL_IF entry_can_edit>
+						<a href='<TMPL_VAR edit_link ESCAPE=HTML>' class='b-editentry-edit-btn b-editentry-ctrl-btn'></a>
+					<TMPL_ELSE>
+						<a href='<TMPL_VAR delete_link ESCAPE=HTML>' class='b-editentry-del-btn b-editentry-ctrl-btn'></a>
+					</TMPL_IF>
+				</p>
 
-                <h2>
+				<h2>
 					<TMPL_IF entry_is_delayed>
 						<img src="<TMPL_VAR lj_imgprefix>/icon_delayed.png?v=11043" width=13 height=15 align=absmiddle class="i-posticon">
 					</TMPL_IF>
@@ -56,45 +56,45 @@
 					</a>
 				</h2>
 
-                <p class='date'>
-                    <TMPL_VAR poster_ljuser>
-                    <TMPL_VAR date_display>
-                </p>
+				<p class='date'>
+					<TMPL_VAR poster_ljuser>
+					<TMPL_VAR date_display>
+				</p>
 
-                <TMPL_VAR entry_text_display>
+				<TMPL_VAR entry_text_display>
 
-                <TMPL_IF entry_taglist>
-                    <p>
-                        <b>Tags:</b>
-                        <TMPL_VAR entry_taglist ESCAPE=HTML>
-                    </p>
-                </TMPL_IF>
-            </li>
-        </TMPL_LOOP>
-    </ul>
+				<TMPL_IF entry_taglist>
+					<p>
+						<b>Tags:</b>
+						<TMPL_VAR entry_taglist ESCAPE=HTML>
+					</p>
+				</TMPL_IF>
+			</li>
+		</TMPL_LOOP>
+	</ul>
 
-    <TMPL_IF adhtml>
-        <td valign='top'><TMPL_VAR adhtml></td>
-    </TMPL_IF>
+	<TMPL_IF adhtml>
+		<td valign='top'><TMPL_VAR adhtml></td>
+	</TMPL_IF>
 </TMPL_IF>
 
 <TMPL_UNLESS entries>
-    <td valign='top'><TMPL_VAR adhtml></td>
+	<td valign='top'><TMPL_VAR adhtml></td>
 </TMPL_UNLESS>
 
 <TMPL_IF expr="link_prev || link_next">
-    <p class='i-qotd-nav'>
-        <TMPL_IF link_prev>
-            <a class='i-qotd-nav-prev' href='<TMPL_VAR link_prev>'>prev</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>
-        </TMPL_IF>
+	<p class='i-qotd-nav'>
+		<TMPL_IF link_prev>
+			<a class='i-qotd-nav-prev' href='<TMPL_VAR link_prev>'>prev</a>
+		<TMPL_ELSE>
+			<span class='i-qotd-nav-prev i-qotd-nav-prev-dis'>prev</span>
+		</TMPL_IF>
 
-        <TMPL_IF link_next>
-            <a class='i-qotd-nav-next' href='<TMPL_VAR link_next>'>next</a>
-        <TMPL_ELSE>
-            <span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>
-        </TMPL_IF>
-    </p>
+		<TMPL_IF link_next>
+			<a class='i-qotd-nav-next' href='<TMPL_VAR link_next>'>next</a>
+		<TMPL_ELSE>
+			<span class='i-qotd-nav-next i-qotd-nav-next-dis'>next</span>
+		</TMPL_IF>
+	</p>
 </TMPL_IF>
 

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