X-Git-Url: http://git.rot13.org/?p=BackupPC.git;a=blobdiff_plain;f=lib%2FBackupPC%2FCGI%2FEditConfig.pm;h=9b78b15f085154ee2ad5361b7a0739229e9640fd;hp=a5740e438dc30bffb681464d81c7852be6bec94d;hb=5b79f9a3c01bca16dd4d211e76fc53daa549e421;hpb=4cdaa6b8a9f5161ee2da4371d68cbbad41248ea0 diff --git a/lib/BackupPC/CGI/EditConfig.pm b/lib/BackupPC/CGI/EditConfig.pm index a5740e4..9b78b15 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.0beta0, released 11 Jul 2006. +# Version 3.1.1, released 22 Dec 2008. # # 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,7 +171,9 @@ our %ConfigMenu = ( {name => "XferMethod", onchangeSubmit => 1}, {name => "XferLogLevel"}, {name => "ClientCharset"}, + {name => "ClientCharsetLegacy"}, + ### Smb Settings {text => "CfgEdit_Title_Smb_Settings", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbShareName", @@ -171,11 +183,13 @@ our %ConfigMenu = ( {name => "SmbSharePasswd", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, + ### Tar Settings {text => "CfgEdit_Title_Tar_Settings", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarShareName", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, + ### Rsync Settings {text => "CfgEdit_Title_Rsync_Settings", visible => sub { return $_[0]->{XferMethod} eq "rsync"; } }, {text => "CfgEdit_Title_Rsyncd_Settings", @@ -191,6 +205,25 @@ our %ConfigMenu = ( {name => "RsyncCsumCacheVerifyProb", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, + ### Ftp Settings + {text => "CfgEdit_Title_Ftp_Settings", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpShareName", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpUserName", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpPasswd", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpBlockSize", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpPort", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpTimeout", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + {name => "FtpFollowSymlinks", + visible => sub { return $_[0]->{XferMethod} eq "ftp"; } }, + + ### BackupPCd Settings {text => "CfgEdit_Title_BackupPCd_Settings", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, {name => "BackupPCdShareName", @@ -202,6 +235,7 @@ our %ConfigMenu = ( {name => "BackupPCdRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } }, + ### Archive Settings {text => "CfgEdit_Title_Archive_Settings", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveDest", @@ -213,6 +247,7 @@ our %ConfigMenu = ( {name => "ArchiveSplit", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, + ### Include/Exclude Settings {text => "CfgEdit_Title_Include_Exclude", visible => sub { return $_[0]->{XferMethod} ne "archive"; } }, {name => "BackupFilesOnly", @@ -220,6 +255,7 @@ our %ConfigMenu = ( {name => "BackupFilesExclude", visible => sub { return $_[0]->{XferMethod} ne "archive"; } }, + ### Samba paths and commands {text => "CfgEdit_Title_Smb_Paths_Commands", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, {name => "SmbClientPath", @@ -231,6 +267,7 @@ our %ConfigMenu = ( {name => "SmbClientRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "smb"; } }, + ### Tar paths and commands {text => "CfgEdit_Title_Tar_Paths_Commands", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, {name => "TarClientPath", @@ -244,6 +281,7 @@ our %ConfigMenu = ( {name => "TarClientRestoreCmd", visible => sub { return $_[0]->{XferMethod} eq "tar"; } }, + ### Rsync paths and commands {text => "CfgEdit_Title_Rsync_Paths_Commands_Args", visible => sub { return $_[0]->{XferMethod} eq "rsync"; } }, {text => "CfgEdit_Title_Rsyncd_Port_Args", @@ -261,6 +299,7 @@ our %ConfigMenu = ( {name => "RsyncRestoreArgs", visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } }, + ### Archive paths and commands {text => "CfgEdit_Title_Archive_Paths_Commands", visible => sub { return $_[0]->{XferMethod} eq "archive"; } }, {name => "ArchiveClientCmd", @@ -357,24 +396,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"}); } @@ -401,7 +444,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}; } @@ -475,9 +518,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 @@ -488,7 +537,7 @@ EOF $groupText - + @@ -498,72 +547,85 @@ EOF - + + +