Commit 51c2020a authored by IKEDA Soji's avatar IKEDA Soji
Browse files

* Cleanup edit_list_request.tt2: Fixing minor bugs and inconsistencies.

* Sympa::ListDef: Adding extended field_type: dayofweek, lang, reception, status, unixtime, visibility.
* wwsympa.fcgi: Simplified do_edit_list_request a bit.
parent 696b5986
This diff is collapsed.
......@@ -12109,68 +12109,11 @@ sub _prepare_edit_form {
foreach my $v (@{$p->{'value'}}) {
next unless ($v->{'name'} eq 'days');
if (ref($v->{'value'}) eq 'ARRAY') {
$log->syslog('debug2',
'Empty digest parameter. Putting a dummy value');
# Empty digest parameter. Putting a dummy value.
$v->{'value'} = undef;
$v->{'type'} = 'enum';
} else {
foreach my $day (keys %{$v->{'value'}}) {
my $t =
$language->gettext_strftime("%A",
gmtime(0 + ($day + 3) * (3600 * 24)));
$t = sprintf '%s (%s)', $t,
$day
if Sympa::is_listmaster($list,
$param->{'user'}{'email'});
$v->{'value'}{$day}{'title'} = $t;
}
}
}
} elsif ($pname eq 'lang') {
$language->push_lang;
foreach my $lang (keys %{$p->{'value'}}) {
$language->set_lang($lang);
my $t = $language->native_name || $lang;
$t = sprintf '%s (%s)', $t, $lang
if Sympa::is_listmaster($list, $param->{'user'}{'email'});
$p->{'value'}{$lang}{'title'} = $t;
# compatibility: 6.1.
$p->{'value'}{$lang}{'lang_tag'} = $lang;
}
$language->pop_lang;
} elsif ($pname eq 'available_user_options'
or $pname eq 'default_user_options') {
foreach my $v (@{$p->{'value'}}) {
if ($v->{'name'} eq 'reception') {
foreach my $x (keys %{$v->{'value'}}) {
$v->{'value'}{$x}{'title'} =
Sympa::ListOpt::get_title(
$x,
'reception',
Sympa::is_listmaster(
$list, $param->{'user'}{'email'}
)
);
}
} elsif ($v->{'name'} eq 'visibility') {
foreach my $x (keys %{$v->{'value'}}) {
$v->{'value'}{$x}{'title'} =
Sympa::ListOpt::get_title(
$x,
'visibility',
Sympa::is_listmaster(
$list, $param->{'user'}{'email'}
)
);
}
}
}
} elsif ($pname eq 'status') {
foreach my $x (keys %{$p->{'value'}}) {
$p->{'value'}{$x}{'title'} =
Sympa::ListOpt::get_title($x, 'status',
Sympa::is_listmaster($list, $param->{'user'}{'email'}));
}
}
 
push @{$param->{'param'}}, $p;
......@@ -12307,6 +12250,9 @@ sub _prepare_data {
$data2 = [$data];
}
 
# filed_type
$p_glob->{field_type} = $struct->{field_type};
my @all_p;
 
## Foreach occurrence of param
......
......@@ -250,6 +250,7 @@ our %pinfo = (
'gettext_id' => "Language of the list",
'format' => [], ## Sympa::get_supported_languages() called later
'file_format' => '\w+(\-\w+)*',
'field_type' => 'lang',
'default' => {'conf' => 'lang'}
},
......@@ -310,6 +311,7 @@ our %pinfo = (
'gettext_id' => "days",
'format' => [0 .. 6],
'file_format' => '1|2|3|4|5|6|7',
'field_type' => 'dayofweek',
'occurrence' => '1-n'
},
'hour' => {
......@@ -351,6 +353,7 @@ our %pinfo = (
'summary', 'nomail', 'txt', 'html',
'urlize', 'not_me'
],
'field_type' => 'reception',
'occurrence' => '1-n',
'split_char' => ',',
'default' =>
......@@ -372,12 +375,14 @@ our %pinfo = (
'summary', 'notice', 'txt', 'html',
'urlize', 'not_me'
],
'field_type' => 'reception',
'default' => 'mail'
},
'visibility' => {
'order' => 2,
'gettext_id' => "visibility",
'format' => ['conceal', 'noconceal'],
'field_type' => 'visibility',
'default' => 'noconceal'
}
},
......@@ -2138,9 +2143,11 @@ our %pinfo = (
},
'date_epoch' => {
'order' => 3,
'gettext_id' => 'epoch date',
'gettext_id' => 'date',
'format' => '\d+',
'occurrence' => '1'
'field_type' => 'unixtime',
'occurrence' => '1',
'length' => 10,
}
},
'internal' => 1
......@@ -2189,9 +2196,11 @@ our %pinfo = (
'format' => {
'date_epoch' => {
'order' => 3,
'gettext_id' => "epoch date",
'gettext_id' => "date",
'format' => '\d+',
'occurrence' => '1'
'field_type' => 'unixtime',
'occurrence' => '1',
'length' => 10,
},
'date' => {
'order' => 2,
......@@ -2230,10 +2239,11 @@ our %pinfo = (
},
'date_epoch' => {
'order' => 3,
'gettext_id' => 'epoch date',
'gettext_id' => 'date',
'format' => '\d+',
'field_type' => 'unixtime',
'occurrence' => '1',
'length' => 8
'length' => 10,
}
},
'internal' => 1,
......@@ -2245,6 +2255,7 @@ our %pinfo = (
'gettext_id' => "Status of the list",
'format' =>
['open', 'closed', 'pending', 'error_config', 'family_closed'],
'field_type' => 'status',
'default' => 'open',
'internal' => 1
},
......@@ -2547,7 +2558,39 @@ that should always be saved in the config file.
=item field_type
Used to select passwords web input type.
Used to special treatment of parameter value to show it.
=over
=item C<'dayofweek'>
Day of week, C<0> - C<6>.
=item C<'lang'>
Language tag.
=item C<'password'>
The value to be concealed.
=item C<'reception'>
Reception mode of list member.
=item C<'status'>
Status of list.
=item C<'unixtime'>
The time in second from Unix epoch.
=item C<'visibility'>
Visibility mode of list memeber.
=back
=item validations
......
......@@ -261,19 +261,46 @@ sub get_title {
my $type = shift || '';
my $withval = shift || 0;
my $map = {
'reception' => \%reception_mode,
'visibility' => \%visibility_mode,
'status' => \%list_status,
}->{$type}
|| \%list_option;
my $t = $map->{$option} || {};
if ($t->{'gettext_id'}) {
my $ret = $language->gettext($t->{'gettext_id'});
$ret =~ s/^\s+//;
$ret =~ s/\s+$//;
return sprintf '%s (%s)', $ret, $option if $withval;
return $ret;
my $title = undef;
if ($type eq 'dayofweek') {
if ($option =~ /\A[0-9]+\z/) {
$title = [
split /:/,
$language->gettext(
'Sunday:Monday:Tuesday:Wednesday:Thursday:Friday:Saturday'
)
]->[$option % 7];
}
} elsif ($type eq 'lang') {
$language->push_lang;
if ($language->set_lang($option)) {
$title = $language->native_name;
}
$language->pop_lang;
} elsif ($type eq 'password') {
return '*' x length($option); # return
} elsif ($type eq 'unixtime') {
$title = $language->gettext_strftime('%d %b %Y at %H:%M:%S',
localtime $option);
} else {
my $map = {
'reception' => \%reception_mode,
'visibility' => \%visibility_mode,
'status' => \%list_status,
}->{$type}
|| \%list_option;
my $t = $map->{$option} || {};
if ($t->{gettext_id}) {
$title = $language->gettext($t->{gettext_id});
$title =~ s/^\s+//;
$title =~ s/\s+$//;
}
}
if (defined $title) {
return sprintf '%s (%s)', $title, $option if $withval;
return $title;
}
return $option;
}
......@@ -312,10 +339,8 @@ Value of option.
=item $type
Type of option.
C<'reception'> (reception mode of list member),
C<'visibility'> (visibility mode of list memeber),
C<'status'> (status of list)
Type of option:
field_type (see L<Sympa::ListDef>)
or other (list config option, default).
=item $withval
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment