summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2009-07-07 13:28:53 +0200
committerYorhel <git@yorhel.nl>2009-07-07 13:28:53 +0200
commitc281835ad2b538c6e1afbd3a4bffe440c011b51c (patch)
tree9b656d43e1f79bc272c0f2fd504f202bf366f809 /lib
parent087b1697606292d945524af4f84ba5899749409e (diff)
Display thread count in user menu
This adds a small performance penalty, but should make it a lot easier for people to notice that someone is asking for his/her attention. Ideally, this count would be the number of *unread* *posts*, rather than *total* number of *threads*, but we don't store read the state (yet).
Diffstat (limited to 'lib')
-rw-r--r--lib/VNDB/DB/Users.pm4
-rw-r--r--lib/VNDB/Util/Auth.pm2
-rw-r--r--lib/VNDB/Util/LayoutHTML.pm2
3 files changed, 5 insertions, 3 deletions
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index 49b56823..d5cdcc6c 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -9,7 +9,7 @@ our @EXPORT = qw|dbUserGet dbUserEdit dbUserAdd dbUserDel|;
# %options->{ username passwd mail order uid ip registered search results page what }
-# what: stats
+# what: stats mymessages
sub dbUserGet {
my $s = shift;
my %o = (
@@ -54,6 +54,8 @@ sub dbUserGet {
'(SELECT COUNT(DISTINCT tag) FROM tags_vn WHERE uid = u.id) AS tagcount',
'(SELECT COUNT(DISTINCT vid) FROM tags_vn WHERE uid = u.id) AS tagvncount',
) : (),
+ $o{what} =~ /mymessages/ ?
+ '(SELECT COUNT(*) FROM threads_boards tb JOIN threads t ON t.id = tb.tid WHERE tb.type = \'u\' AND tb.iid = u.id AND t.hidden = FALSE) AS mymessages' : (),
);
my($r, $np) = $s->dbPage(\%o, q|
diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm
index b520eeba..cb0751e9 100644
--- a/lib/VNDB/Util/Auth.pm
+++ b/lib/VNDB/Util/Auth.pm
@@ -84,7 +84,7 @@ sub _authCheck {
!$user || length($user) > 15 || length($user) < 2
|| !$pass || length($pass) != 32;
- my $d = $self->dbUserGet(username => $user, passwd => $pass)->[0];
+ my $d = $self->dbUserGet(username => $user, passwd => $pass, what => 'mymessages')->[0];
return 0 if !defined $d->{id} || !$d->{rank};
$self->{_auth} = $d;
diff --git a/lib/VNDB/Util/LayoutHTML.pm b/lib/VNDB/Util/LayoutHTML.pm
index 1e6d8a60..2cf3fc40 100644
--- a/lib/VNDB/Util/LayoutHTML.pm
+++ b/lib/VNDB/Util/LayoutHTML.pm
@@ -87,7 +87,7 @@ sub _menu {
a href => "$uid/edit", 'My Profile'; br;
a href => "$uid/list", 'My Visual Novel List'; br;
a href => "$uid/wish", 'My Wishlist'; br;
- a href => "/t$uid", 'My Messages'; br;
+ a href => "/t$uid", sprintf 'My Messages (%d)', $self->authInfo->{mymessages}; br;
a href => "$uid/hist", 'My Recent Changes'; br;
a href => "$uid/tags", 'My Tags'; br;
br;