summaryrefslogtreecommitdiff
path: root/lib/VNDB/Handler/Misc.pm
diff options
context:
space:
mode:
authorYorhel <git@yorhel.nl>2010-12-23 20:05:51 +0100
committerYorhel <git@yorhel.nl>2010-12-23 20:05:51 +0100
commitfd56a6e269aea462a80fff730eccabd4688036e3 (patch)
tree0aefc987bafb835fee825cb0025177266a8640e6 /lib/VNDB/Handler/Misc.pm
parent3eb574e4e26162aa754372fff806e4c6de8f4754 (diff)
Store l10n preference in the database for logged-in users
Diffstat (limited to 'lib/VNDB/Handler/Misc.pm')
-rw-r--r--lib/VNDB/Handler/Misc.pm11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/VNDB/Handler/Misc.pm b/lib/VNDB/Handler/Misc.pm
index 4e4e5479..8b4b8900 100644
--- a/lib/VNDB/Handler/Misc.pm
+++ b/lib/VNDB/Handler/Misc.pm
@@ -340,10 +340,17 @@ sub setlang {
return 404 if $lang->{_err};
$lang = $lang->{lang};
+ my $browser = VNDB::L10N->get_handle()->language_tag();
+
(my $ref = $self->reqHeader('Referer')||'/') =~ s/^\Q$self->{url}//;
$self->resRedirect($ref, 'post');
- $self->resHeader('Set-Cookie', "l10n=$lang; expires=Sat, 01-Jan-2030 00:00:00 GMT; path=/; domain=$self->{cookie_domain}")
- if $lang ne $self->{l10n}->language_tag();
+ if($lang ne $self->{l10n}->language_tag()) {
+ $self->authInfo->{id}
+ ? $self->authPref(l10n => $lang eq $browser ? undef : $lang)
+ : $self->resHeader('Set-Cookie', sprintf 'l10n=%s; expires=%s; path=/; domain=%s',
+ $lang, $lang eq $browser ? 'Sat, 01-Jan-2000 00:00:00 GMT' : 'Sat, 01-Jan-2030 00:00:00 GMT',
+ $self->{cookie_domain});
+ }
}