diff options
author | Yorhel <git@yorhel.nl> | 2019-10-03 10:45:51 +0200 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2019-10-03 10:50:20 +0200 |
commit | 8795f8a55df40603e3e589b584cc5d4c66e78f3a (patch) | |
tree | 7407dd4b1d40a0485a42e0a0ea14fa41a7e74981 /lib/VNDB/Handler | |
parent | 2e9f6f1844131529f553de37eba0bca421a75f8b (diff) |
SQL: Get rid of the users_prefs table, store preferences in users table
This bloats the users table a little bit, but that's fine. The main
advantage of this change is that we now have a proper schema for user
preferences, rather than the schemaless key-value mess we had before.
This commit also splits the 'tags_cat' preference up into tags_cont,
tags_ero and tags_tech bools, as that's more compact to store and easier
to work with.
This commit also changes the 'notify_nodbedit' preference to
'notify_dbedit' with inverted meaning. The reason the value was negated
in the first place was because the old schemaless approach did not
support positive defaults.
Diffstat (limited to 'lib/VNDB/Handler')
-rw-r--r-- | lib/VNDB/Handler/Users.pm | 13 | ||||
-rw-r--r-- | lib/VNDB/Handler/VNPage.pm | 3 |
2 files changed, 7 insertions, 9 deletions
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm index 2557b9d1..ebc037f2 100644 --- a/lib/VNDB/Handler/Users.pm +++ b/lib/VNDB/Handler/Users.pm @@ -322,11 +322,11 @@ sub notifies { if($self->reqMethod() eq 'POST' && $self->reqPost('set')) { return if !$self->authCheckCode; my $frm = $self->formValidate( - { post => 'notify_nodbedit', required => 0, default => 1, enum => [0,1] }, + { post => 'notify_dbedit', required => 0, default => 0, enum => [0,1] }, { post => 'notify_announce', required => 0, default => 0, enum => [0,1] } ); return $self->resNotFound if $frm->{_err}; - $self->authPref($_, $frm->{$_}) for ('notify_nodbedit', 'notify_announce'); + $self->authPref($_, $frm->{$_}) for ('notify_dbedit', 'notify_announce'); $saved = 1; # updating notifications @@ -428,11 +428,10 @@ sub notifies { h1 'Settings'; div class => 'notice', 'Settings successfully saved.' if $saved; p; - for('nodbedit', 'announce') { - my $def = $_ eq 'nodbedit' ? 0 : 1; - input type => 'checkbox', name => "notify_$_", id => "notify_$_", value => $def, - ($self->authPref("notify_$_")||0) == $def ? (checked => 'checked') : (); - label for => "notify_$_", $_ eq 'nodbedit' + for('dbedit', 'announce') { + input type => 'checkbox', name => "notify_$_", id => "notify_$_", value => 1, + $self->authPref("notify_$_") ? (checked => 'checked') : (); + label for => "notify_$_", $_ eq 'dbedit' ? ' Notify me about edits of database entries I contributed to.' : ' Notify me about site announcements.'; br; diff --git a/lib/VNDB/Handler/VNPage.pm b/lib/VNDB/Handler/VNPage.pm index 90597101..d716c74e 100644 --- a/lib/VNDB/Handler/VNPage.pm +++ b/lib/VNDB/Handler/VNPage.pm @@ -456,9 +456,8 @@ sub page { my $t = $self->dbTagStats(vid => $v->{id}, sort => 'rating', reverse => 1, minrating => 0, results => 999, state => 2); if(@$t) { div id => 'tagops'; - my $tags_cat = $self->authPref('tags_cat') || $self->{default_tags_cat}; for (keys %TAG_CATEGORY) { - input id => "cat_$_", type => 'checkbox', class => 'visuallyhidden', $tags_cat =~ /\Q$_/ ? (checked => 'checked') : (); + input id => "cat_$_", type => 'checkbox', class => 'visuallyhidden', $self->authPref("tags_$_") ? (checked => 'checked') : (); label for => "cat_$_", lc $TAG_CATEGORY{$_}; } my $spoiler = $self->authPref('spoilers') || 0; |