summaryrefslogtreecommitdiff
path: root/lib/VNDB
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-12-23 14:25:37 +0100
committerYorhel <git@yorhel.nl>2010-12-23 14:25:37 +0100
commit3eb574e4e26162aa754372fff806e4c6de8f4754 (patch)
tree32b08348512dc2f16d932676bb9b1b61fab16f3a /lib/VNDB
parent6ff1efe0d07e24e9fb2db199c308c6cbed51e578 (diff)
Converted the notify_announce and notify_dbedit preferences
And renamed notify_dbedit to notify_nodbedit, since the default is to provide a notify on a database edit. Also fixed a few bugs along the way.
Diffstat (limited to 'lib/VNDB')
-rw-r--r--lib/VNDB/DB/Users.pm6
-rw-r--r--lib/VNDB/Handler/Users.pm17
-rw-r--r--lib/VNDB/Util/Auth.pm9
-rw-r--r--lib/VNDB/Util/FormHTML.pm2
4 files changed, 16 insertions, 18 deletions
diff --git a/lib/VNDB/DB/Users.pm b/lib/VNDB/DB/Users.pm
index 48e8d7ff..bd7db201 100644
--- a/lib/VNDB/DB/Users.pm
+++ b/lib/VNDB/DB/Users.pm
@@ -55,7 +55,7 @@ sub dbUserGet {
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|,
+ qw|mail rank salt ign_votes|,
q|encode(passwd, 'hex') AS passwd|
) : (),
$o{what} =~ /hide_list/ ? 'up.value AS hide_list' : (),
@@ -95,7 +95,7 @@ sub dbUserGet {
join(', ', @select), join(' ', @join), \%where, $order
);
- if($o{what} =~ /prefs/) {
+ if(@$r && $o{what} =~ /prefs/) {
my %r = map {
$r->[$_]{prefs} = {};
($r->[$_]{id}, $r->[$_])
@@ -118,7 +118,7 @@ sub dbUserEdit {
my %h;
defined $o{$_} && ($h{$_.' = ?'} = $o{$_})
- for (qw| username mail rank salt ign_votes notify_dbedit notify_announce |);
+ for (qw| username mail rank salt ign_votes |);
$h{'passwd = decode(?, \'hex\')'} = $o{passwd}
if defined $o{passwd};
diff --git a/lib/VNDB/Handler/Users.pm b/lib/VNDB/Handler/Users.pm
index d19b2f74..044c72b2 100644
--- a/lib/VNDB/Handler/Users.pm
+++ b/lib/VNDB/Handler/Users.pm
@@ -559,15 +559,11 @@ sub notifies {
if($self->reqMethod() eq 'POST' && $self->reqParam('set')) {
return if !$self->authCheckCode;
my $frm = $self->formValidate(
- { name => 'notify_dbedit', required => 0 },
- { name => 'notify_announce', required => 0 }
+ { name => 'notify_nodbedit', required => 0, default => 1, enum => [0,1] },
+ { name => 'notify_announce', required => 0, default => 0, enum => [0,1] }
);
return 404 if $frm->{_err};
- for ('notify_dbedit', 'notify_announce') {
- $frm->{$_} = $frm->{$_} ? 1 : 0;
- $self->authInfo->{$_} = $frm->{$_};
- }
- $self->dbUserEdit($uid, %$frm);
+ $self->authPref($_, $frm->{$_}) for ('notify_nodbedit', 'notify_announce');
$saved = 1;
# updating notifications
@@ -658,9 +654,10 @@ sub notifies {
h1 mt '_usern_set_title';
div class => 'notice', mt '_usern_set_saved' if $saved;
p;
- for('dbedit', 'announce') {
- input type => 'checkbox', name => "notify_$_", id => "notify_$_", value => 1,
- $self->authInfo->{"notify_$_"} ? (checked => 'checked') : ();
+ 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_$_", ' '.mt("_usern_set_$_");
br;
}
diff --git a/lib/VNDB/Util/Auth.pm b/lib/VNDB/Util/Auth.pm
index 50b81eb2..932a48ee 100644
--- a/lib/VNDB/Util/Auth.pm
+++ b/lib/VNDB/Util/Auth.pm
@@ -198,10 +198,11 @@ sub _incorrectcode {
sub authPref {
my($self, $key, $val) = @_;
- return '' if !$self->authInfo->{id};
- return $self->{_auth}{prefs}{$key}||'' if @_ == 2;
- $self->{_auth}{prefs}{$key} = $val;
- $self->dbUserPrefSet($key, $val);
+ my $nfo = $self->authInfo;
+ return '' if !$nfo->{id};
+ return $nfo->{prefs}{$key}||'' if @_ == 2;
+ $nfo->{prefs}{$key} = $val;
+ $self->dbUserPrefSet($nfo->{id}, $key, $val);
}
1;
diff --git a/lib/VNDB/Util/FormHTML.pm b/lib/VNDB/Util/FormHTML.pm
index 7956a4c2..41ee0ccc 100644
--- a/lib/VNDB/Util/FormHTML.pm
+++ b/lib/VNDB/Util/FormHTML.pm
@@ -89,7 +89,7 @@ sub htmlFormPart {
end;
td class => 'field';
input type => 'checkbox', name => $o{short}, id => $o{short},
- value => $o{value}||1, $frm->{$o{short}} ? ( checked => 'checked' ) : ();
+ value => $o{value}||1, ($frm->{$o{short}}||0) eq ($o{value}||1) ? ( checked => 'checked' ) : ();
label for => $o{short};
lit $o{name};
end;