* Various changes for 3.0.0beta1
[BackupPC.git] / lib / BackupPC / CGI / EditConfig.pm
index 11ac989..3504bc1 100644 (file)
@@ -10,7 +10,7 @@
 #   Craig Barratt  <cbarratt@users.sourceforge.net>
 #
 # COPYRIGHT
-#   Copyright (C) 2004  Craig Barratt
+#   Copyright (C) 2005  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.0.0beta1, released 30 Jul 2006.
 #
 # 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 => {
@@ -181,6 +182,8 @@ our %ConfigMenu = (
                 visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
             {name => "RsyncShareName",
                 visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
+            {name => "RsyncdUserName",
+                visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
             {name => "RsyncdPasswd",
                 visible => sub { return $_[0]->{XferMethod} eq "rsyncd"; } },
             {name => "RsyncdAuthRequired",
@@ -188,6 +191,17 @@ our %ConfigMenu = (
             {name => "RsyncCsumCacheVerifyProb",
                 visible => sub { return $_[0]->{XferMethod} =~ /rsync/; } },
 
+            {text => "CfgEdit_Title_BackupPCd_Settings",
+                visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } },
+            {name => "BackupPCdShareName",
+                visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } },
+            {name => "BackupPCdPath",
+                visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } },
+            {name => "BackupPCdCmd",
+                visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } },
+            {name => "BackupPCdRestoreCmd",
+                visible => sub { return $_[0]->{XferMethod} eq "backuppcd"; } },
+
             {text => "CfgEdit_Title_Archive_Settings",
                 visible => sub { return $_[0]->{XferMethod} eq "archive"; } },
             {name => "ArchiveDest",
@@ -268,9 +282,11 @@ our %ConfigMenu = (
            {name => "IncrKeepCnt"},
            {name => "IncrKeepCntMin"},
            {name => "IncrAgeMax"},
+           {name => "IncrLevels"},
            {name => "IncrFill"},
 
            {text => "CfgEdit_Title_Blackouts"},
+            {name => "BackupsDisable"},
             {name => "BlackoutBadPingLimit"},
             {name => "BlackoutGoodCnt"},
             {name => "BlackoutPeriods"},
@@ -307,6 +323,7 @@ our %ConfigMenu = (
            {name => "RestorePostUserCmd"},
            {name => "ArchivePreUserCmd"},
            {name => "ArchivePostUserCmd"},
+           {name => "UserCmdCheckStatus"},
        ],
     },
     hosts => {
@@ -697,9 +714,10 @@ EOF
         $bpc->ServerConnect();
         if ( $mesg ne "" ) {
             (my $mesgBR = $mesg) =~ s/\n/<br>\n/g;
-            $content .= <<EOF;
-<tr><td colspan="2" class="border"><span class="editComment">$mesgBR</span></td></tr>
-EOF
+             # uncomment this if you want the changes to be displayed
+#            $content .= <<EOF;
+#<tr><td colspan="2" class="border"><span class="editComment">$mesgBR</span></td></tr>
+#EOF
             foreach my $str ( split(/\n/, $mesg) ) {
                 $bpc->ServerMesg("log $str") if ( $str ne "" );
             }
@@ -825,8 +843,9 @@ EOF
             #
             foreach my $var ( keys(%In) ) {
                 next if ( $var !~ /^orig_z_/ );
+                my $val = decode_utf8($In{$var});
                 $contentHidden .= <<EOF;
-<input type="hidden" name="$var" value="${EscHTML($In{$var})}">
+<input type="hidden" name="$var" value="${EscHTML($val)}">
 EOF
             }
        }
@@ -930,7 +949,7 @@ sub fieldEditBuild
     $size = $type->{size} if ( defined($type->{size}) );
 
     #
-    # These fragments allow inline conent to be turned on and off
+    # These fragments allow inline content to be turned on and off
     #
     # <tr><td colspan="2"><span id="id_$varName" style="display: none" class="editComment">$comment</span></td></tr>
     # <tr><td class="border"><a href="javascript: displayHelp('$varName')">$varName</a>
@@ -1111,7 +1130,7 @@ EOF
         if ( !$type->{noKeyEdit} ) {
             $content .= <<EOF;
 <tr><td class="border" colspan="2">
-New key: <input type="text" name="addVarKey_$varName" size="20" maxlength="256" value="">
+$Lang->{CfgEdit_Button_New_Key}: <input type="text" class="editTextInput" name="addVarKey_$varName" size="20" maxlength="256" value="">
 <input type="button" name="add_$varName" value="${EscHTML($Lang->{CfgEdit_Button_Add})}" onClick="addSubmit('$varName', 1)">
 </td></tr>
 EOF
@@ -1189,7 +1208,7 @@ EOF
            }
             my $textType = ($varName =~ /Passwd/) ? "password" : "text";
             $content .= <<EOF;
-<input type="$textType" name="v_z_$varName" size="$size" maxlength="256" value="${EscHTML($varValue)}"$onChange>
+<input type="$textType" class="editTextInput" name="v_z_$varName" size="$size" maxlength="256" value="${EscHTML($varValue)}"$onChange>
 EOF
         } elsif ( $type->{type} eq "boolean" ) {
             # checkbox
@@ -1211,7 +1230,7 @@ EOF
            my $rowCnt = $varValue =~ tr/\n//;
            $rowCnt = 1 if ( $rowCnt < 1 );
             $content .= <<EOF;
-<textarea name="v_z_$varName" cols="$size" rows="$rowCnt"$onChange>${EscHTML($varValue)}</textarea>
+<textarea name="v_z_$varName" class="editTextArea" cols="$size" rows="$rowCnt"$onChange>${EscHTML($varValue)}</textarea>
 EOF
         }
         $content .= "</td>\n";
@@ -1396,7 +1415,7 @@ sub fieldInputParse
                 }
             }
         } else {
-            $$value = $In{"v_z_$varName"};
+            $$value = decode_utf8($In{"v_z_$varName"});
             $$value =~ s/\r\n/\n/g;
         }
         $$value = undef if ( $type->{undefIfEmpty} && $$value eq "" );
@@ -1449,12 +1468,15 @@ sub configDiffMesg
 
             (my $valueNew2 = $valueNew) =~ s/['\n\r]//g;
             (my $valueOld2 = $valueOld) =~ s/['\n\r]//g;
+
+            next if ( $valueOld2 eq $valueNew2 );
+
             $valueNew =~ s/\n/\\n/g;
             $valueOld =~ s/\n/\\n/g;
             $valueNew =~ s/\r/\\r/g;
             $valueOld =~ s/\r/\\r/g;
-            $mesg .= eval("qq($Lang->{CfgEdit_Log_Change_param_value})")
-                                    if ( $valueOld2 ne $valueNew2 );
+
+            $mesg .= eval("qq($Lang->{CfgEdit_Log_Change_param_value})");
         }
     }
     return $mesg;