LJSUP-17669: Login.bml form refactoring
[livejournal.git] / cgi-bin / LJ / Setting / SelfCommentEmail.pm
blob721d098a1893b9212f1d1314b59bb50fff3fec0b
1 package LJ::Setting::SelfCommentEmail;
2 use base 'LJ::Setting';
3 use strict;
4 use warnings;
6 sub should_render {
7 my ($class, $u) = @_;
9 return $u && !$u->is_community ? 1 : 0;
12 sub disabled {
13 my ($class, $u) = @_;
15 return $u->get_cap("getselfemail") ? 0 : 1;
18 sub selected {
19 my ($class, $u) = @_;
21 return $u->prop("opt_getselfemail") && !$class->disabled($u) ? 1 : 0;
24 sub label {
25 my $class = shift;
27 return $class->ml('setting.selfcommentemail.label');
30 sub option {
31 my ($class, $u, $errs, $args, %opts) = @_;
33 return $class->htmlcontrol($u, $errs, $args, %opts) . " " . $class->htmlcontrol_label($u);
36 sub htmlcontrol_label {
37 my ($class, $u) = @_;
38 my $key = $class->pkgkey;
40 return "<label for='${key}selfcommentemail'>" . $class->ml('setting.selfcommentemail.option') . "</label>";
43 sub htmlcontrol {
44 my ($class, $u, $errs, $args, %opts) = @_;
45 my $key = $class->pkgkey;
47 if ($opts{notif}) {
48 my $catid = $opts{notif_catid};
49 my $ntypeid = $opts{notif_ntypeid};
51 return LJ::html_check({
52 class => "SubscribeCheckbox-$catid-$ntypeid",
53 selected => 1,
54 disabled => 1,
55 });
56 } else {
57 return LJ::html_check({
58 name => "${key}selfcommentemail",
59 id => "${key}selfcommentemail",
60 class => "SubscriptionInboxCheck",
61 value => 1,
62 selected => $class->selected($u) ? 1 : 0,
63 disabled => $class->disabled($u) ? 1 : 0,
64 });
68 sub save {
69 my ($class, $u, $args) = @_;
71 my $val = $class->get_arg($args, "selfcommentemail") ? 1 : 0;
72 $u->set_prop( opt_getselfemail => $val );
74 return 1;