X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FEditConfig.pm;h=edc4526d0699fb04ccab4b218db5a07b47ec946d;hp=351f4299b62958cbf76574032a5e073e38328ac8;hb=fda25dc88a63ccac1c80efa2e4994bf0725ca9b7;hpb=e3a3959dcdb461886ed2d5fa4bcd3e345e750e7a diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index 351f429..edc4526 100644 --- a/lib/BackupPC/CGI/EditConfig.pm +++ b/lib/BackupPC/CGI/EditConfig.pm @@ -10,7 +10,7 @@ # Craig Barratt # # COPYRIGHT -# Copyright (C) 2005 Craig Barratt +# Copyright (C) 2005-2007 Craig Barratt # # 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 @@ -28,7 +28,7 @@ # #======================================================================== # -# Version 3.0.0beta2, released 18 Nov 2006. +# Version 3.1.0, released 25 Nov 2007. # # See http://backuppc.sourceforge.net. # @@ -93,11 +93,21 @@ our %ConfigMenu = ( {name => "Bzip2Path"}, {text => "CfgEdit_Title_Install_Paths"}, - {name => "TopDir"}, - {name => "ConfDir"}, - {name => "LogDir"}, + # + # Can only edit TopDir and LogDir if we are in FHS mode. + # Otherwise they are hardcoded in lib/BackupPC/Lib.pm. + # + {name => "TopDir", + visible => sub { return $_[1]->useFHS(); } }, + {name => "LogDir", + visible => sub { return $_[1]->useFHS(); } }, {name => "CgiDir"}, - {name => "InstallDir"}, + # + # Cannot edit ConfDir or InstallDir, since the real value is hardcoded in + # lib/BackupPC/Lib.pm. + # {name => "ConfDir"}, + # {name => "InstallDir"}, + # ], }, email => { @@ -161,6 +171,7 @@ our %ConfigMenu = ( {name => "XferMethod", onchangeSubmit => 1}, {name => "XferLogLevel"}, {name => "ClientCharset"}, + {name => "ClientCharsetLegacy"}, {text => "CfgEdit_Title_Smb_Settings", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, @@ -368,13 +379,17 @@ sub action } if ( (my $var = $In{overrideUncheck}) ne "" ) { # - # a compound variable was unchecked; delete extra - # variables to make the shape the same. + # a compound variable was unchecked; delete or + # add extra variables to make the shape the same. # #print STDERR Dumper(\%In); foreach my $v ( keys(%In) ) { - next if ( $v !~ /^v_zZ_(\Q$var\E(_zZ_.*|$))/ ); - delete($In{$v}) if ( !defined($In{"orig_zZ_$1"}) ); + if ( $v =~ /^v_zZ_(\Q$var\E(_zZ_.*|$))/ ) { + delete($In{$v}) if ( !defined($In{"orig_zZ_$1"}) ); + } + if ( $v =~ /^orig_zZ_(\Q$var\E(_zZ_.*|$))/ ) { + $In{"v_zZ_$1"} = $In{$v}; + } } delete($In{"vflds.$var"}); } @@ -714,9 +729,14 @@ EOF ($mesg, my $hostChange) = hostsDiffMesg($hostsNew); $bpc->HostInfoWrite($hostsNew) if ( $hostChange ); foreach my $host ( keys(%$copyConf) ) { - my $confData = $bpc->ConfigDataRead($copyConf->{$host}); + # + # Currently host names are forced to lc when they + # are read from the hosts file. Therefore we need + # to force the from and to hosts to lc. + # + my $confData = $bpc->ConfigDataRead(lc($copyConf->{$host})); my $fromHost = $copyConf->{$host}; - $err .= $bpc->ConfigDataWrite($host, $confData); + $err .= $bpc->ConfigDataWrite(lc($host), $confData); $mesg .= eval("qq($Lang->{CfgEdit_Log_Copy_host_config})"); } @@ -758,7 +778,7 @@ EOF next if ( $disabled || $menuDisable{$menu}{top} ); if ( ref($paramInfo->{visible}) eq "CODE" - && !&{$paramInfo->{visible}}($newConf) ) { + && !&{$paramInfo->{visible}}($newConf, $bpc) ) { next; } @@ -986,7 +1006,7 @@ sub fieldEditBuild if ( $level == 0 ) { my $lcVarName = lc($varName); $content .= <$varName +$varName EOF if ( defined($overrideVar) ) { my $override_checked = ""; @@ -1466,6 +1486,8 @@ sub fieldInputParse } else { $$value = decode_utf8($In{"v_zZ_$varName"}); $$value =~ s/\r\n/\n/g; + # remove leading space from exec paths + $$value =~ s/^\s+// if ( $type->{type} eq "execPath" ); } $$value = undef if ( $type->{undefIfEmpty} && $$value eq "" ); }