Skip to content

Commit

Permalink
Merge pull request #1492 from ikedas/issue-1424 by ikedas
Browse files Browse the repository at this point in the history
Deprecate `conf_2_db` feature (#1424)
  • Loading branch information
ikedas authored Nov 16, 2022
2 parents 2dd326f + f0e6fec commit 43a6a8c
Show file tree
Hide file tree
Showing 20 changed files with 420 additions and 575 deletions.
62 changes: 22 additions & 40 deletions default/web_tt2/edit_config.tt2
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- edit_config.tt2 -->

<div class="block">
<h2>[%|loc%]Edit robot config[%END%]</h2><br />
<h2>[%|loc%]View domain config[%END%]</h2>
<div>
<ul>
[% FOREACH confparam IN editable_params %]
Expand Down Expand Up @@ -35,45 +35,27 @@
[% SET dark='1'%]
<tr class="color0">
[% END %]
<form action="[% path_cgi %]" method="post">
<td [% IF confparam.query ~%] data-tooltip aria-haspopup="true" title="[% confparam.query %]" [%~ END %]>
<strong>[% confparam.name %]</strong>
</td>
<td>
[% IF confparam.edit == '1' && removethistesttoenblefeature == '1' %]
<input type="text" name="conf_new_value" value="[% confparam.current_value %]" style="width:75%"/>
<input type="hidden" name="conf_parameter_name" value="[% confparam.name %]" />
<input class="MainMenuLinks" type="submit" name="action_edit_config" value="[%|loc%]Set[%END%]" style="width:20%" />
[% ELSE %]
[% UNLESS confparam.obfuscated == '1' %]
[% confparam.current_value %]
[% ELSE %]
[% confparam.current_value.replace('.','*') %]
[% END %]
[% END %]
</td>
<td>
[% IF confparam.vhost == '1' ~%]
[% IF confparam.edit == '1' && removethistesttoenblefeature == '1' %]
[%~ IF robots ~%]
<select name="robot">
[% FOREACH vr = robots ~%]
<option value="[% vr.key %]" [%~ IF vr.key == robot %] selected="selected" [% END ~%]>[% vr.key %]</option>
[% END %]
</select>
[%~ ELSE ~%]
<input type="hidden" name="robot" value="[% robot %]" />
[%~ robot %]
[%~ END %]
[%~ ELSE ~%]
[% robot %]
[%~ END %]
[%~ ELSE ~%]
[%|loc%]main conf[%END%]
[%~ END %]
</td>
<td>[% confparam.default %]</td>
</form>
<td [% IF confparam.query %]
data-tooltip aria-haspopup="true"
title="[% confparam.query %]"
[%~ END %]>
<strong>[% confparam.name %]</strong>
</td>
<td>
[% UNLESS confparam.obfuscated == '1' %]
[% confparam.current_value %]
[% ELSE %]
[% confparam.current_value.replace('.','*') %]
[% END %]
</td>
<td>
[% IF confparam.vhost == '1' ~%]
[% robot %]
[%~ ELSE ~%]
[%|loc%]main conf[%END%]
[%~ END %]
</td>
<td>[% confparam.default %]</td>
</tr>
[% SET close_table = '</table>' %]
[% END %]
Expand Down
8 changes: 6 additions & 2 deletions default/web_tt2/nav.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@
[% SET class = '' %]
[% END %]
<li class="[% class %]">
<a href="[% 'serveradmin/vhosts' | url_rel %]">[%|loc%]Virtual Robots[%END%]</a>
<a href="[% 'serveradmin/vhosts' | url_rel %]">
[%|loc%]Domains[%END%]
</a>
</li>
[%~ END %]
[% IF main_robot ~%]
Expand All @@ -116,7 +118,9 @@
[% SET class = '' %]
[% END %]
<li class="[% class %]">
<a href="[% 'edit_config' | url_rel %]">[%|loc%]Edit Robot Config[%END%]</a>
<a href="[% 'edit_config' | url_rel %]">
[%|loc%]View domain config[%END%]
</a>
</li>
[%~ END %]
[% IF families -%]
Expand Down
18 changes: 4 additions & 14 deletions default/web_tt2/serveradmin.tt2
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

[% IF main_robot %]
[% IF subaction == 'vhosts' %]
<h2>[%|loc%]Virtual Robots[%END%]</h2> <br />
<h2>[%|loc%]Domains[%END%]</h2> <br />
[% IF robots %]
<p>
[%|loc%]The following virtual robots are running on this server:[%END%]
[%|loc%]The following mail domains are running on this server:[%END%]
</p>
[% FOREACH vr = robots %]
<h4>
Expand Down Expand Up @@ -56,7 +56,7 @@
</ul>
[% END %]
[% ELSE %]
<p>[%|loc%]No Virtual Robot defined on this server[%END%]</p>
<p>[%|loc%]No additional mail domains defined on this server.[%END%]</p>
[% END %]
[% END %]
[% END %]
Expand Down Expand Up @@ -266,17 +266,7 @@
[% END %]
<td>[% confparam.name %]</td>
<td>
[% IF confparam.edit == '1' %]
<form action="[% path_cgi %]" method="post">
<fieldset>
<input type="text" name="new_value" value="[% confparam.current_value %]" style="width:75%"/>
<input type="hidden" name="conf_parameter_name" value="[% confparam.name %]" />
<input class="MainMenuLinks" type="submit" name="action_set_param" value="[%|loc%]Set[%END%]" style="width:20%" />
</fieldset>
</form>
[% ELSE %]
[% confparam.current_value %]
[% END %]
[% confparam.current_value %]
</td>
<td>[% confparam.default %]</td>
<td>[% confparam.query %]</td>
Expand Down
29 changes: 15 additions & 14 deletions doc/sympa_config.podpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,7 @@ foreach my $key (_keys($pinfo)) {
my $pii = $pinfo->{$key};
my $ppi = [$key];

if ($key eq 'color_0') {
$parameters .= "=head3 C<color_0>, ..., C<color_15>\n\n";
} elsif ($key =~ /\Acolor_/) {
next;
} elsif ($key eq 'dark_color') {
$parameters .=
"=head3 C<dark_color>, C<light_color>, C<text_color>, C<bg_color>, C<error_color>, C<selected_color>, C<shaded_color>\n\n";
} elsif ($key =~ /_color\z/) {
next;
} elsif ($key eq 'main_menu_custom_button_1_title') {
if ($key eq 'main_menu_custom_button_1_title') {
$parameters .=
"=head3 C<main_menu_custom_button_1_title>, ... C<main_menu_custom_button_3_title>, C<main_menu_custom_button_1_url>, ... C<main_menu_custom_button_3_url>, C<main_menu_custom_button_1_target>, ... C<main_menu_custom_button_3_target>\n\n";
} elsif ($key =~ /\Amain_menu_custom_button_/) {
Expand Down Expand Up @@ -97,7 +88,19 @@ foreach my $okey (
my $pii = $pinfo->{$okey};
my $ppi = [$okey];

$parameters .= sprintf "=head3 C<%s>\n\n", _escape_pod($okey);
if ($okey eq 'color_0') {
$parameters .= "=head3 C<color_0>, ..., C<color_15>\n\n";
$parameters .= "See description on web interface.\n";
} elsif ($okey eq 'dark_color') {
$parameters .= "=head3 C<dark_color>, C<light_color>,\n";
$parameters .= "C<text_color>, C<bg_color>, C<error_color>,\n";
$parameters .= "C<selected_color>, C<shaded_color>\n\n";
$parameters .= "See description on web interface.\n";
} elsif ($okey =~ /\Acolor_/ or $okey =~ /_color\z/) {
next;
} else {
$parameters .= sprintf "=head3 C<%s>\n\n", _escape_pod($okey);
}
_render($pii, $ppi);
}
}
Expand Down Expand Up @@ -314,9 +317,7 @@ sub _default {
my $fullname = join '.', @$pnames;

$parameters .= "=item Default:\n\n";
if ($fullname =~ /\Acolor_/ or $fullname =~ /_color\z/) {
$parameters .= "See description on web interface.\n\n";
} elsif (exists $pinfo->{default}) {
if (exists $pinfo->{default}) {
if (exists $pinfo->{default_s}) {
my $default = $pinfo->{default_s};
$parameters .= sprintf "C<%s>\n\n", $default;
Expand Down
50 changes: 6 additions & 44 deletions src/cgi/wwsympa.fcgi.in
Original file line number Diff line number Diff line change
Expand Up @@ -5983,46 +5983,6 @@ sub do_edit_config {
}
}

if ($in{'conf_new_value'}) {
my $editable;
my $i;
foreach my $p (@$editable_params) {
next unless $p->{'name'};

# if the parameter is editable and if the is a change
next unless $p->{'name'} eq $in{'conf_parameter_name'};
unless ($p->{'edit'} and $p->{'edit'} eq '1') {
$log->syslog(
'err',
'Ignoring change of parameter %s (value %s) because not editable',
$in{'conf_parameter_name'},
$in{'conf_new_value'}
);
last;
}
if ($in{'conf_new_value'} eq $p->{'current_value'}) {
$log->syslog(
'notice',
'Ignoring change of parameter %s (value %s) because inchanged',
$in{'conf_parameter_name'},
$in{'conf_new_value'}
);
last;
} else {
$p->{'current_value'} = $in{'conf_new_value'};
Conf::set_robot_conf($robot, $in{'conf_parameter_name'},
$in{'conf_new_value'});
$log->syslog(
'notice',
'Setting parameter %s to value %s',
$in{'conf_parameter_name'},
$in{'conf_new_value'}
);
last;
}
}
}

$param->{'editable_params'} = $editable_params;
return 1;

Expand Down Expand Up @@ -6816,7 +6776,7 @@ sub do_skinsedit {
$session->{$cn} = lc $in{$cn}
if $in{$cn} and $in{$cn} =~ /\A#[0-9a-z]+\z/i;

my $cur_color = Conf::get_robot_conf($robot, $cn);
my $cur_color = Sympa::WWW::Tools::get_color($robot, $cn);
unless ($session->{$cn}) {
$session->{$cn} = $cur_color;
} elsif ($session->{$cn} ne $cur_color) {
Expand All @@ -6829,7 +6789,8 @@ sub do_skinsedit {
# Update config.
my @keys = grep { $session->{$_} } @std_color_names;
foreach my $key (@keys) {
Conf::set_robot_conf($robot, $key, $session->{$key});
Sympa::WWW::Tools::set_color($robot, $key,
$session->{$key});
}
# Force update CSS.
Sympa::WWW::Tools::get_css_url($robot, force => 1);
Expand All @@ -6844,11 +6805,12 @@ sub do_skinsedit {

$param->{'custom_css'} = $session->{'custom_css'};
foreach my $cn (@std_color_names) {
$param->{$cn} = $session->{$cn} || Conf::get_robot_conf($robot, $cn);
$param->{$cn} =
$session->{$cn} || Sympa::WWW::Tools::get_color($robot, $cn);
}
# Compat.
foreach my $cn (@obs_color_names) {
$param->{$cn} = Conf::get_robot_conf($robot, $cn);
$param->{$cn} = Sympa::WWW::Tools::get_color($robot, $cn);
}

return 1;
Expand Down
Loading

0 comments on commit 43a6a8c

Please sign in to comment.