svnno****@sourc*****
svnno****@sourc*****
2009年 2月 23日 (月) 17:35:49 JST
Revision: 1031 http://svn.sourceforge.jp/view?root=slashdotjp&view=rev&rev=1031 Author: tach Date: 2009-02-23 17:35:49 +0900 (Mon, 23 Feb 2009) Log Message: ----------- * Add getDiscussionByTime() to Slash/DB/MySQL/MySQL.pm to get next/prev discussions * Change printCommentSuffix() to add suffix for submission comments Modified Paths: -------------- slashjp/trunk/Slash/DB/MySQL/MySQL.pm slashjp/trunk/Slash/Utility/Comments/Comments.pm slashjp/trunk/debian/changelog -------------- next part -------------- Modified: slashjp/trunk/Slash/DB/MySQL/MySQL.pm =================================================================== --- slashjp/trunk/Slash/DB/MySQL/MySQL.pm 2009-02-23 06:46:55 UTC (rev 1030) +++ slashjp/trunk/Slash/DB/MySQL/MySQL.pm 2009-02-23 08:35:49 UTC (rev 1031) @@ -12936,6 +12936,37 @@ } +sub getDiscussionByTime { + my ($self, $sign, $discussion, $options) = @_; + my $constants = getCurrentStatic(); + $options = {} if !$options || ref($options) ne 'HASH'; + my $uid = int($options->{uid}) || undef; + my $dkid = int($options->{dkid}) || undef; + my $where = ''; + my $order = $sign eq '<' ? 'DESC' : 'ASC'; + + if (ref($discussion) ne 'HASH') { + $discussion = $self->getDiscussion(int($discussion)); + } + + if ($uid) { + $where .= " AND uid=$uid"; + } + + if ($dkid) { + $where .= " AND dkid=$dkid"; + } + + return $self->sqlSelectHashref( + '*', + 'discussions', + "ts $sign '$discussion->{ts}' + AND ts <= NOW() + $where", + "ORDER BY ts $order LIMIT 1" + ); +} + ######################################################## sub DESTROY { my($self) = @_; Modified: slashjp/trunk/Slash/Utility/Comments/Comments.pm =================================================================== --- slashjp/trunk/Slash/Utility/Comments/Comments.pm 2009-02-23 06:46:55 UTC (rev 1030) +++ slashjp/trunk/Slash/Utility/Comments/Comments.pm 2009-02-23 08:35:49 UTC (rev 1031) @@ -2685,14 +2685,27 @@ $item->{up}->{url} = $journal_reader->createJournalUrl({ uid => $journal->{uid} }); push(@$stories, $item); } + + # submission + if ($kind eq "submission" && $constants->{plugin}{FireHose}) { + my $item = { 'prev' => {}, 'next' => {}, 'up' => {} }; + if (my $prev = $reader->getDiscussionByTime('<', $discussion, { dkid => $discussion->{dkid} })) { + $item->{prev} = { url => $prev->{url}, title => $prev->{title} }; + } + if (my $next = $reader->getDiscussionByTime('>', $discussion, { dkid => $discussion->{dkid} })) { + $item->{next} = { url => $next->{url}, title => $next->{title} }; + } + $item->{up}->{title} = Slash::getData('submissions', {}, 'misc'); + $item->{up}->{url} = "$constants->{rootdir}/firehose.pl?fhfilter=submission"; + push(@$stories, $item); + } + #use Data::Dumper; print STDERR Dumper($stories); # poll # feed - # submission - # project $ret = slashDisplay('printCommentsSuffix', { Modified: slashjp/trunk/debian/changelog =================================================================== --- slashjp/trunk/debian/changelog 2009-02-23 06:46:55 UTC (rev 1030) +++ slashjp/trunk/debian/changelog 2009-02-23 08:35:49 UTC (rev 1031) @@ -17,8 +17,10 @@ plugins/Journal/Journal.pm * Fix to return with uid on getJournalByTime() on plugins/Journal/Journal.pm * Print comments on the page of submission preview for Admin + * Add getDiscussionByTime() to Slash/DB/MySQL/MySQL.pm to get next/prev + discussions - -- Taku YASUI <tach****@osdn*****> Mon, 23 Feb 2009 06:45:47 +0000 + -- Taku YASUI <tach****@osdn*****> Mon, 23 Feb 2009 08:33:46 +0000 slash (2.5.0.233-4) unstable; urgency=low