summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2019-07-12 14:56:18 +0200
committerYorhel <git@yorhel.nl>2019-07-12 14:56:18 +0200
commitd3c33f4e3db37caeea8118de094193064c7668cb (patch)
treeb8f793c505a88093615cc70adccf468a4a78d715
parent62a8a06dfef2ecf94dd9755b01216a14c9b1d886 (diff)
Display hidden users in VN vote listings, but hide their username/id
https://vndb.org/t950.119 - old request, but better late than never.
-rw-r--r--lib/VNDB/DB/ULists.pm12
-rw-r--r--lib/VNDB/Handler/ULists.pm11
-rw-r--r--lib/VNDB/Util/CommonHTML.pm5
3 files changed, 19 insertions, 9 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm
index e6a85ba0..f941dac5 100644
--- a/lib/VNDB/DB/ULists.pm
+++ b/lib/VNDB/DB/ULists.pm
@@ -172,8 +172,8 @@ sub dbRListDel {
}
-# Options: uid vid hide hide_ign results page what sort reverse
-# what: user, vn
+# Options: uid vid hide_ign results page what sort reverse
+# what: user, vn, hide_list
sub dbVoteGet {
my($self, %o) = @_;
$o{results} ||= 50;
@@ -185,7 +185,6 @@ sub dbVoteGet {
my %where = (
$o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (),
$o{vid} ? ( 'n.vid = ?' => $o{vid} ) : (),
- $o{hide} ? ( 'NOT EXISTS(SELECT 1 FROM users_prefs WHERE uid = n.uid AND key = \'hide_list\')' => 1 ) : (),
$o{hide_ign} ? ( '(NOT u.ign_votes OR u.id = ?)' => $self->authInfo->{id}||0 ) : (),
$o{vn_char} ? ( 'LOWER(SUBSTR(v.title, 1, 1)) = ?' => $o{vn_char} ) : (),
defined $o{vn_char} && !$o{vn_char} ? (
@@ -199,6 +198,7 @@ sub dbVoteGet {
qw|n.vid n.vote n.uid|, q|extract('epoch' from n.date) as date|,
$o{what} =~ /user/ ? ('u.username') : (),
$o{what} =~ /vn/ ? (qw|v.title v.original|) : (),
+ $o{what} =~ /hide_list/ ? ('up.uid as hide_list') : (),
);
my @join = (
@@ -208,11 +208,15 @@ sub dbVoteGet {
$o{what} =~ /user/ || $o{hide} ? (
'JOIN users u ON u.id = n.uid'
) : (),
+ $o{what} =~ /hide_list/ ? (
+ 'LEFT JOIN users_prefs up ON up.uid = n.uid AND key = \'hide_list\''
+ ) : (),
);
my $order = sprintf {
date => 'n.date %s',
- username => 'u.username %s',
+ # Hidden users should not be sorted among the rest. as that would still give them away
+ username => $o{what} =~ /hide_list/ ? '(CASE WHEN up.uid IS NULL THEN u.username ELSE NULL END) %s, n.date' : 'u.username %s',
title => 'v.title %s',
vote => 'n.vote %s'.($o{what} =~ /vn/ ? ', v.title ASC' : $o{what} =~ /user/ ? ', u.username ASC' : ''),
}->{$o{sort}}, $o{reverse} ? 'DESC' : 'ASC';
diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm
index 5b4ea901..10687533 100644
--- a/lib/VNDB/Handler/ULists.pm
+++ b/lib/VNDB/Handler/ULists.pm
@@ -145,8 +145,7 @@ sub votelist {
my($list, $np) = $self->dbVoteGet(
$type.'id' => $id,
- what => $type eq 'v' ? 'user' : 'vn',
- hide => $type eq 'v',
+ what => $type eq 'v' ? 'user hide_list' : 'vn',
hide_ign => $type eq 'v',
sort => $f->{s} eq 'title' && $type eq 'v' ? 'username' : $f->{s},
reverse => $f->{o} eq 'd',
@@ -194,7 +193,13 @@ sub votelist {
end;
td class => 'tc2', fmtvote $l->{vote};
td class => 'tc3';
- a href => $type eq 'v' ? ("/u$l->{uid}", $l->{username}) : ("/v$l->{vid}", shorten $l->{title}, 100);
+ if($type eq 'u') {
+ a href => "/v$l->{vid}", title => $l->{original}||$l->{title}, shorten $l->{title}, 100;
+ } elsif($l->{hide_list}) {
+ b class => 'grayedout', 'hidden';
+ } else {
+ a href => "/u$l->{uid}", $l->{username};
+ }
end;
end;
},
diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm
index dd129c18..e12024c1 100644
--- a/lib/VNDB/Util/CommonHTML.pm
+++ b/lib/VNDB/Util/CommonHTML.pm
@@ -389,8 +389,7 @@ sub htmlVoteStats {
my $recent = $self->dbVoteGet(
$type.'id' => $obj->{id},
results => 8,
- what => $type eq 'v' ? 'user' : 'vn',
- hide => $type eq 'v',
+ what => $type eq 'v' ? 'user hide_list' : 'vn',
hide_ign => $type eq 'v',
);
if(@$recent) {
@@ -410,6 +409,8 @@ sub htmlVoteStats {
td;
if($type eq 'u') {
a href => "/v$_->{vid}", title => $_->{original}||$_->{title}, shorten $_->{title}, 40;
+ } elsif($_->{hide_list}) {
+ b class => 'grayedout', 'hidden';
} else {
a href => "/u$_->{uid}", $_->{username};
}