[Slashdotjp-dev 1492] [1023] Add getJournalByDiscussion() and createJournalUrl() on plugins/ Journal/Journal.pm

Back to archive index

svnno****@sourc***** svnno****@sourc*****
2009年 2月 20日 (金) 20:23:20 JST


Revision: 1023
          http://svn.sourceforge.jp/view?root=slashdotjp&view=rev&rev=1023
Author:   tach
Date:     2009-02-20 20:23:20 +0900 (Fri, 20 Feb 2009)

Log Message:
-----------
Add getJournalByDiscussion() and createJournalUrl() on plugins/Journal/Journal.pm

Modified Paths:
--------------
    slashjp/trunk/Slash/Utility/Comments/Comments.pm
    slashjp/trunk/debian/changelog


-------------- next part --------------
Modified: slashjp/trunk/Slash/Utility/Comments/Comments.pm
===================================================================
--- slashjp/trunk/Slash/Utility/Comments/Comments.pm	2009-02-20 09:03:40 UTC (rev 1022)
+++ slashjp/trunk/Slash/Utility/Comments/Comments.pm	2009-02-20 11:23:20 UTC (rev 1023)
@@ -2638,19 +2638,37 @@
 	my ($discussion, $options) = @_;
 	my $constants = getCurrentStatic();
 	my $reader = getObject('Slash::DB', { db_type => 'reader' });
-	my $stories = {};
+	my $stories = { 'prev' => {}, 'next' => {} };
 	my $ret = '';
 
 	return $ret if (!$discussion || ref($discussion) ne "HASH");
 
 	my $sid = $reader->getStorySidFromDiscussion($discussion->{id});
-	if ($sid) {
+	my $kinds = $reader->getDescriptions('discussion_kinds');
+	my $kind = $kinds->{ $discussion->{dkid} };
+print STDERR "kind = $kind\n";
+
+	if ($kind =~ /story$/ && $sid) {
 		my $story = $reader->getStory($sid);
+		$stories->{kinds} = "story";
 		if ($constants->{use_prev_next_link}) {
 			$stories->{prev} = $reader->getStoryByTime('<', $story);
 			$stories->{next} = $reader->getStoryByTime('>', $story) unless $story->{is_future};
 		}
+	} elsif ($kind eq "journal") {
+		my $journal_reader = getObject("Slash::Journal");
+		my $journal = $journal_reader->getJournalByDiscussion($discussion->{id});
+		if (my $prev = $journal_reader->getJournalByTime('<', [ $journal->{date} ], { uid => $journal->{uid} })) {
+use Data::Dumper; print STDERR Dumper($prev);
+			$stories->{prev}->{title} = $prev->{desctiption};
+			$stories->{prev}->{url} = $journal_reader->createJournalUrl($prev);
+		}
+		if (my $next = $journal_reader->getJournalByTime('>', [ $journal->{date} ], { uid => $journal->{uid} })) {
+			$stories->{next}->{title} = $next->{desctiption};
+			$stories->{next}->{url} = $journal_reader->createJournalUrl($next);
+		}
 	}
+use Data::Dumper; print STDERR Dumper($stories);
 
 	$ret = slashDisplay('printCommentsSuffix', {
 		stories	=> $stories,

Modified: slashjp/trunk/debian/changelog
===================================================================
--- slashjp/trunk/debian/changelog	2009-02-20 09:03:40 UTC (rev 1022)
+++ slashjp/trunk/debian/changelog	2009-02-20 11:23:20 UTC (rev 1023)
@@ -13,8 +13,10 @@
   * Fix: add fhid for submission to submission_param table
   * Make to fetch fhid on getSubmissionsByUID()
   * Fix: yourPendingSubs system
+  * Add getJournalByDiscussion() and createJournalUrl() on
+    plugins/Journal/Journal.pm
 
- -- Taku YASUI <tach****@osdn*****>  Thu, 19 Feb 2009 10:25:10 +0000
+ -- Taku YASUI <tach****@osdn*****>  Fri, 20 Feb 2009 11:21:53 +0000
 
 slash (2.5.0.233-4) unstable; urgency=low
 



Slashdotjp-dev メーリングリストの案内
Back to archive index