diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | data/lang.txt | 10 | ||||
-rw-r--r-- | lib/VNDB/DB/ULists.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/DB/Users.pm | 12 | ||||
-rw-r--r-- | lib/VNDB/Handler/Discussions.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/Misc.pm | 2 | ||||
-rw-r--r-- | lib/VNDB/Handler/ULists.pm | 11 | ||||
-rw-r--r-- | lib/VNDB/Handler/Users.pm | 31 | ||||
-rw-r--r-- | lib/VNDB/Util/CommonHTML.pm | 2 | ||||
-rw-r--r-- | util/sql/schema.sql | 1 | ||||
-rw-r--r-- | util/updates/update_2.16.sql | 3 |
11 files changed, 43 insertions, 36 deletions
@@ -16,7 +16,8 @@ - Improved VN tag filter selection with a dynamic HTML list of selected tags - Don't send 'tagspoil' filter when 'tag_inc' isn't active - Don't allow page > 100 or sorting on username or title on tag link browser - - Added users_prefs table and removed users.(skin|customcss|show_nsfw) + - Added users_prefs table and removed the following columns from users: + skin, customcss, show_nsfw, show_list 2.15 - 2010-12-15 - Removed expand/collapse from history browser and /u+/posts and switched to diff --git a/data/lang.txt b/data/lang.txt index 1e7f690c..afd1ff25 100644 --- a/data/lang.txt +++ b/data/lang.txt @@ -5545,11 +5545,11 @@ hu : Beállítások nl : Opties :_usere_flist -en : Allow other people to see my visual novel list ([url,_1,_1]) and wishlist ([url,_2,_2]) -ru : Разрешить остальным видеть мой список новелл ([url,_1,_1]) и список желаемого ([url,_2,_2]) -cs : Povolit ostatním zobrazit můj list vizuálních novel ([url,_1,_1]) a wishlist ([url,_2,_2]) -hu : Más embereknek megengedni, hogy lássák a visual novel listám ([url,_1,_1]) és a kívánságlistám ([url,_2,_2]) -nl : Sta andere mensen toe om mijn visual novel lijst ([url,_1,_1]) en wensenlijst ([url,_2,_2]) te zien +en : Don't allow other people to see my visual novel list ([url,_1,_1]), votes ([url,_2,_2]) and wishlist ([url,_3,_3]) +ru*: +cs*: +hu*: +nl : Sta andere mensen niet toe om mijn visual novel lijst ([url,_1,_1]), stemmen ([url,_2,_2]) en wensenlijst ([url,_3,_3]) te zien :_usere_fnsfw en : Disable warnings for images that are not safe for work. diff --git a/lib/VNDB/DB/ULists.pm b/lib/VNDB/DB/ULists.pm index a1f02786..e6b6419a 100644 --- a/lib/VNDB/DB/ULists.pm +++ b/lib/VNDB/DB/ULists.pm @@ -188,7 +188,7 @@ sub dbVoteGet { my %where = ( $o{uid} ? ( 'n.uid = ?' => $o{uid} ) : (), $o{vid} ? ( 'n.vid = ?' => $o{vid} ) : (), - $o{hide} ? ( 'u.show_list = TRUE' => 1 ) : (), + $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(vr.title, 1, 1)) = ?' => $o{vn_char} ) : (), defined $o{vn_char} && !$o{vn_char} ? ( diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm index 86249f44..48e8d7ff 100644 --- a/lib/VNDB/DB/Users.pm +++ b/lib/VNDB/DB/Users.pm @@ -13,7 +13,7 @@ our @EXPORT = qw| # %options->{ username passwd mail session uid ip registered search results page what sort reverse } -# what: notifycount stats extended prefs +# what: notifycount stats extended prefs hide_list # sort: username registered votes changes tags sub dbUserGet { my $s = shift; @@ -21,6 +21,7 @@ sub dbUserGet { page => 1, results => 10, what => '', + sort => '', @_ ); @@ -51,12 +52,13 @@ sub dbUserGet { ); my @select = ( - qw|id username c_votes c_changes show_list c_tags|, + qw|id username c_votes c_changes c_tags|, q|extract('epoch' from registered) as registered|, $o{what} =~ /extended/ ? ( qw|mail rank salt ign_votes notify_dbedit notify_announce|, q|encode(passwd, 'hex') AS passwd| ) : (), + $o{what} =~ /hide_list/ ? 'up.value AS hide_list' : (), $o{what} =~ /notifycount/ ? '(SELECT COUNT(*) FROM notifications WHERE uid = u.id AND read IS NULL) AS notifycount' : (), $o{what} =~ /stats/ ? ( @@ -72,12 +74,14 @@ sub dbUserGet { my @join = ( $o{session} ? 'JOIN sessions s ON s.uid = u.id' : (), + $o{what} =~ /hide_list/ || $o{sort} eq 'votes' ? + "LEFT JOIN users_prefs up ON up.uid = u.id AND up.key = 'hide_list'" : (), ); my $order = sprintf { username => 'u.username %s', registered => 'u.registered %s', - votes => 'NOT u.show_list, u.c_votes %s', + votes => 'up.value NULLS FIRST, u.c_votes %s', changes => 'u.c_changes %s', tags => 'u.c_tags %s', }->{ $o{sort}||'username' }, $o{reverse} ? 'DESC' : 'ASC'; @@ -114,7 +118,7 @@ sub dbUserEdit { my %h; defined $o{$_} && ($h{$_.' = ?'} = $o{$_}) - for (qw| username mail rank show_list salt ign_votes notify_dbedit notify_announce |); + for (qw| username mail rank salt ign_votes notify_dbedit notify_announce |); $h{'passwd = decode(?, \'hex\')'} = $o{passwd} if defined $o{passwd}; diff --git a/lib/VNDB/Handler/Discussions.pm b/lib/VNDB/Handler/Discussions.pm index 7c0160de..0b5daa6c 100644 --- a/lib/VNDB/Handler/Discussions.pm +++ b/lib/VNDB/Handler/Discussions.pm @@ -278,7 +278,7 @@ sub board { return 404 if $f->{_err}; my $obj = !$iid ? undef : - $type eq 'u' ? $self->dbUserGet(uid => $iid)->[0] : + $type eq 'u' ? $self->dbUserGet(uid => $iid, what => 'hide_list')->[0] : $type eq 'p' ? $self->dbProducerGet(id => $iid)->[0] : $self->dbVNGet(id => $iid)->[0]; return 404 if $iid && !$obj; diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm index 88e08f68..4e4e5479 100644 --- a/lib/VNDB/Handler/Misc.pm +++ b/lib/VNDB/Handler/Misc.pm @@ -197,7 +197,7 @@ sub history { return 404 if $f->{_err}; # get item object and title - my $obj = $type eq 'u' ? $self->dbUserGet(uid => $id)->[0] : + my $obj = $type eq 'u' ? $self->dbUserGet(uid => $id, what => 'hide_list')->[0] : $type eq 'p' ? $self->dbProducerGet(id => $id)->[0] : $type eq 'r' ? $self->dbReleaseGet(id => $id)->[0] : $type eq 'v' ? $self->dbVNGet(id => $id)->[0] : undef; diff --git a/lib/VNDB/Handler/ULists.pm b/lib/VNDB/Handler/ULists.pm index d9051347..cb164277 100644 --- a/lib/VNDB/Handler/ULists.pm +++ b/lib/VNDB/Handler/ULists.pm @@ -115,10 +115,11 @@ sub rlist_e { sub votelist { my($self, $type, $id) = @_; - my $obj = $type eq 'v' ? $self->dbVNGet(id => $id)->[0] : $self->dbUserGet(uid => $id)->[0]; + my $obj = $type eq 'v' ? $self->dbVNGet(id => $id)->[0] : $self->dbUserGet(uid => $id, what => 'hide_list')->[0]; return 404 if !$obj->{id}; my $own = $type eq 'u' && $self->authInfo->{id} && $self->authInfo->{id} == $id; + return 404 if $type eq 'u' && !$own && ($obj->{hide_list} || $self->authCan('usermod')); my $f = $self->formValidate( { name => 'p', required => 0, default => 1, template => 'int' }, @@ -220,8 +221,8 @@ sub wishlist { my($self, $uid) = @_; my $own = $self->authInfo->{id} && $self->authInfo->{id} == $uid; - my $u = $self->dbUserGet(uid => $uid)->[0]; - return 404 if !$u || !$own && !($u->{show_list} || $self->authCan('usermod')); + my $u = $self->dbUserGet(uid => $uid, what => 'hide_list')->[0]; + return 404 if !$u || !$own && ($u->{hide_list} || $self->authCan('usermod')); my $f = $self->formValidate( { name => 'p', required => 0, default => 1, template => 'int' }, @@ -322,8 +323,8 @@ sub vnlist { my($self, $uid) = @_; my $own = $self->authInfo->{id} && $self->authInfo->{id} == $uid; - my $u = $self->dbUserGet(uid => $uid)->[0]; - return 404 if !$u || !$own && !($u->{show_list} || $self->authCan('usermod')); + my $u = $self->dbUserGet(uid => $uid, what => 'hide_list')->[0]; + return 404 if !$u || !$own && ($u->{hide_list} || $self->authCan('usermod')); my $f = $self->formValidate( { name => 'p', required => 0, default => 1, template => 'int' }, diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index d3879109..d19b2f74 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -27,7 +27,7 @@ YAWF::register( sub userpage { my($self, $uid) = @_; - my $u = $self->dbUserGet(uid => $uid, what => 'stats')->[0]; + my $u = $self->dbUserGet(uid => $uid, what => 'stats hide_list')->[0]; return 404 if !$u->{id}; my $votes = $u->{c_votes} && $self->dbVoteStats(uid => $uid); @@ -69,7 +69,7 @@ sub userpage { Tr ++$i % 2 ? (class => 'odd') : (); td mt '_userpage_votes'; td; - if(!$u->{show_list}) { + if($u->{hide_list}) { txt mt '_userpage_hidden'; } elsif($votes) { my($total, $count) = (0, 0); @@ -99,7 +99,7 @@ sub userpage { Tr ++$i % 2 ? (class => 'odd') : (); td mt '_userpage_list'; - td !$u->{show_list} ? mt('_userpage_hidden') : + td $u->{hide_list} ? mt('_userpage_hidden') : mt('_userpage_list_item', $u->{releasecount}, $u->{vncount}); end; @@ -116,7 +116,7 @@ sub userpage { end; end; - if($u->{show_list} && $votes) { + if(!$u->{hide_list} && $votes) { div class => 'mainbox'; h1 mt '_userpage_votestats'; $self->htmlVoteStats(u => $u, $votes); @@ -307,7 +307,7 @@ sub edit { { name => 'mail', template => 'mail' }, { name => 'usrpass', required => 0, minlength => 4, maxlength => 64, template => 'asciiprint' }, { name => 'usrpass2', required => 0, minlength => 4, maxlength => 64, template => 'asciiprint' }, - { name => 'flags_list', required => 0, default => 0 }, + { name => 'hide_list', required => 0, default => 0, enum => [0,1] }, { name => 'show_nsfw', required => 0, default => 0, enum => [0,1] }, { name => 'skin', required => 0, default => '', enum => [ '', keys %{$self->{skins}} ] }, { name => 'customcss', required => 0, maxlength => 2000, default => '' }, @@ -315,13 +315,12 @@ sub edit { push @{$frm->{_err}}, 'passmatch' if ($frm->{usrpass} || $frm->{usrpass2}) && (!$frm->{usrpass} || !$frm->{usrpass2} || $frm->{usrpass} ne $frm->{usrpass2}); if(!$frm->{_err}) { - $self->dbUserPrefSet($uid, $_ => $frm->{$_}) for (qw|skin customcss show_nsfw |); + $self->dbUserPrefSet($uid, $_ => $frm->{$_}) for (qw|skin customcss show_nsfw hide_list |); my %o; $o{username} = $frm->{usrname} if $frm->{usrname}; $o{rank} = $frm->{rank} if $frm->{rank}; $o{mail} = $frm->{mail}; ($o{passwd}, $o{salt}) = $self->authPreparePass($frm->{usrpass}) if $frm->{usrpass}; - $o{show_list} = $frm->{flags_list} ? 1 : 0; $o{ign_votes} = $frm->{ign_votes} ? 1 : 0 if $self->authCan('usermod'); $self->dbUserEdit($uid, %o); $self->dbSessionDel($uid) if $frm->{usrpass}; @@ -333,8 +332,7 @@ sub edit { # fill out default values $frm->{usrname} ||= $u->{username}; $frm->{$_} ||= $u->{$_} for(qw|rank mail|); - $frm->{$_} //= $u->{prefs}{$_} for(qw|skin customcss show_nsfw|); - $frm->{flags_list} = $u->{show_list} if !defined $frm->{flags_list}; + $frm->{$_} //= $u->{prefs}{$_} for(qw|skin customcss show_nsfw hide_list|); $frm->{ign_votes} = $u->{ign_votes} if !defined $frm->{ign_votes}; # create the page @@ -366,7 +364,7 @@ sub edit { [ passwd => short => 'usrpass2', name => mt '_usere_confirm' ], [ part => title => mt '_usere_options' ], - [ check => short => 'flags_list', name => mt '_usere_flist', "/u$uid/list", "/u$uid/wish" ], + [ check => short => 'hide_list', name => mt '_usere_flist', "/u$uid/list", "/u$uid/votes", "/u$uid/wish" ], [ check => short => 'show_nsfw', name => mt '_usere_fnsfw' ], [ select => short => 'skin', name => mt('_usere_skin'), width => 300, options => [ map [ $_ eq $self->{skin_default} ? '' : $_, $self->{skins}{$_}[0].($self->debug?" [$_]":'') ], sort { $self->{skins}{$a}[0] cmp $self->{skins}{$b}[0] } keys %{$self->{skins}} ] ], @@ -380,7 +378,7 @@ sub posts { my($self, $uid) = @_; # fetch user info (cached if uid == loggedin uid) - my $u = $self->authInfo->{id} && $self->authInfo->{id} == $uid ? $self->authInfo : $self->dbUserGet(uid => $uid)->[0]; + my $u = $self->authInfo->{id} && $self->authInfo->{id} == $uid ? $self->authInfo : $self->dbUserGet(uid => $uid, what => 'hide_list')->[0]; return 404 if !$u->{id}; my $f = $self->formValidate( @@ -437,7 +435,7 @@ sub delete { # confirm if(!$act) { my $code = $self->authGetCode("/u$uid/del/o"); - my $u = $self->dbUserGet(uid => $uid)->[0]; + my $u = $self->dbUserGet(uid => $uid, what => 'hide_list')->[0]; return 404 if !$u->{id}; $self->htmlHeader(title => 'Delete user', noindex => 1); $self->htmlMainTabs('u', $u, 'del'); @@ -498,6 +496,7 @@ sub list { my($list, $np) = $self->dbUserGet( sort => $f->{s}, reverse => $f->{o} eq 'd', + what => 'hide_list', $char ne 'all' ? ( firstchar => $char ) : (), results => 50, @@ -525,8 +524,8 @@ sub list { a href => '/u'.$l->{id}, $l->{username}; end; td class => 'tc2', $self->{l10n}->date($l->{registered}); - td class => 'tc3'.(!$l->{show_list} && $self->authCan('usermod') ? ' linethrough' : ''); - lit !$l->{show_list} && !$self->authCan('usermod') ? '-' : !$l->{c_votes} ? 0 : + td class => 'tc3'.($l->{hide_list} && $self->authCan('usermod') ? ' linethrough' : ''); + lit $l->{hide_list} && !$self->authCan('usermod') ? '-' : !$l->{c_votes} ? 0 : qq|<a href="/u$l->{id}/votes">$l->{c_votes}</a>|; end; td class => 'tc4'; @@ -544,9 +543,9 @@ sub list { sub notifies { my($self, $uid) = @_; - return $self->htmlDenied if !$self->authInfo->{id} || $uid != $self->authInfo->{id}; - my $u = $self->dbUserGet(uid => $uid)->[0]; + my $u = $self->authInfo; + return $self->htmlDenied if !$u->{id} || $uid != $u->{id}; my $f = $self->formValidate( { name => 'p', required => 0, default => 1, template => 'int' }, diff --git a/lib/VNDB/Util/CommonHTML.pm b/lib/VNDB/Util/CommonHTML.pm index a384c5a3..a412949a 100644 --- a/lib/VNDB/Util/CommonHTML.pm +++ b/lib/VNDB/Util/CommonHTML.pm @@ -45,7 +45,7 @@ sub htmlMainTabs { end; } - if($type eq 'u' && ($obj->{show_list} || $self->authCan('usermod'))) { + if($type eq 'u' && (!($obj->{hide_list} || $obj->{prefs}{hide_list}) || ($self->authInfo->{id} && $self->authInfo->{id} == $obj->{id}) || $self->authCan('usermod'))) { li $sel eq 'wish' ? (class => 'tabselected') : (); a href => "/$id/wish", mt '_mtabs_wishlist'; end; diff --git a/util/sql/schema.sql b/util/sql/schema.sql index 8826a01e..638191c3 100644 --- a/util/sql/schema.sql +++ b/util/sql/schema.sql @@ -266,7 +266,6 @@ CREATE TABLE users ( rank smallint NOT NULL DEFAULT 3, passwd bytea NOT NULL DEFAULT '', registered timestamptz NOT NULL DEFAULT NOW(), - show_list boolean NOT NULL DEFAULT TRUE, c_votes integer NOT NULL DEFAULT 0, c_changes integer NOT NULL DEFAULT 0, ip inet NOT NULL DEFAULT '0.0.0.0', diff --git a/util/updates/update_2.16.sql b/util/updates/update_2.16.sql index a0678fd3..b401a7a4 100644 --- a/util/updates/update_2.16.sql +++ b/util/updates/update_2.16.sql @@ -65,8 +65,11 @@ INSERT INTO users_prefs (uid, key, value) SELECT id, 'customcss', customcss FROM users WHERE customcss <> ''; UNION SELECT id, 'show_nsfw'::prefs_key, '1' FROM users WHERE show_nsfw; + UNION + SELECT id, 'hide_list'::prefs_key, '1' FROM users WHERE NOT show_list; ALTER TABLE users DROP COLUMN skin; ALTER TABLE users DROP COLUMN customcss; ALTER TABLE users DROP COLUMN show_nsfw; +ALTER TABLE users DROP COLUMN show_list; |