diff options
author | Yorhel <git@yorhel.nl> | 2009-08-12 15:36:37 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2009-08-12 15:36:37 +0200 |
commit | e8ed9663331278c6bd555f7a69c45e84fc4bb34e (patch) | |
tree | 6c4f6b4539398b48dee64bdd2045713cf5d17013 /lib/VNDB/DB/ULists.pm | |
parent | 9af811fcde7d9f5c8e9f63390e895fcb8fc07677 (diff) |
Added global user votes ignore list
Diffstat (limited to 'lib/VNDB/DB/ULists.pm')
-rw-r--r-- | lib/VNDB/DB/ULists.pm | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm index 34bdc2aa..f57c5aa1 100644 --- a/lib/VNDB/DB/ULists.pm +++ b/lib/VNDB/DB/ULists.pm @@ -155,6 +155,7 @@ sub dbVoteGet { $o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (), $o{vid} ? ( 'n.vid = ?' => $o{vid} ) : (), $o{hide} ? ( 'u.show_list = TRUE' => 1 ) : (), + $o{hide_ign} ? ( '(NOT u.ign_votes OR u.id = ?)' => $self->authInfo->{id}||0 ) : (), ); my @select = ( @@ -186,16 +187,19 @@ sub dbVoteGet { } -# Arguments: (uid|vid), id +# Arguments: (uid|vid), id, use_ignore_list # Returns an arrayref with 10 elements containing the number of votes for index+1 sub dbVoteStats { - my($self, $col, $id) = @_; + my($self, $col, $id, $ign) = @_; + my $u = $self->authInfo->{id}; my $r = [ qw| 0 0 0 0 0 0 0 0 0 0 | ]; $r->[$_->{vote}-1] = $_->{votes} for (@{$self->dbAll(q| SELECT vote, COUNT(vote) as votes FROM votes + !s !W GROUP BY vote|, + $ign ? 'JOIN users ON id = uid AND (NOT ign_votes'.($u?sprintf(' OR id = %d'.$u):'').')' : '', $col ? { '!s = ?' => [ $col, $id ] } : {}, )}); return $r; |