From a486d3a9221a1f9ca24ce8a779a2d55a4e7ada21 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Tue, 6 May 2008 22:13:15 +0000 Subject: [PATCH] Index and control files fields --- dovecot/CHANGELOG | 1 + dovecot/edit_mail.cgi | 28 +++++++++++++++++++++++++++- dovecot/lang/en | 9 +++++++++ dovecot/save_mail.cgi | 16 ++++++++++++++++ 4 files changed, 53 insertions(+), 1 deletion(-) diff --git a/dovecot/CHANGELOG b/dovecot/CHANGELOG index 1c6e41d2e..a73124bcc 100644 --- a/dovecot/CHANGELOG +++ b/dovecot/CHANGELOG @@ -14,3 +14,4 @@ Added fields for editing the UIDL format and number of login processes. Supported newer versions of Dovecot which use mail_location instead of default_mail_env. ---- Changes since 1.410 ---- The locking methods for mailboxes and index files can be configured on the Mail Files page. +Added fields for setting the index and control files locations. diff --git a/dovecot/edit_mail.cgi b/dovecot/edit_mail.cgi index 620034815..8e4a18c95 100755 --- a/dovecot/edit_mail.cgi +++ b/dovecot/edit_mail.cgi @@ -16,6 +16,12 @@ if (&find("mail_location", $conf, 2)) { else { $env = &find_value("default_mail_env", $conf); } +if ($env =~ s/:INDEX=([^:]+)//) { + $index = $1; + } +if ($env =~ s/:CONTROL=([^:]+)//) { + $control = $1; + } for($i=0; $i<@mail_envs; $i++) { $envmode = $i if ($mail_envs[$i] eq $env); } @@ -23,9 +29,29 @@ print &ui_table_row($text{'mail_env'}, &ui_radio("envmode", $envmode, [ ( map { [ $_, $text{'mail_env'.$_}."
" ] } (0.. 3) ), [ 4, &text('mail_env4', - &ui_textbox("other", $envmode == 4 ? $env : undef, 30)) ] ], + &ui_textbox("other", $envmode == 4 ? $env : undef, 40)) ] ], ), 3); +# Index files location +$indexmode = $index eq 'MEMORY' ? 1 : + $index ? 2 : 0; +print &ui_table_row($text{'mail_index'}, + &ui_radio("indexmode", $indexmode, + [ [ 0, $text{'mail_index0'}."
" ], + [ 1, $text{'mail_index1'}."
" ], + [ 2, &text('mail_index2', + &ui_textbox("index", $indexmode == 2 ? $index : "", 40)) ] + ]), 3); + +# Control files location +print &ui_table_row($text{'mail_control'}, + &ui_radio("controlmode", $control ? 1 : 0, + [ [ 0, $text{'mail_index0'}."
" ], + [ 1, &text('mail_index2', + &ui_textbox("control", $control, 40)) ] ]), 3); + +print &ui_table_hr(); + # Check interval $check = &find_value("mailbox_check_interval", $conf); print &ui_table_row($text{'mail_check'}, diff --git a/dovecot/lang/en b/dovecot/lang/en index f6d132c21..6013b82e5 100644 --- a/dovecot/lang/en +++ b/dovecot/lang/en @@ -127,6 +127,11 @@ mail_env1=Inbox and folders in ~/Maildir mail_env2=Inbox under /var/mail, folders in ~/mail mail_env3=Inbox in ~/Maildir, folders in ~/mail mail_env4=Other Dovecot location $1 +mail_index=Index files location +mail_index0=Default (in Maildir directory) +mail_index1=In memory only +mail_index2=Other directory $1 +mail_control=Control files location mail_check=Interval between mail checks mail_never=Never check mail_secs=seconds @@ -162,6 +167,10 @@ mail_none=None mail_sel=Selected below, in order .. mail_embox_read_locks=No read locking methods selected mail_embox_write_locks=No write locking methods selected +mail_eindexmode=The index files location cannot be set when the mail file location is detected automatically +mail_econtrolmode=The control files location cannot be set when the mail file location is detected automatically +mail_eindex=Missing or invalid absolute path for index files +mail_econtrol=Missing or invalid absolute path for control files log_net=Changed Networking and Protocols log_login=Changed User and Login Options diff --git a/dovecot/save_mail.cgi b/dovecot/save_mail.cgi index dc7a0a6b6..e1247964f 100755 --- a/dovecot/save_mail.cgi +++ b/dovecot/save_mail.cgi @@ -15,6 +15,22 @@ if ($in{'envmode'} == 4) { else { $env = $mail_envs[$in{'envmode'}]; } + +# Add index file location +$env || !$in{'indexmode'} || &error($text{'mail_eindexmode'}); +$env || !$in{'controlmode'} || &error($text{'mail_econtrolmode'}); +if ($in{'indexmode'} == 1) { + $env .= ":INDEX=MEMORY"; + } +elsif ($in{'indexmode'} == 2) { + $in{'index'} =~ /^\/\S+$/ || &error($text{'mail_eindex'}); + $env .= ":INDEX=".$in{'index'}; + } +if ($in{'controlmode'}) { + $in{'control'} =~ /^\/\S+$/ || &error($text{'mail_econtrol'}); + $env .= ":CONTROL=".$in{'control'}; + } + if (&find("mail_location", $conf, 2)) { &save_directive($conf, "mail_location", $env eq "" ? undef : $env); }