summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author3dB <3db@3decibels.net>2009-08-05 18:23:10 -0400
committer3dB <3db@3decibels.net>2009-08-05 18:23:10 -0400
commitfebecb5992b042d3de20e4f30a537b61a4800031 (patch)
treeb85c152178be0ec20b779a0d72c25d1b943ce119
parent8bfbcc91073690d4847ea6ca783c9d839c3ffcb6 (diff)
Reworked double post checking to use existing code
-- Removed dbPostCheckDouble -- Added more filters to dbPostGet to serve similar purpose
-rw-r--r--lib/VNDB/DB/Discussions.pm24
-rw-r--r--lib/VNDB/Handler/Discussions.pm3
2 files changed, 5 insertions, 22 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index eed1b2f9..6e09e0ad 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -153,7 +153,7 @@ sub dbThreadCount {
}
-# Options: tid, num, what, order, uid, hide, page, results
+# Options: tid, num, what, order, uid, date >, hide, page, results
# what: user thread
sub dbPostGet {
my($self, %o) = @_;
@@ -169,6 +169,8 @@ sub dbPostGet {
'tp.num = ?' => $o{num} ) : (),
$o{uid} ? (
'tp.uid = ?' => $o{uid} ) : (),
+ $o{date} ? (
+ 'tp.date > ?' => $o{date} ) : (),
$o{hide} ? (
'tp.hidden = FALSE' => 1 ) : (),
$o{hide} && $o{what} =~ /thread/ ? (
@@ -241,25 +243,5 @@ sub dbPostAdd {
}
-# Checks if a user has recently made a post in a particular thread
-# If tid is omitted or equal to zero, check if user has made a recent post at all
-# uid, tid (optional)
-sub dbPostCheckDouble {
- my($self, @o) = @_;
-
- my $time = time - 30; # 30 Seconds
- my $r;
- if (defined $o[1] && $o[1] ne 0) {
- $r = $self->dbRow('SELECT COUNT(num) FROM threads_posts WHERE uid = ? AND tid = ? AND date > ? LIMIT 1',
- @o, $time);
- } else {
- $r = $self->dbRow('SELECT COUNT(num) FROM threads_posts WHERE uid = ? AND date > ? LIMIT 1',
- $o[0], $time);
- }
-
- return $r->{count}||0;
-}
-
-
1;
diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm
index dce8dcde..ae0961d8 100644
--- a/lib/VNDB/Handler/Discussions.pm
+++ b/lib/VNDB/Handler/Discussions.pm
@@ -167,7 +167,8 @@ sub edit {
);
# check for double-posting
- push @{$frm->{_err}}, 'doublepost' if $self->dbPostCheckDouble($self->{_auth}{id}, $tid);
+ push @{$frm->{_err}}, 'doublepost' if $self->dbPostGet(
+ uid => $self->authInfo->{id}, tid => $tid || '', date => time - 30, results=> 1)->[0]->{num};
# parse and validate the boards
my @boards;