1 package LJ
::Setting
::Birthday
;
2 use base
'LJ::Setting';
8 sub tags
{ qw(birthday birthdate dob) }
11 my ($class, $u, $errs, $args) = @_;
12 my $key = $class->pkgkey;
15 $ret .= "<label for='${key}month'>" . $class->ml('.setting.birthday.question') . "</label>";
17 if ($u->{bdate
} =~ /^(\d\d\d\d)-(\d\d)-(\d\d)$/) {
18 ($bdpart{year
}, $bdpart{month
}, $bdpart{day
}) = ($1, $2, $3);
19 if ($bdpart{year
} eq "0000") { $bdpart{year
} = ""; }
20 if ($bdpart{day
} eq "00") { $bdpart{day
} = ""; }
22 $ret .= LJ
::html_select
({ 'name' => "${key}month", 'id' => "${key}month", 'class' => "select", 'selected' => int($bdpart{month
}) },
23 '', '', map { $_, LJ
::Lang
::ml
(LJ
::Lang
::month_long_langcode
($_)) } (1..12)) . " ";
25 $ret .= LJ
::html_text
({ 'name' => "${key}day", 'value' => $bdpart{day
}, 'class' => 'text', 'size' => '3', 'maxlength' => '2' }) . " ";
26 $ret .= LJ
::html_text
({ 'name' => "${key}year", 'value' => $bdpart{year
}, 'class' => 'text', 'size' => '5', 'maxlength' => '4' });
28 $ret .= $class->errdiv($errs, "month");
29 $ret .= $class->errdiv($errs, "day");
30 $ret .= $class->errdiv($errs, "year");
36 my ($class, $u, $args) = @_;
37 my $month = $class->get_arg($args, "month") || 0;
38 my $day = $class->get_arg($args, "day") || 0;
39 my $year = $class->get_arg($args, "year") || 0;
40 my $this_year = (localtime())[5]+1900;
42 local $BML::ML_SCOPE
= "/manage/profile/index.bml";
44 if ($year && $year < 100) {
45 $class->errors("year" => LJ
::Lang
::ml
('.error.year.notenoughdigits'));
49 if ($year && $year >= 100 && ($year < 1890 || $year > $this_year)) {
50 $class->errors("year" => LJ
::Lang
::ml
('.error.year.outofrange'));
54 if ($month && ($month < 1 || $month > 12)) {
55 $class->errors("month" => LJ
::Lang
::ml
('.error.month.outofrange'));
59 if ($day && ($day < 1 || $day > 31)) {
60 $class->errors("day" => LJ
::Lang
::ml
('.error.day.outofrange'));
64 if ($err_count == 0 && $day > LJ
::TimeUtil
->days_in_month($month, $year)) {
65 $class->errors("day" => LJ
::Lang
::ml
('.error.day.notinmonth'));
72 my ($class, $u, $args) = @_;
73 $class->error_check($u, $args);
75 my $month = $class->get_arg($args, "month") || 0;
76 my $day = $class->get_arg($args, "day") || 0;
77 my $year = $class->get_arg($args, "year") || 0;
80 'bdate' => sprintf("%04d-%02d-%02d", $year, $month, $day),
82 LJ
::update_user
($u, \
%update);
85 my $sidx_bday = sprintf("%02d-%02d", $month, $day);
86 $sidx_bday = "" if !$sidx_bday || $sidx_bday =~ /00/;
87 $u->set_prop('sidx_bday', $sidx_bday);
88 $u->invalidate_directory_record;
89 $u->set_next_birthday;