diff --git a/default/web_tt2/edit_config.tt2 b/default/web_tt2/edit_config.tt2 index 853f44c08..e0c133ae4 100644 --- a/default/web_tt2/edit_config.tt2 +++ b/default/web_tt2/edit_config.tt2 @@ -1,7 +1,7 @@
-

[%|loc%]Edit robot config[%END%]


+

[%|loc%]View domain config[%END%]

[% END %] [% ELSE %] -

[%|loc%]No Virtual Robot defined on this server[%END%]

+

[%|loc%]No additional mail domains defined on this server.[%END%]

[% END %] [% END %] [% END %] @@ -266,17 +266,7 @@ [% END %] [% confparam.name %] - [% IF confparam.edit == '1' %] -
-
- - - -
-
- [% ELSE %] - [% confparam.current_value %] - [% END %] + [% confparam.current_value %] [% confparam.default %] [% confparam.query %] diff --git a/doc/sympa_config.podpl b/doc/sympa_config.podpl index ebc5fccd2..c3af654e8 100644 --- a/doc/sympa_config.podpl +++ b/doc/sympa_config.podpl @@ -37,16 +37,7 @@ foreach my $key (_keys($pinfo)) { my $pii = $pinfo->{$key}; my $ppi = [$key]; - if ($key eq 'color_0') { - $parameters .= "=head3 C, ..., C\n\n"; - } elsif ($key =~ /\Acolor_/) { - next; - } elsif ($key eq 'dark_color') { - $parameters .= - "=head3 C, C, C, C, C, C, C\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, ... C, C, ... C, C, ... C\n\n"; } elsif ($key =~ /\Amain_menu_custom_button_/) { @@ -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, ..., C\n\n"; + $parameters .= "See description on web interface.\n"; + } elsif ($okey eq 'dark_color') { + $parameters .= "=head3 C, C,\n"; + $parameters .= "C, C, C,\n"; + $parameters .= "C, C\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); } } @@ -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; diff --git a/src/cgi/wwsympa.fcgi.in b/src/cgi/wwsympa.fcgi.in index 0bf7b8728..1b5b25fcb 100644 --- a/src/cgi/wwsympa.fcgi.in +++ b/src/cgi/wwsympa.fcgi.in @@ -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; @@ -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) { @@ -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); @@ -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; diff --git a/src/lib/Conf.pm b/src/lib/Conf.pm index 7f6caaeb8..e8a0c5b7b 100644 --- a/src/lib/Conf.pm +++ b/src/lib/Conf.pm @@ -36,7 +36,6 @@ use English qw(-no_match_vars); use Sympa; use Sympa::ConfDef; use Sympa::Constants; -use Sympa::DatabaseManager; use Sympa::Language; use Sympa::Log; use Sympa::Regexps; @@ -58,8 +57,6 @@ my $log = Sympa::Log->instance; =cut -## Database and SQL statement handlers -my $sth; # parameters hash, keyed by parameter name our %params = map { $_->{name} => $_ } @@ -67,13 +64,10 @@ our %params = # valid virtual host parameters, keyed by parameter name my %valid_robot_key_words; -my %db_storable_parameters; my %optional_key_words; foreach my $hash (@Sympa::ConfDef::params) { $valid_robot_key_words{$hash->{'name'}} = 1 if ($hash->{'vhost'}); - $db_storable_parameters{$hash->{'name'}} = 1 - if (defined($hash->{'db'}) and $hash->{'db'} ne 'none'); - $optional_key_words{$hash->{'name'}} = 1 if ($hash->{'optional'}); + $optional_key_words{$hash->{'name'}} = 1 if ($hash->{'optional'}); } our $params_by_categories = _get_parameters_names_by_category(); @@ -138,7 +132,7 @@ do not change gloval hash %Conf if RETURN_RESULT is set; sub load { my $config_file = shift || get_sympa_conf(); - my $no_db = shift; + my $no_db = shift; # No longer used. my $return_result = shift; my $force_reload; @@ -196,8 +190,6 @@ sub load { $missing_modules_count); } - _replace_file_value_by_db_value({'config_hash' => \%Conf}) - unless ($no_db); _load_server_specific_secondary_config_files({'config_hash' => \%Conf,}); _load_robot_secondary_config_files({'config_hash' => \%Conf}); @@ -205,7 +197,6 @@ sub load { unless ( load_robots( { 'config_hash' => \%Conf, - 'no_db' => $no_db, 'force_reload' => $force_reload } ) @@ -238,7 +229,6 @@ sub load_robots { unless ( $robot_conf = _load_single_robot_config( { 'robot' => $robot, - 'no_db' => $param->{'no_db'}, 'force_reload' => $param->{'force_reload'} } ) @@ -375,183 +365,15 @@ sub get_parameters_group { return $param_hash; } -## fetch the value from parameter $label of robot $robot from conf_table -sub get_db_conf { - my $robot = shift; - my $label = shift; +# Moved to: Sympa::WWW::Tools::get_color(). +#sub get_db_conf; - # if the value is related to a robot that is not explicitly defined, apply - # it to the default robot. - $robot = '*' unless (-f $Conf{'etc'} . '/' . $robot . '/robot.conf'); - unless ($robot) { $robot = '*' } - - my $sdm = Sympa::DatabaseManager->instance; - unless ( - $sdm - and $sth = $sdm->do_prepared_query( - q{SELECT value_conf AS value - FROM conf_table - WHERE robot_conf = ? AND label_conf = ?}, - $robot, $label - ) - ) { - $log->syslog( - 'err', - 'Unable retrieve value of parameter %s for robot %s from the database', - $label, - $robot - ); - return undef; - } - - my $value = $sth->fetchrow; - - $sth->finish(); - return $value; -} - -## store the value from parameter $label of robot $robot from conf_table -sub set_robot_conf { - my $robot = shift; - my $label = shift; - my $value = shift; - - $log->syslog('info', 'Set config for robot %s, %s="%s"', - $robot, $label, $value); - - # set the current config before to update database. - if (-f "$Conf{'etc'}/$robot/robot.conf") { - $Conf{'robots'}{$robot}{$label} = $value; - } else { - $Conf{$label} = $value; - $robot = '*'; - } - - my $sdm = Sympa::DatabaseManager->instance; - unless ( - $sdm - and $sth = $sdm->do_prepared_query( - q{SELECT COUNT(*) - FROM conf_table - WHERE robot_conf = ? AND label_conf = ?}, - $robot, $label - ) - ) { - $log->syslog( - 'err', - 'Unable to check presence of parameter %s for robot %s in database', - $label, - $robot - ); - return undef; - } - - my $count = $sth->fetchrow; - $sth->finish(); - - if ($count == 0) { - unless ( - $sth = $sdm->do_prepared_query( - q{INSERT INTO conf_table - (robot_conf, label_conf, value_conf) - VALUES (?, ?, ?)}, - $robot, $label, $value - ) - ) { - $log->syslog( - 'err', - 'Unable add value %s for parameter %s in the robot %s DB conf', - $value, - $label, - $robot - ); - return undef; - } - } else { - unless ( - $sth = $sdm->do_prepared_query( - q{UPDATE conf_table - SET robot_conf = ?, label_conf = ?, value_conf = ? - WHERE robot_conf = ? AND label_conf = ?}, - $robot, $label, $value, - $robot, $label - ) - ) { - $log->syslog( - 'err', - 'Unable set parameter %s value to %s in the robot %s DB conf', - $label, - $value, - $robot - ); - return undef; - } - } -} +# Moved to: Sympa::WWW::Tools::set_color(). +#sub set_robot_conf; # Store configs to database -sub conf_2_db { - $log->syslog('debug2', '(%s)', @_); - - my @conf_parameters = @Sympa::ConfDef::params; - - # store in database robots parameters. - # load only parameters that are in a robot.conf file (do not apply - # defaults). - my $robots_conf = load_robots(); - - my $robots_ref = get_robots_list(); - return undef unless $robots_ref; - - foreach my $robot (@$robots_ref) { - my $config; - if (my $result_of_config_loading = _load_config_file_to_hash( - $Conf{'etc'} . '/' . $robot . '/robot.conf' - ) - ) { - $config = $result_of_config_loading->{'config'}; - } - _remove_unvalid_robot_entry($config); - - for my $i (0 .. $#conf_parameters) { - if ($conf_parameters[$i]->{'name'}) { - # skip separators in conf_parameters structure - if (($conf_parameters[$i]->{'vhost'} eq '1') - && #skip parameters that can't be define by robot so not to be loaded in db at that stage - ($config->{$conf_parameters[$i]->{'name'}}) - ) { - Conf::set_robot_conf( - $robot, - $conf_parameters[$i]->{'name'}, - $config->{$conf_parameters[$i]->{'name'}} - ); - } - } - } - } - - # Store sympa.conf into database. - - ## Load configuration file. Ignoring database config and get result - my $global_conf; - unless ($global_conf = - Conf::load(Conf::get_sympa_conf(), 1, 'return_result')) { - $log->syslog('err', 'Configuration file %s has errors', - Conf::get_sympa_conf()); - return undef; - } - - for my $i (0 .. $#conf_parameters) { - if (($conf_parameters[$i]->{'edit'} eq '1') - && $global_conf->{$conf_parameters[$i]->{'name'}}) { - Conf::set_robot_conf( - "*", - $conf_parameters[$i]->{'name'}, - $global_conf->{$conf_parameters[$i]->{'name'}}[0] - ); - } - } -} +# Deprecated. +#sub conf_2_db; ## Check required files and create them if required sub checkfiles_as_root { @@ -2042,8 +1864,6 @@ sub _load_single_robot_config { #XXX {'config_hash' => $robot_conf, 'source_file' => $config_file}); return undef if ($config_err); - _replace_file_value_by_db_value({'config_hash' => $robot_conf}) - unless $param->{'no_db'}; _load_robot_secondary_config_files({'config_hash' => $robot_conf}); return $robot_conf; } @@ -2090,19 +1910,8 @@ sub _parse_custom_robot_parameters { } } -sub _replace_file_value_by_db_value { - my $param = shift; - my $robot = $param->{'config_hash'}{'robot_name'}; - # The name of the default robot is "*" in the database. - $robot = '*' if ($param->{'config_hash'}{'robot_name'} eq ''); - foreach my $label (keys %db_storable_parameters) { - next unless ($robot ne '*' && $valid_robot_key_words{$label} == 1); - my $value = get_db_conf($robot, $label); - if (defined $value) { - $param->{'config_hash'}{$label} = $value; - } - } -} +# Deprecated: No longer used. +#sub _replace_file_value_by_db_value; # Stores the config hash binary representation to a file. # Returns 1 or undef if something went wrong. diff --git a/src/lib/Makefile.am b/src/lib/Makefile.am index afb6e0e72..792491c00 100644 --- a/src/lib/Makefile.am +++ b/src/lib/Makefile.am @@ -35,7 +35,6 @@ CLI_modules = \ Sympa/CLI/bouncers/reset.pm \ Sympa/CLI/check.pm \ Sympa/CLI/close.pm \ - Sympa/CLI/conf_2_db.pm \ Sympa/CLI/config.pm \ Sympa/CLI/config/create.pm \ Sympa/CLI/config/show.pm \ diff --git a/src/lib/Sympa/CLI.pm b/src/lib/Sympa/CLI.pm index 928cd1853..83dc41723 100644 --- a/src/lib/Sympa/CLI.pm +++ b/src/lib/Sympa/CLI.pm @@ -236,7 +236,7 @@ sub arrange { # Moved from: _load() in sympa.pl. ## Load sympa.conf. - unless (Conf::load($options{config}, 'no_db')) { + unless (Conf::load($options{config})) { die sprintf "Unable to load sympa configuration, file %s or one of the vhost robot.conf files contain errors. Exiting.\n", Conf::get_sympa_conf(); @@ -274,13 +274,6 @@ sub arrange { $Conf::Conf{'db_name'}; } - # Now trying to load full config (including database) - unless (Conf::load()) { - die sprintf - "Unable to load Sympa configuration, file %s or any of the virtual host robot.conf files contain errors. Exiting.\n", - Conf::get_sympa_conf(); - } - $language->set_lang($Conf::Conf{'lang'}) unless $options{lang}; ## Main program @@ -409,14 +402,14 @@ sub _translate_warn { $SIG{__WARN__} = sub { warn _translate_warn(shift) }; my $arg_labels = { - list => {gettext_id => 'list'}, - list_id => {gettext_id => 'list'}, - family => {gettext_id => 'family'}, - domain => {gettext_id => 'domain'}, - site => {gettext_id => '"*"'}, - command => {gettext_id => 'command'}, - string => {gettext_id => 'string'}, - email => {gettext_id => 'email address'}, + list => {gettext_id => 'list'}, + list_id => {gettext_id => 'list'}, + family => {gettext_id => 'family'}, + domain => {gettext_id => 'domain'}, + site => {gettext_id => '"*"'}, + command => {gettext_id => 'command'}, + string => {gettext_id => 'string'}, + email => {gettext_id => 'email address'}, keyvalue => {gettext_id => '"key=value"'}, }; diff --git a/src/lib/Sympa/CLI/bouncers/reset.pm b/src/lib/Sympa/CLI/bouncers/reset.pm index a9b25e6d3..af34b7269 100644 --- a/src/lib/Sympa/CLI/bouncers/reset.pm +++ b/src/lib/Sympa/CLI/bouncers/reset.pm @@ -55,7 +55,8 @@ sub _run { ) { $users++; } else { - printf STDERR "Unable to cancel bounce error for %s.\n", $i->{email}; + printf STDERR "Unable to cancel bounce error for %s.\n", + $i->{email}; } $errors++; } diff --git a/src/lib/Sympa/CLI/check.pm b/src/lib/Sympa/CLI/check.pm index e8d1970dc..79588e7cf 100644 --- a/src/lib/Sympa/CLI/check.pm +++ b/src/lib/Sympa/CLI/check.pm @@ -44,7 +44,7 @@ sub _run { # Load configuration file. Ignoring database config for now: it avoids # trying to load a database that could not exist yet. - unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) { + unless (Conf::load(Conf::get_sympa_conf())) { #FIXME: force reload die sprintf "Configuration file %s has errors.\n", @@ -95,13 +95,6 @@ sub _run { $Conf::Conf{'db_name'}; } - ## Now trying to load full config (including database) - unless (Conf::load()) { #FIXME: load Site, then robot cache - die sprintf - "Unable to load Sympa configuration, file %s or any of the virtual host robot.conf files contain errors. Exiting.\n", - Conf::get_sympa_conf(); - } - ## Change working directory. if (!chdir($Conf::Conf{'home'})) { printf STDERR "Can't chdir to %s: %s\n", $Conf::Conf{'home'}, $ERRNO; diff --git a/src/lib/Sympa/CLI/conf_2_db.pm b/src/lib/Sympa/CLI/conf_2_db.pm deleted file mode 100644 index 046ea50e4..000000000 --- a/src/lib/Sympa/CLI/conf_2_db.pm +++ /dev/null @@ -1,69 +0,0 @@ -# -*- indent-tabs-mode: nil; -*- -# vim:ft=perl:et:sw=4 - -# Sympa - SYsteme de Multi-Postage Automatique -# -# Copyright 2021 The Sympa Community. See the -# AUTHORS.md file at the top-level directory of this distribution and at -# . -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see . - -package Sympa::CLI::conf_2_db; - -use strict; -use warnings; - -use Conf; - -use parent qw(Sympa::CLI); - -use constant _options => qw(); -use constant _args => qw(); -use constant _log_to_stderr => 1; - -sub _run { - my $class = shift; - my $options = shift; - - printf - "Sympa is going to store %s in database conf_table. This operation do NOT remove original files\n", - Conf::get_sympa_conf(); - if (Conf::conf_2_db()) { - printf "Done"; - } else { - printf "an error occur"; - } - exit 1; - -} - -1; -__END__ - -=encoding utf-8 - -=head1 NAME - -sympa-conf_2_db - Load config into the database - -=head1 SYNOPSIS - -C - -=head1 DESCRIPTION - -Load sympa.conf and each robot.conf into database. - -=cut diff --git a/src/lib/Sympa/CLI/review.pm b/src/lib/Sympa/CLI/review.pm index a0321eff5..2a06683a8 100644 --- a/src/lib/Sympa/CLI/review.pm +++ b/src/lib/Sympa/CLI/review.pm @@ -40,18 +40,15 @@ sub _run { my $list = shift; if ($list) { - my @members = $list->get_members( - 'unconcealed_member', - order => 'email' - ); + my @members = + $list->get_members('unconcealed_member', order => 'email'); my @bounced = (); my @suspended = (); - printf "%i member(s) in list %s.\n", - scalar(@members), $list->get_id; + printf "%i member(s) in list %s.\n", scalar(@members), $list->get_id; for my $member (@members) { printf "%s\n", $member->{email}; - push @bounced, $member->{'email'} + push @bounced, $member->{'email'} if defined $member->{'bounce'}; push @suspended, $member->{'email'} if defined $member->{'suspend'}; diff --git a/src/lib/Sympa/CLI/upgrade/password.pm b/src/lib/Sympa/CLI/upgrade/password.pm index dc557479f..15be22abe 100644 --- a/src/lib/Sympa/CLI/upgrade/password.pm +++ b/src/lib/Sympa/CLI/upgrade/password.pm @@ -70,17 +70,17 @@ sub _run { STDOUT->autoflush(1); -# -# For safety, dry_run disables all modifications -# + # + # For safety, dry_run disables all modifications + # if ($dry_run) { $savecache = $updateuser = 0; } die 'Error in configuration' - unless Conf::load($config, 'no_db'); + unless Conf::load($config); -# Get obsoleted parameter. + # Get obsoleted parameter. open my $fh, '<', $config or die $ERRNO; my ($cookie) = grep {defined} map { /\A\s*cookie\s+(\S+)/s ? $1 : undef } <$fh>; @@ -89,9 +89,9 @@ sub _run { my $password_hash = Conf::get_robot_conf('*', 'password_hash'); my $bcrypt_cost = Conf::get_robot_conf('*', 'bcrypt_cost'); -# -# Handle the cache if specfied -# + # + # Handle the cache if specfied + # my $hashes = {}; my $hashes_changed = 0; @@ -100,9 +100,9 @@ sub _run { $hashes = read_hashes($cache = $options->{'cache'}); } -# -# Retrieve user records and update each in turn -# + # + # Retrieve user records and update each in turn + # print "Recoding password using $password_hash fingerprint.\n"; $dry_run && print "dry_run: database will *not* be updated.\n"; @@ -110,7 +110,7 @@ sub _run { or die 'Can\'t connect to database'; my $sth; -# Check if RC4 decryption required. + # Check if RC4 decryption required. $sth = $sdm->do_prepared_query( q{SELECT COUNT(*) FROM user_table WHERE password_user LIKE 'crypt.%'} ); @@ -233,13 +233,13 @@ sub _run { $sth->finish(); -# save hashes for later if hash db file is specified + # save hashes for later if hash db file is specified if (defined($cache) && $savecache && $hashes_changed) { printf "Saving hashes in %s\n", $cache; save_hashes($cache, $hashes); } -# print a roundup of changes + # print a roundup of changes foreach my $hash_type ('md5', 'bcrypt') { if ($total->{$hash_type}) { diff --git a/src/lib/Sympa/Config/Schema.pm b/src/lib/Sympa/Config/Schema.pm index 1ac6e6f4e..82ba17bfd 100644 --- a/src/lib/Sympa/Config/Schema.pm +++ b/src/lib/Sympa/Config/Schema.pm @@ -5367,168 +5367,141 @@ our %pinfo = ( color_0 => { context => [qw(domain site)], - order => 120.10, - group => 'www_appearances', - gettext_id => 'Colors for web interface', - gettext_comment => - 'Colors are used in style sheet (CSS). They may be changed using web interface by listmasters.', - default => '#f7f7f7', # very light grey use in tables, - db => 'db_first', + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_1 => { - context => [qw(domain site)], - order => 120.11, - group => 'www_appearances', - default => '#222222', # main menu button color, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_2 => { - context => [qw(domain site)], - order => 120.12, - group => 'www_appearances', - default => '#004b94', # font color, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_3 => { - context => [qw(domain site)], - order => 120.13, - group => 'www_appearances', - default => '#5e5e5e', # top boxe and footer box bacground color, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_4 => { - context => [qw(domain site)], - order => 120.14, - group => 'www_appearances', - default => '#4c4c4c', # page backgound color, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_5 => { - context => [qw(domain site)], - order => 120.15, - group => 'www_appearances', - default => '#0090e9', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_6 => { - context => [qw(domain site)], - order => 120.16, - group => 'www_appearances', - default => '#005ab2', # list menu current button, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_7 => { - context => [qw(domain site)], - order => 120.17, - group => 'www_appearances', - default => '#ffffff', # errorbackground color, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_8 => { - context => [qw(domain site)], - order => 120.18, - group => 'www_appearances', - default => '#f2f6f9', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_9 => { - context => [qw(domain site)], - order => 120.19, - group => 'www_appearances', - default => '#bfd2e1', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_10 => { - context => [qw(domain site)], - order => 120.20, - group => 'www_appearances', - default => '#983222', # inactive button, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_11 => { - context => [qw(domain site)], - order => 120.21, - group => 'www_appearances', - default => '#66aaff', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_12 => { - context => [qw(domain site)], - order => 120.22, - group => 'www_appearances', - default => '#ffe7e7', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_13 => { - context => [qw(domain site)], - order => 120.23, - group => 'www_appearances', - default => '#f48a7b', # input backgound | transparent, - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_14 => { - context => [qw(domain site)], - order => 120.24, - group => 'www_appearances', - default => '#ffff99', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, color_15 => { - context => [qw(domain site)], - order => 120.25, - group => 'www_appearances', - default => '#fe57a1', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '5.1b', + not_after => '6.2.70', }, dark_color => { context => [qw(domain site)], - order => 120.30, - group => 'www_appearances', - gettext_id => 'Colors for web interface, obsoleted', - default => '#c0c0c0', # 'silver' - db => 'db_first', + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, light_color => { - context => [qw(domain site)], - order => 120.31, - group => 'www_appearances', - default => '#aaddff', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, text_color => { - context => [qw(domain site)], - order => 120.32, - group => 'www_appearances', - default => '#000000', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, bg_color => { - context => [qw(domain site)], - order => 120.33, - group => 'www_appearances', - default => '#ffffcc', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, error_color => { - context => [qw(domain site)], - order => 120.34, - group => 'www_appearances', - default => '#ff6666', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, selected_color => { - context => [qw(domain site)], - order => 120.35, - group => 'www_appearances', - default => '#c0c0c0', # 'silver' - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, shaded_color => { - context => [qw(domain site)], - order => 120.36, - group => 'www_appearances', - default => '#66cccc', - db => 'db_first', + context => [qw(domain site)], + obsolete => 1, + not_before => '3.3a', + not_after => '6.2.70', }, default_home => { context => [qw(domain site)], @@ -6735,8 +6708,8 @@ It remains there in order to migrating older versions of config. =item db +Deprecated. 'db_first', 'file_first' or 'no'. -TBD. =item importance diff --git a/src/lib/Sympa/Regexps.pm b/src/lib/Sympa/Regexps.pm index 898627402..ee6f2a1a0 100644 --- a/src/lib/Sympa/Regexps.pm +++ b/src/lib/Sympa/Regexps.pm @@ -70,7 +70,7 @@ use constant ldap_attrdesc => qr'\w[-\w]*(?:;[-\w]+)*'; # RFC2251, 4.1.5 use constant rfc2045_parameter_value => qr'[^\s\x00-\x1F\x7F-\xFF()<>\@,;:\\/\[\]?=\"]+'; -use constant sql_query => qr'(SELECT|select).*'; +use constant sql_query => qr'(SELECT|select).*'; # "scenario" was deprecated. Use "scenario_name". # "scenario_config" is used for compatibility to earlier list config files. diff --git a/src/lib/Sympa/Request/Handler/open_list.pm b/src/lib/Sympa/Request/Handler/open_list.pm index cb1b7be2d..b182eab4e 100644 --- a/src/lib/Sympa/Request/Handler/open_list.pm +++ b/src/lib/Sympa/Request/Handler/open_list.pm @@ -95,7 +95,7 @@ sub _twist { Conf::get_robot_conf($list->{'domain'}, 'alias_manager')); if ($aliases and $aliases->add($list)) { $self->add_stash($request, 'notice', 'auto_aliases', - { listname => $list->{'name'} .'@' . $list->{'domain'} }); + {listname => $list->{'name'} . '@' . $list->{'domain'}}); } else { ; } diff --git a/src/lib/Sympa/WWW/Tools.pm b/src/lib/Sympa/WWW/Tools.pm index 1860c81bb..d299f568f 100644 --- a/src/lib/Sympa/WWW/Tools.pm +++ b/src/lib/Sympa/WWW/Tools.pm @@ -39,6 +39,7 @@ use Sympa; use Conf; use Sympa::ConfDef; use Sympa::Constants; +use Sympa::DatabaseManager; use Sympa::Language; use Sympa::List; use Sympa::LockedFile; @@ -174,6 +175,101 @@ our %bounce_status = ( '7.30' => 'REQUIRETLS support required', ); +our %css_colors = ( + color_0 => { + order => 0, + default => '#f7f7f7', # very light grey use in tables, + }, + color_1 => { + order => 1, + default => '#222222', # main menu button color, + }, + color_2 => { + order => 2, + default => '#004b94', # font color, + }, + color_3 => { + order => 3, + default => '#5e5e5e', # top boxe and footer box bacground color, + }, + color_4 => { + order => 4, + default => '#4c4c4c', # page backgound color, + }, + color_5 => { + order => 5, + default => '#0090e9', + }, + color_6 => { + order => 6, + default => '#005ab2', # list menu current button, + }, + color_7 => { + order => 7, + default => '#ffffff', # errorbackground color, + }, + color_8 => { + order => 8, + default => '#f2f6f9', + }, + color_9 => { + order => 9, + default => '#bfd2e1', + }, + color_10 => { + order => 10, + default => '#983222', # inactive button, + }, + color_11 => { + order => 11, + default => '#66aaff', + }, + color_12 => { + order => 12, + default => '#ffe7e7', + }, + color_13 => { + order => 13, + default => '#f48a7b', # input backgound | transparent, + }, + color_14 => { + order => 14, + default => '#ffff99', + }, + color_15 => { + order => 15, + default => '#fe57a1', + }, + dark_color => { + order => 100, + default => '#c0c0c0', # 'silver' + }, + light_color => { + order => 101, + default => '#aaddff', + }, + text_color => { + order => 102, + default => '#000000', + }, + bg_color => { + order => 103, + default => '#ffffcc', + }, + error_color => { + order => 104, + default => '#ff6666', + }, + selected_color => { + order => 105, + default => '#c0c0c0', # 'silver' + }, + shaded_color => { + order => 106, + default => '#66cccc', + }, +); + ## Load WWSympa configuration file ##sub load_config ## MOVED: use Conf::_load_wwsconf(). @@ -724,12 +820,16 @@ sub _get_css_url { # Get parameters for parsing. my $param = {}; foreach my $p ( - grep { /_color\z/ or /\Acolor_/ or /_url\z/ } - map { $_->{name} } + grep {/_url\z/} + map { $_->{name} } grep { not $_->{obsolete} and $_->{name} } @Sympa::ConfDef::params ) { $param->{$p} = Conf::get_robot_conf($robot, $p); } + foreach my $cn (Sympa::WWW::Tools::css_colors()) { + $param->{$cn} = Sympa::WWW::Tools::get_color($robot, $cn); + } + if (%colors) { # Override colors for parsing. my @keys = @@ -949,5 +1049,131 @@ sub _get_css_url { # DEPRECATED. No longer used. #sub unescape_html_minimum; +my %color_values; + +sub css_colors { + return sort { $css_colors{$a}->{order} <=> $css_colors{$b}->{order} } + keys %css_colors; +} + +# Fetch the color value for name $label of domain $robot from conf_table. +# Old name: Conf::get_db_conf(). +sub get_color { + my $robot = shift; + my $label = shift; + + my $value = $color_values{$robot}->{$label} + if $color_values{$robot}; + return $value if length($value // ''); + + my $sdm = Sympa::DatabaseManager->instance; + my $sth; + unless ( + $sdm + and $sth = $sdm->do_prepared_query( + q{SELECT value_conf AS value + FROM conf_table + WHERE robot_conf = ? AND label_conf = ?}, + $robot, $label + ) + ) { + $log->syslog( + 'err', + 'Unable retrieve value of parameter %s for robot %s from the database', + $label, + $robot + ); + return undef; + } + $value = $sth->fetchrow; + $sth->finish; + + if (length($value // '')) { + $color_values{$robot} ||= {}; + $color_values{$robot}->{$label} = $value; + return $value; + } + return $css_colors{$label}->{default}; +} + +# store the color value $label of robot $robot to conf_table +# Old name: Conf::set_robot_conf(). +sub set_color { + $log->syslog('debug2', 'Set config for robot %s, %s="%s"', @_); + my $robot = shift; + my $label = shift; + my $value = shift; + + return unless grep { $label eq $_ } Sympa::WWW::Tools::css_colors(); + + # set the current config before to update database. + $color_values{$robot} ||= {}; + $color_values{$robot}->{$label} = $value; + + my $sdm = Sympa::DatabaseManager->instance; + my $sth; + unless ( + $sdm + and $sth = $sdm->do_prepared_query( + q{SELECT COUNT(*) + FROM conf_table + WHERE robot_conf = ? AND label_conf = ?}, + $robot, $label + ) + ) { + $log->syslog( + 'err', + 'Unable to check presence of parameter %s for robot %s in database', + $label, + $robot + ); + return undef; + } + + my $count = $sth->fetchrow; + $sth->finish; + + if ($count == 0) { + unless ( + $sth = $sdm->do_prepared_query( + q{INSERT INTO conf_table + (robot_conf, label_conf, value_conf) + VALUES (?, ?, ?)}, + $robot, $label, $value + ) + ) { + $log->syslog( + 'err', + 'Unable add value %s for parameter %s in the robot %s DB conf', + $value, + $label, + $robot + ); + return undef; + } + } else { + unless ( + $sth = $sdm->do_prepared_query( + q{UPDATE conf_table + SET robot_conf = ?, label_conf = ?, value_conf = ? + WHERE robot_conf = ? AND label_conf = ?}, + $robot, $label, $value, + $robot, $label + ) + ) { + $log->syslog( + 'err', + 'Unable set parameter %s value to %s in the robot %s DB conf', + $label, + $value, + $robot + ); + return undef; + } + } + + return 1; +} + 1; __END__ diff --git a/src/sbin/sympa.pl.in b/src/sbin/sympa.pl.in index 876dab2dc..23b284b85 100644 --- a/src/sbin/sympa.pl.in +++ b/src/sbin/sympa.pl.in @@ -96,7 +96,8 @@ if ($options{'add'}) { } elsif ($options{'close_list'}) { Sympa::CLI->run({}, 'close', $options{close_list}); } elsif ($options{'conf_2_db'}) { - Sympa::CLI->run({}, 'conf_2_db'); + printf STDERR "The --conf_2_db was deprecated.\n"; + exit 1; } elsif ($options{'copy_list'}) { Sympa::CLI->run( {mode => 'copy'}, @@ -306,10 +307,6 @@ Check environment Close a list or the lists belonging to a family -=item L<"sympa conf_2_db"|sympa-conf_2_db(1)> - -Load config into the database - =item L<"sympa config"|sympa-config(1)> Manipulate configuration of Sympa @@ -554,11 +551,12 @@ New command line format: =item C<--conf_2_db> +B. Load sympa.conf and each robot.conf into database. New command line format: -TBD. +None. =item C<--copy_list=>IC<@>I C<--new_listname=>I C<--new_listrobot=>I diff --git a/src/sbin/sympa_automatic.pl.in b/src/sbin/sympa_automatic.pl.in index b64342120..84d8bfce5 100644 --- a/src/sbin/sympa_automatic.pl.in +++ b/src/sbin/sympa_automatic.pl.in @@ -197,7 +197,7 @@ exit(0); # Load configuration. sub _load { ## Load sympa.conf. - unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) { #Site and Robot + unless (Conf::load(Conf::get_sympa_conf())) { #Site and Robot die sprintf "Unable to load sympa configuration, file %s or one of the vhost robot.conf files contain errors. Exiting.\n", Conf::get_sympa_conf(); @@ -234,13 +234,6 @@ sub _load { $Conf::Conf{'db_name'}; } - # Now trying to load full config (including database) - unless (Conf::load()) { #FIXME: load Site, then robot cache - die sprintf - "Unable to load Sympa configuration, file %s or any of the virtual host robot.conf files contain errors. Exiting.\n", - Conf::get_sympa_conf(); - } - ## Main program if (!chdir($Conf::Conf{'home'})) { die sprintf 'Can\'t chdir to %s: %s', $Conf::Conf{'home'}, $ERRNO; diff --git a/src/sbin/sympa_msg.pl.in b/src/sbin/sympa_msg.pl.in index a1642add6..5bc93d0ef 100644 --- a/src/sbin/sympa_msg.pl.in +++ b/src/sbin/sympa_msg.pl.in @@ -277,7 +277,7 @@ exit(0); # Load configuration. sub _load { ## Load sympa.conf. - unless (Conf::load(Conf::get_sympa_conf(), 'no_db')) { #Site and Robot + unless (Conf::load(Conf::get_sympa_conf())) { #Site and Robot die sprintf "Unable to load sympa configuration, file %s or one of the vhost robot.conf files contain errors. Exiting.\n", Conf::get_sympa_conf(); @@ -314,13 +314,6 @@ sub _load { $Conf::Conf{'db_name'}; } - # Now trying to load full config (including database) - unless (Conf::load()) { #FIXME: load Site, then robot cache - die sprintf - "Unable to load Sympa configuration, file %s or any of the virtual host robot.conf files contain errors. Exiting.\n", - Conf::get_sympa_conf(); - } - ## Set locale configuration ## Compatibility with version < 2.3.3 $main::options{'lang'} =~ s/\.cat$//