summaryrefslogtreecommitdiff
path: root/lib/VNDB/DB/Discussions.pm
diff options
context:
space:
mode:
Diffstat (limited to 'lib/VNDB/DB/Discussions.pm')
-rw-r--r--lib/VNDB/DB/Discussions.pm58
1 files changed, 30 insertions, 28 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index 1e626c57..b28bfeab 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -9,7 +9,7 @@ our @EXPORT = qw|dbThreadGet dbThreadEdit dbThreadAdd dbPostGet dbPostEdit dbPos
# Options: id, type, iid, results, page, what
-# What: tags, tagtitles, firstpost, lastpost
+# What: boards, boardtitles, firstpost, lastpost
sub dbThreadGet {
my($self, %o) = @_;
$o{results} ||= 50;
@@ -23,9 +23,9 @@ sub dbThreadGet {
!$o{id} ? (
't.hidden = FALSE' => 0 ) : (),
$o{type} && !$o{iid} ? (
- 't.id IN(SELECT tid FROM threads_tags WHERE type = ?)' => $o{type} ) : (),
+ 't.id IN(SELECT tid FROM threads_boards WHERE type = ?)' => $o{type} ) : (),
$o{type} && $o{iid} ? (
- 'tt.type = ?' => $o{type}, 'tt.iid = ?' => $o{iid} ) : (),
+ 'tb.type = ?' => $o{type}, 'tb.iid = ?' => $o{iid} ) : (),
);
my @select = (
@@ -44,7 +44,7 @@ sub dbThreadGet {
'JOIN users ul ON ul.id = tpl.uid'
) : (),
$o{type} && $o{iid} ?
- 'JOIN threads_tags tt ON tt.tid = t.id' : (),
+ 'JOIN threads_boards tb ON tb.tid = t.id' : (),
);
my($r, $np) = $self->dbPage(\%o, q|
@@ -56,30 +56,30 @@ sub dbThreadGet {
join(', ', @select), join(' ', @join), \%where, $o{order}
);
- if($o{what} =~ /(tags|tagtitles)/ && $#$r >= 0) {
+ if($o{what} =~ /(boards|boardtitles)/ && $#$r >= 0) {
my %r = map {
- $r->[$_]{tags} = [];
+ $r->[$_]{boards} = [];
($r->[$_]{id}, $_)
} 0..$#$r;
- if($o{what} =~ /tags/) {
- ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, [ $_->{type}, $_->{iid} ]) for (@{$self->dbAll(q|
+ if($o{what} =~ /boards/) {
+ ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{boards}}, [ $_->{type}, $_->{iid} ]) for (@{$self->dbAll(q|
SELECT tid, type, iid
- FROM threads_tags
+ FROM threads_boards
WHERE tid IN(!l)|,
[ keys %r ]
)});
}
- if($o{what} =~ /tagtitles/) {
- ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{tags}}, $_) for (@{$self->dbAll(q|
- SELECT tt.tid, tt.type, tt.iid, COALESCE(u.username, vr.title, pr.name) AS title, COALESCE(u.username, vr.original, pr.original) AS original
- FROM threads_tags tt
- LEFT JOIN vn v ON tt.type = 'v' AND v.id = tt.iid
+ if($o{what} =~ /boardtitles/) {
+ ($_->{type}=~s/ +//||1) && push(@{$r->[$r{$_->{tid}}]{boards}}, $_) for (@{$self->dbAll(q|
+ SELECT tb.tid, tb.type, tb.iid, COALESCE(u.username, vr.title, pr.name) AS title, COALESCE(u.username, vr.original, pr.original) AS original
+ FROM threads_boards tb
+ LEFT JOIN vn v ON tb.type = 'v' AND v.id = tb.iid
LEFT JOIN vn_rev vr ON vr.id = v.latest
- LEFT JOIN producers p ON tt.type = 'p' AND p.id = tt.iid
+ LEFT JOIN producers p ON tb.type = 'p' AND p.id = tb.iid
LEFT JOIN producers_rev pr ON pr.id = p.latest
- LEFT JOIN users u ON tt.type = 'u' AND u.id = tt.iid
- WHERE tt.tid IN(!l)|,
+ LEFT JOIN users u ON tb.type = 'u' AND u.id = tb.iid
+ WHERE tb.tid IN(!l)|,
[ keys %r ]
)});
}
@@ -89,7 +89,7 @@ sub dbThreadGet {
}
-# id, %options->( title locked hidden tags }
+# id, %options->( title locked hidden boards }
sub dbThreadEdit {
my($self, $id, %o) = @_;
@@ -105,18 +105,18 @@ sub dbThreadEdit {
WHERE id = ?|,
\%set, $id);
- if($o{tags}) {
- $self->dbExec('DELETE FROM threads_tags WHERE tid = ?', $id);
+ if($o{boards}) {
+ $self->dbExec('DELETE FROM threads_boards WHERE tid = ?', $id);
$self->dbExec(q|
- INSERT INTO threads_tags (tid, type, iid)
+ INSERT INTO threads_boards (tid, type, iid)
VALUES (?, ?, ?)|,
$id, $_->[0], $_->[1]||0
- ) for (@{$o{tags}});
+ ) for (@{$o{boards}});
}
}
-# %options->{ title hidden locked tags }
+# %options->{ title hidden locked boards }
sub dbThreadAdd {
my($self, %o) = @_;
@@ -128,23 +128,25 @@ sub dbThreadAdd {
)->{id};
$self->dbExec(q|
- INSERT INTO threads_tags (tid, type, iid)
+ INSERT INTO threads_boards (tid, type, iid)
VALUES (?, ?, ?)|,
$id, $_->[0], $_->[1]||0
- ) for (@{$o{tags}});
+ ) for (@{$o{boards}});
return $id;
}
-# Returns thread count of a specific item tag
+# Returns thread count of a specific item board
# Arguments: type, iid
sub dbThreadCount {
my($self, $type, $iid) = @_;
return $self->dbRow(q|
SELECT COUNT(*) AS cnt
- FROM threads_tags
- WHERE type = ? AND iid = ?|,
+ FROM threads_boards tb
+ JOIN threads t ON t.id = tb.tid
+ WHERE tb.type = ? AND tb.iid = ?
+ AND t.hidden = FALSE|,
$type, $iid)->{cnt};
}