Handle hostnames with upper-case letters
[webmin.git] / dovecot / edit_mail.cgi
1 #!/usr/local/bin/perl
2 # Show mail file options
3
4 require './dovecot-lib.pl';
5 &ui_print_header(undef, $text{'mail_title'}, "");
6 $conf = &get_config();
7
8 print &ui_form_start("save_mail.cgi", "post");
9 print &ui_table_start($text{'mail_header'}, "width=100%", 4);
10
11 # Mail file location. Old versions used default_mail_env, new uses mail_location
12 $envmode = 4;
13 if (&find("mail_location", $conf, 2)) {
14         $env = &find_value("mail_location", $conf);
15         }
16 else {
17         $env = &find_value("default_mail_env", $conf);
18         }
19 if ($env =~ s/:INDEX=([^:]+)//) {
20         $index = $1;
21         }
22 if ($env =~ s/:CONTROL=([^:]+)//) {
23         $control = $1;
24         }
25 for($i=0; $i<@mail_envs; $i++) {
26         $envmode = $i if ($mail_envs[$i] eq $env);
27         }
28 print &ui_table_row($text{'mail_env'},
29         &ui_radio("envmode", $envmode,
30                 [ ( map { [ $_, $text{'mail_env'.$_}."<br>" ] } (0.. 3) ),
31                   [ 4, &text('mail_env4',
32                         &ui_textbox("other", $envmode == 4 ? $env : undef, 40)) ] ],
33                 ), 3);
34
35 # Index files location
36 $indexmode = $index eq 'MEMORY' ? 1 :
37              $index ? 2 : 0;
38 print &ui_table_row($text{'mail_index'},
39         &ui_radio("indexmode", $indexmode,
40           [ [ 0, $text{'mail_index0'}."<br>" ],
41             [ 1, $text{'mail_index1'}."<br>" ],
42             [ 2, &text('mail_index2',
43                   &ui_textbox("index", $indexmode == 2 ? $index : "", 40)) ]
44           ]), 3);
45
46 # Control files location
47 print &ui_table_row($text{'mail_control'},
48         &ui_radio("controlmode", $control ? 1 : 0,
49           [ [ 0, $text{'mail_index0'}."<br>" ],
50             [ 1, &text('mail_index2',
51                   &ui_textbox("control", $control, 40)) ] ]), 3);
52
53 print &ui_table_hr();
54
55 # Check interval
56 $check = &find_value("mailbox_check_interval", $conf);
57 print &ui_table_row($text{'mail_check'},
58         &ui_radio("check", $check eq '' ? 0 : $check == 0 ? 1 : 2,
59                   [ [ 1, $text{'mail_never'} ],
60                     [ 2, &ui_textbox("checki", $check ? $check : "", 10).
61                          " ".$text{'mail_secs'} ],
62                     [ 0, &getdef("mailbox_check_interval",
63                                  [ [ 0, $text{'mail_never'} ] ]) ] ]), 3);
64
65 # Idle interval
66 $idle = &find_value("mailbox_idle_check_interval", $conf);
67 print &ui_table_row($text{'mail_idle'},
68         &ui_radio("idle", $idle eq '' ? 0 : $idle == 0 ? 1 : 2,
69                   [ [ 1, $text{'mail_never'} ],
70                     [ 2, &ui_textbox("idlei", $idle ? $idle : "", 10).
71                          " ".$text{'mail_secs'} ],
72                     [ 0, &getdef("mailbox_idle_check_interval",
73                                  [ [ 0, $text{'mail_never'} ] ]) ] ]), 3);
74
75 # Full FS access
76 @opts = ( [ "yes", $text{'yes'} ], [ "no", $text{'no'} ] );
77 $full = &find_value("mail_full_filesystem_access", $conf);
78 print &ui_table_row($text{'mail_full'},
79         &ui_radio("full", $full,
80           [ @opts,
81             [ "", &getdef("mail_full_filesystem_access", \@opts) ] ]), 3);
82
83 # CRLF save mode
84 $crlf = &find_value("mail_save_crlf", $conf);
85 @opts = ( [ "yes", $text{'yes'} ], [ "no", $text{'no'} ] );
86 print &ui_table_row($text{'mail_crlf'},
87         &ui_radio("crlf", $crlf,
88           [ @opts,
89             [ "", &getdef("mail_save_crlf", \@opts) ] ]), 3);
90
91 # Allow changing of files
92 $dirty = &find("mbox_dirty_syncs", $conf, 2) ?
93                 "mbox_dirty_syncs" : "maildir_check_content_changes";
94 $change = &find_value($dirty, $conf);
95 print &ui_table_row($text{'mail_change'},
96         &ui_radio("change", $change,
97           [ @opts,
98             [ "", &getdef($dirty, \@opts) ] ]), 3);
99
100 # Permissions on files
101 $umask = &find_value("umask", $conf);
102 print &ui_table_row($text{'mail_umask'},
103         &ui_opt_textbox("umask", $umask, 5, &getdef("umask")), 3);
104
105 # UIDL format
106 if (&find("pop3_uidl_format", $conf, 2)) {
107         $uidl = &find_value("pop3_uidl_format", $conf);
108         @opts = ( $uidl ? ( ) : ( [ "", $text{'mail_uidl_none'} ] ),
109                   [ "%v.%u", $text{'mail_uidl_dovecot'} ],
110                   [ "%08Xv%08Xu", $text{'mail_uidl_uw'} ],
111                   [ "%f", $text{'mail_uidl_courier0'} ],
112                   [ "%u", $text{'mail_uidl_courier1'} ],
113                   [ "%v-%u", $text{'mail_uidl_courier2'} ],
114                   [ "%Mf", $text{'mail_uidl_tpop3d'} ] );
115         ($got) = grep { $_->[0] eq $uidl } @opts;
116         print &ui_table_row($text{'mail_uidl'},
117                 &ui_select("pop3_uidl_format", $got ? $uidl : "*",
118                            [ @opts, [ "*", $text{'mail_uidl_other'} ] ])."\n".
119                 &ui_textbox("pop3_uidl_format_other", $got ? "" : $uidl, 10),
120                 3);
121         }
122
123 # Allow POP3 last command
124 if (&find("pop3_enable_last", $conf, 2)) {
125         $last = &find_value("pop3_enable_last", $conf);
126         @opts = ( [ 'yes', $text{'yes'} ], [ 'no', $text{'no'} ] );
127         print &ui_table_row($text{'mail_last'},
128                 &ui_radio("pop3_enable_last", $last,
129                   [ [ '', &getdef("pop3_enable_last", \@opts) ],
130                     @opts ]), 3);
131         }
132
133 # Index lock method
134 if (&find("lock_method", $conf, 2)) {
135         $method = &find_value("lock_method", $conf);
136         @opts = map { [ $_, $text{'mail_'.$_} ] } &list_lock_methods(1);
137         print &ui_table_row($text{'mail_lock'},
138                 &ui_select("lock_method", $method,
139                            [ @opts,
140                              [ '', &getdef("lock_method", \@opts) ] ],
141                            1, 0, 1), 3);
142         }
143
144 # Mailbox lock methods
145 @opts = map { [ $_, $text{'mail_'.$_} ] } &list_lock_methods(0);
146 foreach $l ("mbox_read_locks", "mbox_write_locks") {
147         next if (!&find($l, $conf, 2));
148         $def = &find_value($l, $conf, 1);
149         $defmsg = join(", ", map { $text{'mail_'.$_} || $_ }
150                                  split(/\s+/, $def));
151         $defmsg = " ($defmsg)" if ($defmsg);
152         $method = &find_value($l, $conf);
153         $defsel = &ui_radio($l."_def", $method ? 0 : 1,
154                             [ [ 1, $text{'default'}.$defmsg ],
155                               [ 0, $text{'mail_sel'} ] ]);
156         $methsel = "";
157         @methods = split(/\s+/, $method);
158         for(my $i=0; $i<@opts; $i++) {
159                 $methsel .= &ui_select($l."_".$i, $methods[$i],
160                                        [ [ '', "&lt;$text{'mail_none'}&gt;" ],
161                                          @opts ], 1, 0, 1);
162                 }
163         print &ui_table_row($text{'mail_'.$l},
164                             $defsel."<br>\n".$methsel, 3);
165         }
166
167 print &ui_table_end();
168 print &ui_form_end([ [ "save", $text{'save'} ] ]);
169
170 &ui_print_footer("", $text{'index_return'});
171