madeon (madeon) wrote in changelog,
madeon
madeon
changelog

[livejournal] r19817: LJSUP-9307: Custom user added to get_ent...

Committer: sbelyaev
LJSUP-9307: Custom user added to get_entry_by_id, get_entries_by_journal.
U   branches/delayed_entries/cgi-bin/Apache/LiveJournal.pm
U   branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm
Modified: branches/delayed_entries/cgi-bin/Apache/LiveJournal.pm
===================================================================
--- branches/delayed_entries/cgi-bin/Apache/LiveJournal.pm	2011-08-23 11:31:29 UTC (rev 19816)
+++ branches/delayed_entries/cgi-bin/Apache/LiveJournal.pm	2011-08-24 02:58:43 UTC (rev 19817)
@@ -788,7 +788,8 @@
                 $mode = "entry";
             }
 
-        } elsif ($uuri =~ m|^/d(\d+)\.html$|)  { 
+        } elsif ($uuri =~ m|^/d(\d+)\.html$|)  {
+            my $delayedid = $1;
             my $u = LJ::load_user($user);
             
             unless ($u) {
@@ -797,7 +798,9 @@
                 return LJ::Request::NOT_FOUND;
             }
             
-            $ljentry = LJ::DelayedEntry->get_entry_by_id($u, $1, { 'dateformat' => 'S2'});
+            $ljentry = LJ::DelayedEntry->get_entry_by_id($u,
+                                                         $delayedid,
+                                                         { 'dateformat' => 'S2'});
             
             if ( $GET{'mode'} eq "reply" || $GET{'replyto'} || $GET{'edit'} ) {
                 $mode = "reply";

Modified: branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm
===================================================================
--- branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm	2011-08-23 11:31:29 UTC (rev 19816)
+++ branches/delayed_entries/cgi-bin/LJ/DelayedEntry.pm	2011-08-24 02:58:43 UTC (rev 19817)
@@ -615,12 +615,12 @@
 
 
 sub get_entry_by_id {
-    my ($class, $journal, $delayedid, $settings) = @_;
+    my ($class, $journal, $delayedid, $options) = @_;
     __assert($journal);
     return undef unless $delayedid;
 
     my $journalid = $journal->userid;
-    my $dateformat_type = $settings->{'dateformat'} || '';
+    my $dateformat_type = $options->{'dateformat'} || '';
     my $dbcr = LJ::get_cluster_def_reader($journal) 
         or die "get cluster for journal failed";
 
@@ -629,10 +629,10 @@
         $dateformat = "%Y %m %d %H %i %s %w"; # yyyy mm dd hh mm ss day_of_week
     }
 
-    my $userid = $settings->{userid} || 0;
-    my $remote = LJ::get_remote();
-    return undef unless $remote;
-    $userid = $remote->userid unless $userid;
+    my $userid = $options->{userid} || 0;
+    my $user = LJ::get_remote() || $options->{user};
+    return undef unless $user;
+    $userid = $user->userid unless $userid;
 
     return undef unless __delayed_entry_can_see( $journal,
                                                   $journal->userid,
@@ -714,7 +714,7 @@
 sub get_entries_by_journal {
     my ( $class, $journal, $skip, $elements_to_show, $userid ) = @_;
     __assert($journal);
-    my $journalid = $journal->userid;    
+    my $journalid = $journal->userid;
 
     my $dbcr = LJ::get_cluster_def_reader($journal) 
         or die "get cluster for journal failed";
@@ -723,9 +723,13 @@
     if ($skip || $elements_to_show) {
         $sql_limit = "LIMIT $skip, $elements_to_show";
     }
-    
-    $userid = LJ::get_remote()->userid unless $userid;
 
+    unless ($userid) {
+        my $remote = LJ::get_remote();
+        return undef unless $remote;
+        $userid = $remote->userid ;
+    }
+
     return undef unless __delayed_entry_can_see( $journal,
                                               $journal->userid,
                                               $userid );

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