From e939877da97c08099acfc68238e30b3c934c82d6 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 27 Jul 2011 15:50:59 -0700 Subject: [PATCH] Allow editing of multiple configs --- dovecot/CHANGELOG | 2 ++ dovecot/edit_manual.cgi | 20 +++++++++++++++++--- dovecot/lang/en | 7 +++++-- dovecot/save_manual.cgi | 7 +++++-- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/dovecot/CHANGELOG b/dovecot/CHANGELOG index 1edb8434e..dc620d5aa 100644 --- a/dovecot/CHANGELOG +++ b/dovecot/CHANGELOG @@ -19,3 +19,5 @@ Added fields for setting the index and control files locations. Added fields to the SSL page for an optional CA certificate file and private key password. ---- Changes since 1.530 ---- Added support for Dovecot 2.0, which renames many configuration directives and splits up the config using include files. +---- Changes since 1.550 ---- +The Edit Config Files page can now be used to edit any of the Dovecot configuration files, for the case where there are many included configs. diff --git a/dovecot/edit_manual.cgi b/dovecot/edit_manual.cgi index 19f03f4a7..b1d3f9f35 100755 --- a/dovecot/edit_manual.cgi +++ b/dovecot/edit_manual.cgi @@ -3,12 +3,26 @@ require './dovecot-lib.pl'; &ui_print_header(undef, $text{'manual_title'}, ""); +&ReadParse(); +$file = $in{'file'} || $config{'dovecot_config'}; +$conf = &get_config(); +@files = &unique(map { $_->{'file'} } @$conf); +&indexof($file, @files) >= 0 || &error($text{'manual_efile'}); + +# Show the file selector +print &ui_form_start("edit_manual.cgi"); +print "$text{'manual_editsel'}\n"; +print &ui_select("file", $file, \@files),"\n"; +print &ui_submit($text{'manual_ok'}); +print &ui_form_end(); # Show the file contents -print &text('manual_desc', "$config{'dovecot_config'}"),"

\n"; print &ui_form_start("save_manual.cgi", "form-data"); -$data = &read_file_contents($config{'dovecot_config'}); -print &ui_textarea("data", $data, 20, 80),"\n"; +print &ui_hidden("file", $file); +print &ui_table_start(undef, undef, 2); +$data = &read_file_contents($file); +print &ui_table_row(undef, ui_textarea("data", $data, 20, 80), 2); +print &ui_table_end(); print &ui_form_end([ [ "save", $text{'save'} ] ]); &ui_print_footer("", $text{'index_return'}); diff --git a/dovecot/lang/en b/dovecot/lang/en index 8a970a77b..4e74845ed 100644 --- a/dovecot/lang/en +++ b/dovecot/lang/en @@ -188,8 +188,11 @@ log_bootup=Enabled Dovecot at boot time log_bootdown=Disabled Dovecot at boot time log_manual=Manually edited config file $1 -manual_title=Edit Config File -manual_desc=Editing Dovecot configuration file $1 .. +manual_title=Edit Config Files +manual_editsel=Edit Dovecot configuration file manual_err=Failed to save config file manual_edata=Nothing entered! +manual_efile=Selected configuration file is not valid +manual_ok=Edit + __norefs=1 diff --git a/dovecot/save_manual.cgi b/dovecot/save_manual.cgi index 3b91a1dbe..35a37ebd3 100755 --- a/dovecot/save_manual.cgi +++ b/dovecot/save_manual.cgi @@ -4,14 +4,17 @@ require './dovecot-lib.pl'; &ReadParseMime(); &error_setup($text{'manual_err'}); +$conf = &get_config(); +@files = &unique(map { $_->{'file'} } @$conf); +&indexof($in{'file'}, @files) >= 0 || &error($text{'manual_efile'}); $in{'data'} =~ s/\r//g; $in{'data'} =~ /\S/ || &error($text{'manual_edata'}); -&open_lock_tempfile(DATA, ">$config{'dovecot_config'}"); +&open_lock_tempfile(DATA, ">$in{'file'}"); &print_tempfile(DATA, $in{'data'}); &close_tempfile(DATA); -&webmin_log("manual", undef, $config{'dovecot_config'}); +&webmin_log("manual", undef, $in{'file'}); &redirect("");