[Slashdotjp-dev 312] CVS update: slashjp/plugins/Journal

アーカイブの一覧に戻る

Taku YASUI tach****@users*****
2005年 11月 18日 (金) 01:01:04 JST


Index: slashjp/plugins/Journal/Journal.pm
diff -u slashjp/plugins/Journal/Journal.pm:1.2 slashjp/plugins/Journal/Journal.pm:1.3
--- slashjp/plugins/Journal/Journal.pm:1.2	Tue Dec 21 18:28:52 2004
+++ slashjp/plugins/Journal/Journal.pm	Fri Nov 18 01:01:04 2005
@@ -1,7 +1,7 @@
 # This code is a part of Slash, and is released under the GPL.
 # Copyright 1997-2003 by Open Source Development Network. See README
 # and COPYING for more information, or see http://slashcode.com/.
-# $Id: Journal.pm,v 1.2 2004/12/21 09:28:52 oliver Exp $
+# $Id: Journal.pm,v 1.3 2005/11/17 16:01:04 tach Exp $
 
 package Slash::Journal;
 
@@ -15,7 +15,7 @@
 use base 'Exporter';
 use base 'Slash::DB::MySQL';
 
-($VERSION) = ' $Revision: 1.2 $ ' =~ /\$Revision:\s+([^\s]+)/;
+($VERSION) = ' $Revision: 1.3 $ ' =~ /\$Revision:\s+([^\s]+)/;
 
 # On a side note, I am not sure if I liked the way I named the methods either.
 # -Brian
@@ -145,6 +145,7 @@
 	my($date) = $self->sqlSelect('date', 'journals', "id=$id");
 	my $slashdb = getCurrentDB();
 	$slashdb->setUser($uid, { journal_last_entry_date => $date });
+	$self->updateUsersJournal($uid);
 
 	return $id;
 }
@@ -177,9 +178,33 @@
 	}
 	my $slashdb = getCurrentDB();
 	$slashdb->setUser($uid, { -journal_last_entry_date => $date });
+	$self->updateUsersJournal($uid);
+
 	return $count;
 }
 
+sub updateUsersJournal {
+	my ($self, $uid) = @_;
+
+	my $count = $self->sqlCount("journals", "uid=$uid");
+	my $jid = $self->sqlSelect("MAX(id)", "journals", "uid=$uid");
+	my $date = $self->sqlSelect("date", "journals", "id=$jid");
+	if ($self->sqlUpdate("users_journal",
+			     { count => $count,
+			       jid => $jid,
+			       date => $date },
+			     "uid=$uid") < 1) {
+		if ($self->sqlInsert("users_journal",
+				     { uid => $uid,
+				       jid => $jid,
+				       count => $count,
+				       date => $date }) < 1) {
+			return 0;
+		}
+	}
+	return 1;
+}
+
 sub top {
 	my($self, $limit) = @_;
 	$limit ||= getCurrentStatic('journal_top') || 10;


Slashdotjp-dev メーリングリストの案内
アーカイブの一覧に戻る