madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r20598: LJSUP-10439: Service page for delayed en...

Committer: sbelyaev
LJSUP-10439: Service page for delayed entries
U   trunk/cgi-bin/LJ/DelayedEntry.pm
A   trunk/htdocs/manage/edit_scheduled_entries.bml
A   trunk/htdocs/manage/edit_scheduled_entries.bml.text
Modified: trunk/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- trunk/cgi-bin/LJ/DelayedEntry.pm	2011-11-22 10:33:21 UTC (rev 20597)
+++ trunk/cgi-bin/LJ/DelayedEntry.pm	2011-11-22 10:38:40 UTC (rev 20598)
@@ -916,33 +916,37 @@
 }
 
 sub get_entries_by_journal {
-    my ( $class, $journal, $skip, $elements_to_show, $userid ) = @_;
+    my ( $class, $journal, $opts ) = @_;
     __assert($journal, "no journal");
 
+    my $skip   = $opts->{'skip'} || 0;
+    my $show   = $opts->{'show'} || 0;
+    my $userid = $opts->{'userid'};
+    my $only_my = $opts->{'only_my'};
+    
+
     my $dbcr = LJ::get_cluster_def_reader($journal) 
         or die "get cluster for journal failed";
 
-    my $sql_poster = '';
+    my $u;
+
     unless ($userid) {
-        my $remote = LJ::get_remote();
-        return undef unless $remote;
-        
-        $userid = $remote->userid ;
-        if (!__delayed_entry_can_see( $journal, $remote ) ) {
-            $sql_poster = 'AND posterid = ' . $remote->userid . " ";
-        }
+        $u = LJ::get_remote();
     } else {
-        my $u = LJ::want_user($userid);
-        if (!__delayed_entry_can_see( $journal, $u ) ){
-            $sql_poster = 'AND posterid = ' . $u->userid . " ";
-        }
+        $u = LJ::want_user($userid);      
     }
 
-    $elements_to_show += 1 if $skip > 0;
+    return [] unless $u;
+    $userid = $u->userid;
+   
+    my $sql_poster = ''; 
+    if ( !__delayed_entry_can_see( $journal, $u ) || $only_my ) {
+        $sql_poster = 'AND posterid = ' . $u->userid . " ";
+    }
 
     my $sql_limit = '';
-    if ($skip || $elements_to_show) {
-        $sql_limit = "LIMIT $skip, $elements_to_show";
+    if ($skip || $show) {
+        $sql_limit = "LIMIT $skip, $show";
     }
 
     my $journalid = $journal->userid;

Added: trunk/htdocs/manage/edit_scheduled_entries.bml
===================================================================
--- trunk/htdocs/manage/edit_scheduled_entries.bml	                        (rev 0)
+++ trunk/htdocs/manage/edit_scheduled_entries.bml	2011-11-22 10:38:40 UTC (rev 20598)
@@ -0,0 +1,159 @@
+<?page
+title=><?_ML .title _ML?>
+windowtitle=><?_ML .title _ML?>
+body<=
+<?_code
+{
+#line 7
+
+    LJ::need_res(qw(
+                    stc/entry.css
+                    stc/editjournal.css
+                    stc/widgets/selecttags.css
+                    js/inputcomplete.js
+                    js/jquery/jquery.ui.position.min.js
+                    js/jquery/jquery.ui.autocomplete.min.js
+                    js/jquery/jquery.bgiframe.js
+                    js/gears_init.js
+                    js/scanner.js
+                    js/photobucket_jw.js
+                    ));
+
+
+    my $page_name = 'edit_scheduled_entries.bml';
+    my $items_per_page = 20;
+    my $skip = $GET{'skip'} || 0;
+    my $usejournal = $GET{'usejournal'};
+    my $only_me_checked = $GET{'only_me'};
+
+    my $remote = LJ::get_remote();
+    
+    return "<?needlogin?>" unless $remote;
+
+    if ($remote->underage) {
+        return BML::redirect("$LJ::SITEROOT/agecheck/?s=1");
+    }
+
+    my $usejournal_u = LJ::load_user ($usejournal || $remote->user);
+
+    my $entry_chooser = sub {
+        my $ref = shift;
+        my %opts = @_;
+
+        my @res = @$ref;
+        my $show_ad = $opts{show_ad} ? 1 : 0;
+
+        my ( $link_prev, $link_next );
+        my $is_first_page = $opts{'first_page'};
+
+        if ($opts{'prev'} || $opts{'next'} || !$is_first_page ) {
+            if ( $opts{'prev'} || !$is_first_page ) {
+                $link_prev = "$LJ::SITEROOT/$page_name$getextra" .
+                             ($getextra ? "&" : "?") .
+                             "skip=$opts{prev}";
+            }
+
+            if ($opts{'next'}) {
+                $link_next = "$LJ::SITEROOT/$page_name$getextra" .
+                             ($getextra ? "&" : "?") .
+                             "skip=$opts{next}";
+            }
+        }
+
+        my @entries;
+
+        my $journal = LJ::load_user($usejournal) || $remote;
+        foreach my $e_raw (@res) {
+            if ( $e_raw->{'delayedid'} ) {
+                push @entries,
+                    $e_raw->{'delayed_obj'};
+            }
+        }
+
+        my $adhtml = '';
+        if ($show_ad) {
+            $adhtml = LJ::get_ads(
+                { 'location' => 'bml.editjournal', 'ljadwrapper' => 1 } );
+        }
+
+        return LJ::Widget::EntryChooser->render(
+            'link_prev'    => $link_prev,
+            'link_next'    => $link_next,
+            'show_posters' => $usejournal ? 1 : 0,
+            'entries'      => \@entries,
+            'adhtml'       => $adhtml,
+            'scheduled'    => BML::ml('.date.scheduled'),
+        );
+    };
+
+    my $append_delayed = sub {
+        my ($u, $delayed_entries) = @_;
+        my @ordered;
+
+        foreach my $ditem (@$delayed_entries) {
+            my $entry = LJ::DelayedEntry->get_entry_by_id($u, $ditem);
+
+            push @ordered, {
+                            '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,
+                           };
+        }
+        
+        return @ordered;
+    };
+
+
+    my $delayed_entries = LJ::DelayedEntry->get_entries_by_journal($usejournal_u,
+                                                                   { 'skip'    => $skip,
+                                                                     'show'    => $items_per_page + 1,
+                                                                     'only_my' => $only_me_checked, });
+
+    my $have_next_page =  scalar @$delayed_entries > $items_per_page;
+    my @recent_entries = $append_delayed->($usejournal_u, $delayed_entries);
+
+
+    # draw the page
+
+    $ret .= "<table style='width: 100%;'><tr><td>";
+
+    # header
+    $ret .= "<div class='b-editentries-header'>";
+    $ret .= "<h1>" . BML::ml('.title') . "</h1>";
+
+    $ret .= "<form action='$page_name$getextra' method='get' class='b-editentries-form'>\n";
+    $ret .= "<p>" . LJ::html_text({ 'name'        => 'usejournal', 
+                                    'size'        => '20', 
+                                    'mfaxlength'  => '15', 
+                                    'value'       => $GET{'usejournal'} || $POST{'usejournal'}, 
+                                    'class'       => 'b-editentries-comm', 
+                                    'placeholder' => BML::ml('.input.journal') });
+
+    $ret .= LJ::html_submit(undef, $ML{'.btn.search'}) . "</p>";
+    $ret .= "<p>" . LJ::html_check({ 'name'     => 'only_me', 
+                                     'id'       => 'only_me',
+                                     'value'    => '1', 
+                                     'selected' =>  $only_me_checked });
+
+    $ret .= "<label for='only_me'>".$ML{'.only_my_entries'}."</label></p>";
+    $ret .= "</form>\n";
+    $ret .= "<a href='$LJ::SITEROOT/$page_name'>" . BML::ml('.lnk.journal') . "</a>";
+
+    $ret .= $entry_chooser->(\@recent_entries,
+                                first_page   => $skip ? 0 : 1,
+                                prev         => $skip > $items_per_page ? $skip - $items_per_page : 0,
+                                next         => $have_next_page         ? $skip + $items_per_page : 0);
+
+    return $ret;    
+}
+_code?>
+<=body
+page?>

Added: trunk/htdocs/manage/edit_scheduled_entries.bml.text
===================================================================
--- trunk/htdocs/manage/edit_scheduled_entries.bml.text	                        (rev 0)
+++ trunk/htdocs/manage/edit_scheduled_entries.bml.text	2011-11-22 10:38:40 UTC (rev 20598)
@@ -0,0 +1,15 @@
+;; -*- coding: utf-8 -*-
+.title=Edit Scheduled Entries
+
+.show_entries=Scheduled Entries
+
+.only_my_entries=Only My Entries 
+
+.lnk.journal=Back to My Journal Scheduled Entries
+
+.date.scheduled=Schedule for:
+
+.btn.search=Search
+
+.input.journal=Show entries from community
+


Property changes on: trunk/htdocs/manage/edit_scheduled_entries.bml.text
___________________________________________________________________
Added: svn:executable
   + *

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