X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FEditConfig.pm;h=edc4526d0699fb04ccab4b218db5a07b47ec946d;hp=ec05e9f78896288463f842112908453d1adae6cb;hb=fda25dc88a63ccac1c80efa2e4994bf0725ca9b7;hpb=c2d26ea114f743daeb016d53f6364a45a4e037ae diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index ec05e9f..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.0alpha, released 23 Jan 2006. +# Version 3.1.0, released 25 Nov 2007. # # See http://backuppc.sourceforge.net. # @@ -41,6 +41,7 @@ use BackupPC::CGI::Lib qw(:all); use BackupPC::Config::Meta qw(:all); use BackupPC::Storage; use Data::Dumper; +use Encode; our %ConfigMenu = ( server => { @@ -92,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 => { @@ -160,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"; } }, @@ -356,24 +368,28 @@ sub action ErrorExit(eval("qq{$Lang->{Only_privileged_users_can_edit_config_files}}")); } - if ( defined($In{menu}) || $In{editAction} eq $Lang->{CfgEdit_Button_Save} ) { + if ( defined($In{menu}) || $In{saveAction} eq "Save" ) { $errors = errorCheck(); if ( %$errors ) { # # If there are errors, then go back to the same menu # - $In{editAction} = ""; - $In{newMenu} = ""; + $In{saveAction} = ""; + #$In{newMenu} = ""; } 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_z_(\Q$var\E(_z_.*|$))/ ); - delete($In{$v}) if ( !defined($In{"orig_z_$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"}); } @@ -400,7 +416,7 @@ sub action $newConf = { %$mainConf, %$hostConf }; } - if ( $In{editAction} ne $Lang->{CfgEdit_Button_Save} && $In{newMenu} ne "" + if ( $In{saveAction} ne "Save" && $In{newMenu} ne "" && defined($ConfigMenu{$In{newMenu}}) ) { $menu = $In{newMenu}; } @@ -474,9 +490,15 @@ EOF $content .= eval("qq($Lang->{CfgEdit_Header_Host})"); } - my $saveDisplay = "block"; - $saveDisplay = "none" if ( !$In{modified} - || $In{editAction} eq $Lang->{CfgEdit_Button_Save} ); + my $saveStyle = ""; + my $saveColor = "#ff0000"; + + if ( $In{modified} && $In{saveAction} ne "Save" && !%$errors ) { + $saveStyle = "style=\"color:$saveColor\""; + } else { + $In{modified} = 0; + } + # # Add action and host to the URL so the nav bar link is # highlighted @@ -487,7 +509,7 @@ EOF $groupText - + @@ -497,72 +519,85 @@ EOF - + + +