summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Discussions.pm11
-rw-r--r--lib/VNDB/Handler/Users.pm2
2 files changed, 9 insertions, 4 deletions
diff --git a/lib/VNDB/DB/Discussions.pm b/lib/VNDB/DB/Discussions.pm
index deeb7480..1c27c22e 100644
--- a/lib/VNDB/DB/Discussions.pm
+++ b/lib/VNDB/DB/Discussions.pm
@@ -158,7 +158,7 @@ sub dbThreadCount {
}
-# Options: tid, num, what, uid, mindate, hide, page, results
+# Options: tid, num, what, uid, mindate, hide, page, results, sort, reverse
# what: user thread
sub dbPostGet {
my($self, %o) = @_;
@@ -191,13 +191,18 @@ sub dbPostGet {
$o{what} =~ /thread/ ? 'JOIN threads t ON t.id = tp.tid' : (),
);
+ my $order = sprintf {
+ num => 'tp.num %s',
+ date => 'tp.date %s',
+ }->{ $o{sort}||'num' }, $o{reverse} ? 'DESC' : 'ASC';
+
my($r, $np) = $self->dbPage(\%o, q|
SELECT !s
FROM threads_posts tp
!s
!W
- ORDER BY tp.num ASC|,
- join(', ', @select), join(' ', @join), \%where
+ ORDER BY !s|,
+ join(', ', @select), join(' ', @join), \%where, $order
);
return wantarray ? ($r, $np) : $r;
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index e9c97198..2cec8b52 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -364,7 +364,7 @@ sub posts {
{ name => 'p', required => 0, default => 1, template => 'int' }
);
- my($posts, $np) = $self->dbPostGet(uid => $uid, hide => 1, what => 'thread', page => $f->{p}, order => 'tp.date DESC');
+ my($posts, $np) = $self->dbPostGet(uid => $uid, hide => 1, what => 'thread', page => $f->{p}, sort => 'date', reverse => 1);
my $title = mt '_uposts_title', $u->{username};
$self->htmlHeader(title => $title, noindex => 1);