summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Discussions.pm
diff options
context:
space:
mode:
author3dB <3db@3decibels.net>2009-08-04 01:03:29 -0400
committer3dB <3db@3decibels.net>2009-08-04 01:03:29 -0400
commit8bfbcc91073690d4847ea6ca783c9d839c3ffcb6 (patch)
tree587e9595e0676f587acbd233948796bef6a37914 /lib/VNDB/DB/Discussions.pm
parenta130a4f79e04f8a6ccd4514b9a1d0285c63edfea (diff)
Implemented double-post prevention
-- Created a subroutine to check for any recent posts made by a user -- Added double-post checking and error messages to the form handler & html generator
Diffstat (limited to 'lib/VNDB/DB/Discussions.pm')
-rw-r--r--lib/VNDB/DB/Discussions.pm22
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index 58cc5f61..eed1b2f9 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -5,7 +5,7 @@ use strict;
use warnings;
use Exporter 'import';
-our @EXPORT = qw|dbThreadGet dbThreadEdit dbThreadAdd dbPostGet dbPostEdit dbPostAdd dbThreadCount|;
+our @EXPORT = qw|dbThreadGet dbThreadEdit dbThreadAdd dbPostGet dbPostEdit dbPostAdd dbThreadCount dbPostCheckDouble|;
# Options: id, type, iid, results, page, what, notusers
@@ -241,5 +241,25 @@ 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;