LJSUP-17669: Login.bml form refactoring
[livejournal.git] / cgi-bin / LJ / Setting / MailEncoding.pm
blobe3df35ff52bde0e82a6e967e14f4e713e6dee6de
1 package LJ::Setting::MailEncoding;
2 use base 'LJ::Setting';
3 use strict;
4 use warnings;
6 sub tags { qw(mail translate encoding) }
8 sub as_html {
9 my ($class, $u, $errs) = @_;
10 my $key = $class->pkgkey;
11 local $BML::ML_SCOPE = "/editinfo.bml";
12 my %mail_encnames;
13 LJ::load_codes({ "encname" => \%mail_encnames } );
15 my $ret = "<?h2 $BML::ML{'.translatemailto.header'} h2?>\n";
16 $ret .= LJ::html_select({ 'name' => "${key}mailencoding",
17 'selected' => $u->prop('mailencoding')},
18 map { $_, $mail_encnames{$_} } sort keys %mail_encnames);
19 $ret .= "<br />\n$BML::ML{'.translatemailto.about'}";
20 return $ret;
23 sub save {
24 my ($class, $u, $args) = @_;
25 my $val = $args->{'mailencoding'};
27 my %mail_encnames;
28 LJ::load_codes({ "encname" => \%mail_encnames } );
29 $class->errors(oldenc => "Invalid") unless ! $val || $mail_encnames{$val};
31 return 1 if $val eq $u->prop('mailencoding');
32 return 0 unless $u->set_prop('mailencoding', $val);
33 return 1;