madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20934: LJSUP-10439: Updated service page for de...

Committer: sbelyaev
LJSUP-10439: Updated service page for delayed entries. Now preview page is used to show delayed entry.
U   trunk/cgi-bin/ljprotocol.pl
U   trunk/htdocs/editjournal.bml
U   trunk/htdocs/manage/scheduled_posts.bml
U   trunk/htdocs/preview/entry.bml
Modified: trunk/cgi-bin/ljprotocol.pl
===================================================================
--- trunk/cgi-bin/ljprotocol.pl	2012-01-19 12:01:11 UTC (rev 20933)
+++ trunk/cgi-bin/ljprotocol.pl	2012-01-19 12:59:38 UTC (rev 20934)
@@ -2369,6 +2369,7 @@
             return fail($err, 507) unless $entry;
             $res->{delayedid} = $entry->delayedid;
             $res->{type}      = 'delayed';
+
             return $res;
         }
         else {
@@ -2879,31 +2880,9 @@
                 return $res;
             }
 
-
             # updating an entry:
             return undef
                 unless common_event_validation($req, $err, $flags);
-
-            if ( LJ::DelayedEntry::is_future_date($req) ) {
-                $entry->update($req);
-                $res->{type} = 'delayed';   
-                $res->{delayedid} = $delayedid;
-            } else {
-                my $out = $entry->convert_from_data($req);
-
-                if ( $out->{delete_entry} ) {
-                    $entry->delete();
-                }
-
-                $res->{type}   = 'posted';
-                $res->{itemid} = $out->{res}->{itemid};
-                $res->{anum}   = $out->{res}->{anum};
-                $res->{'ditemid'} = $out->{res}->{itemid} * 256 + $out->{res}->{anum};
-
-                $res->{'url'} = LJ::item_link(  $uowner,
-                                                $res->{itemid},
-                                                $res->{anum} );
-            }
         }
 
         return $res if $res->{type};

Modified: trunk/htdocs/editjournal.bml
===================================================================
--- trunk/htdocs/editjournal.bml	2012-01-19 12:01:11 UTC (rev 20933)
+++ trunk/htdocs/editjournal.bml	2012-01-19 12:59:38 UTC (rev 20934)
@@ -258,9 +258,9 @@
                 $res{'events_1_allowmask'} = $entry_obj->allowmask;
                 $res{'events_1_security'} = $entry_obj->security;            
                 $res{'events_1_eventtime'} = $entry_obj->posttime;
-                $res{'events_1_'} = $entry_obj->mood;
-                $res{'events_1_itemid'} = $entry_obj->jitemid;
-                $res{'events_1_anum'} = $entry_obj->correct_anum;
+                $res{'events_1_'} = $entry_obj->prop("current_mood");
+                $res{'events_1_itemid'} = 0; # has no itemid
+                $res{'events_1_anum'} = 0;# has no anum
                 
                 my @prop_keys = keys %{$entry_obj->props};
                 $res{'prop_count'} = scalar @prop_keys; 
@@ -342,7 +342,6 @@
                             'itemid'     => $itemid,
                             'delayedid'  => $delayedid,
                             'sticky'     => $sticky,
-                            'custom_time' => $custom_time,
                             );
                 LJ::entry_form_decode(\%req, \%POST);
 

Modified: trunk/htdocs/manage/scheduled_posts.bml
===================================================================
--- trunk/htdocs/manage/scheduled_posts.bml	2012-01-19 12:01:11 UTC (rev 20933)
+++ trunk/htdocs/manage/scheduled_posts.bml	2012-01-19 12:59:38 UTC (rev 20934)
@@ -1,6 +1,28 @@
 <?page
 title=><?_code return $title; _code?>
 windowtitle=><?_ML .title _ML?>
+head<=
+<script type="text/javascript">
+function showEntry(delayedId) {
+    preview = window.open('', 'preview', 'width=760,height=600,resizable=yes,status=yes,toolbar=no,location=no,menubar=no,scrollbars=yes');
+    preview.document.writeln("<html><body></body></html>");
+    entryForm = preview.document.createElement("form");
+    entryForm.method = 'POST';
+    entryForm.action = '/preview/entry.bml';
+    
+    newInput = preview.document.createElement("input");
+    newInput.name = "delayed_id";
+    newInput.value = delayedId;
+    newInput.type = 'hidden';
+    entryForm.appendChild(newInput);
+    preview.document.getElementsByTagName('body')[0].appendChild(entryForm);
+    entryForm.submit();
+    return false;
+}
+
+</script>
+
+<=head
 body<=
 <?_code
 {
@@ -97,17 +119,17 @@
             my $entry = LJ::DelayedEntry->get_entry_by_id($u, $ditem);
 
             push @ordered, {
-                            'alldatepart' => $entry->alldatepart ,
+                            'alldatepart'        => $entry->alldatepart ,
                             'system_alldatepart' => $entry->system_alldatepart,
-                            'allowmask'   => $entry->allowmask,
-                            'posterid'    => $entry->posterid,
-                            'eventtime'   => $entry->posttime,
-                            'security'    => $entry->security,
-                            'logtime'     => $entry->logtime,
-                            'delayed_obj' => $entry,
-                            'delayedid'   => $ditem,
-                            'itemid'      => 0,
-                            'anum'        => 0,
+                            'allowmask'          => $entry->allowmask,
+                            'posterid'           => $entry->posterid,
+                            'eventtime'          => $entry->posttime,
+                            'security'           => $entry->security,
+                            'logtime'            => $entry->logtime,
+                            'delayed_obj'        => $entry,
+                            'delayedid'          => $ditem,
+                            'use_js_function'
+                                => "javascript:showDelayedEntry($ditem);"
                            };
         }
         return @ordered;
@@ -152,7 +174,7 @@
 
     my $usejournal_text = $usejournal ? 'usejournal=mojo&' : '';
     $ret .= "<a href=\"/update.bml?${usejournal_text}type=scheduled\">";
-    $ret .= BML::ml('.newpost') . '</a>';
+    $ret .= BML::ml('.newpost') . '</a><br/>';
 
     if ( !$usejournal_u || $usejournal_u->is_community ) {
         $ret .= "<p><a href='$LJ::SITEROOT/manage/$page_name'>" . BML::ml('.lnk.journal') . "</a></p>";

Modified: trunk/htdocs/preview/entry.bml
===================================================================
--- trunk/htdocs/preview/entry.bml	2012-01-19 12:01:11 UTC (rev 20933)
+++ trunk/htdocs/preview/entry.bml	2012-01-19 12:59:38 UTC (rev 20934)
@@ -6,7 +6,7 @@
     my $ret;
     my $remote = LJ::get_remote();
     my $styleid; my $stylesys = 1;
-   
+
     ## This header is to pass page content through IE8 XSS Filter.
     ## Use-case: 
     ##  (1) gazeta.ru has POST form with destination http://www.livejournal.com/preview/entry.bml
@@ -29,12 +29,27 @@
     $up = $u unless $up;
 
     return $ML{'.error.no_user'} unless $up and $u;
+    my $delayed_id = $POST{'delayed_id'};
+    my $sticky = $POST{'sticky_type'} && LJ::is_enabled('sticky_entries');
 
     ### Set up preview variables
     my ($ditemid, $anum, $itemid);
     my %req = ( 'usejournal' => $POST{'usejournal'}, );
-    LJ::entry_form_decode(\%req, \%POST);
 
+    my $delayed_obj; 
+    if (!$delayed_id) {
+        LJ::entry_form_decode(\%req, \%POST);
+    } else {
+        $delayed_obj
+            = LJ::DelayedEntry->get_entry_by_id($remote, $delayed_id);
+
+        if (!$delayed_obj) {
+            return "unknown error";
+        }
+
+        %req = %{$delayed_obj->data};
+    }
+
     my ($event, $subject) = ($req{'event'}, $req{'subject'});
     LJ::CleanHTML::clean_subject(\$subject);
 
@@ -265,7 +280,7 @@
 
         my $custom_time = $POST{'custom_time'} || $GET{'custom_time'};
         my $timezone = $POST{'timezone'} || $GET{'timezone'};
-        $req{'tz'} =  sprintf("%+.4d", $timezone); 
+        $req{'tz'} =  sprintf("%+.4d", $timezone);
 
         my $s2entry = LJ::S2::Entry($u, {
             'subject' => $subject,
@@ -283,8 +298,8 @@
             'tags' => \@taglist,
             'userpic' => $userpic,
             'permalink_url' => "#",
-            'sticky_type' =>  $POST{'sticky_type'} || $GET{'sticky_type'},
-            'delayed' => $custom_time ?  LJ::DelayedEntry::is_future_date(\%req) : 0,
+            'sticky_type' =>  $sticky,
+            'delayed' => $delayed_obj,
             '_preview' => 1,
          }); 
     

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