1#!/usr/local/bin/perl
2# edit_options.cgi
3# Display options for the entire voicemail server
4
5require './vgetty-lib.pl';
6&ui_print_header(undef, $text{'options_title'}, "");
7@conf = &get_config();
8
9print "<form action=save_options.cgi method=post>\n";
10print "<table border width=100%>\n";
11print "<tr $tb> <td><b>$text{'options_header'}</b></td> </tr>\n";
12print "<tr $cb> <td><table width=100%>\n";
13
14$rings = &find_value("rings", \@conf);
15if ($rings =~ /^\//) {
16	open(TF, "<$rings");
17	chop($rc = <TF>);
18	close(TF);
19	}
20else { $rc = $rings; }
21print "<tr> <td><b>$text{'options_rings'}</b></td>\n";
22print "<td nowrap><input name=rings size=5 value='$rc'></td>\n";
23printf "<td colspan=2><input type=checkbox name=rings_port value=1 %s> %s\n",
24	$rings =~ /^\// ? "checked" : "", $text{'options_perport'};
25print "</td> </tr>\n";
26
27$ans = &find_value("answer_mode", \@conf);
28if ($ans =~ /^\//) {
29	open(TF, "<$ans");
30	chop($rc = <TF>);
31	close(TF);
32	}
33else { $rc = $ans; }
34print "<tr> <td><b>$text{'options_ans'}</b></td>\n";
35print "<td nowrap>",&answer_mode_input($rc, "ans"),"</td>\n";
36printf "<td colspan=2><input type=checkbox name=ans_port value=1 %s> %s\n",
37	$ans =~ /^\// ? "checked" : "", $text{'options_perport'};
38print "</td> </tr>\n";
39
40print "<tr> <td><b>$text{'options_maxlen'}</b></td>\n";
41printf "<td><input name=maxlen size=8 value='%s'> %s</td>\n",
42	&find_value("rec_max_len", \@conf), $text{'options_secs'};
43
44print "<td><b>$text{'options_minlen'}</b></td>\n";
45printf "<td><input name=minlen size=8 value='%s'> %s</td> </tr>\n",
46	&find_value("rec_min_len", \@conf), $text{'options_secs'};
47
48$silence = &find_value("rec_remove_silence", \@conf);
49print "<tr> <td><b>$text{'options_silence'}</b></td>\n";
50printf "<td nowrap><input type=radio name=silence value=1 %s> %s\n",
51	$silence =~ /true/i ? "checked" : "", $text{'yes'};
52printf "<input type=radio name=silence value=0 %s> %s</td>\n",
53	$silence =~ /true/i ? "" : "checked", $text{'no'};
54
55print "<td><b>$text{'options_thresh'}</b></td>\n";
56printf "<td><input name=thresh size=3 value='%s'> %%</td> </tr>\n",
57	&find_value("rec_silence_threshold", \@conf);
58
59$rgain = &find_value("receive_gain", \@conf);
60print "<tr> <td><b>$text{'options_rgain'}</b></td>\n";
61printf "<td nowrap><input type=radio name=rgain_def value=1 %s> %s\n",
62	$rgain == -1 ? "checked" : "", $text{'default'};
63printf "<input type=radio name=rgain_def value=0 %s>\n",
64	$rgain == -1 ? "" : "checked";
65printf "<input name=rgain size=4 value='%s'> %%</td>\n",
66	$rgain == -1 ? "" : $rgain;
67
68$tgain = &find_value("transmit_gain", \@conf);
69print "<td><b>$text{'options_tgain'}</b></td>\n";
70printf "<td nowrap><input type=radio name=tgain_def value=1 %s> %s\n",
71	$tgain == -1 ? "checked" : "", $text{'default'};
72printf "<input type=radio name=tgain_def value=0 %s>\n",
73	$tgain == -1 ? "" : "checked";
74printf "<input name=tgain size=4 value='%s'> %%</td> </tr>\n",
75	$tgain == -1 ? "" : $tgain;
76
77$keep = &find_value("rec_always_keep", \@conf);
78print "<tr> <td><b>$text{'options_keep'}</b></td>\n";
79printf "<td nowrap><input type=radio name=keep value=1 %s> %s\n",
80	$keep =~ /true/i ? "checked" : "", $text{'yes'};
81printf "<input type=radio name=keep value=0 %s> %s</td>\n",
82	$keep =~ /true/i ? "" : "checked", $text{'no'};
83
84$light = &find_value("do_message_light", \@conf);
85print "<td><b>$text{'options_light'}</b></td>\n";
86printf "<td nowrap><input type=radio name=light value=1 %s> %s\n",
87	$light =~ /true/i ? "checked" : "", $text{'yes'};
88printf "<input type=radio name=light value=0 %s> %s</td> </tr>\n",
89	$light =~ /true/i ? "" : "checked", $text{'no'};
90
91print "<tr> <td><b>$text{'options_owner'}</b></td>\n";
92printf "<td><input name=owner size=8 value='%s'> %s</td>\n",
93	&find_value("phone_owner", \@conf), &user_chooser_button("owner");
94
95print "<td><b>$text{'options_group'}</b></td>\n";
96printf "<td><input name=group size=8 value='%s'> %s</td> </tr>\n",
97	&find_value("phone_group", \@conf), &user_chooser_button("group");
98
99print "<tr> <td><b>$text{'options_mode'}</b></td>\n";
100printf "<td><input name=mode size=4 value='%s'></td>\n",
101	&find_value("phone_mode", \@conf);
102
103$prog = &find_value("message_program", \@conf);
104$mode = !$prog ? 0 : $prog eq "$module_config_directory/email.pl" ? 1 : 2;
105print "<tr> <td valign=top><b>$text{'options_prog'}</b></td> <td colspan=3>\n";
106printf "<input type=radio name=prog_mode value=0 %s> %s<br>\n",
107	$mode == 0 ? "checked" : "", $text{'options_prog0'};
108printf "<input type=radio name=prog_mode value=1 %s> %s\n",
109	$mode == 1 ? "checked" : "", $text{'options_prog1'};
110printf "<input name=email size=30 value='%s'><br>\n",
111	$mode == 1 ? $config{'email_to'} : "";
112printf "<input type=radio name=prog_mode value=2 %s> %s\n",
113	$mode == 2 ? "checked" : "", $text{'options_prog2'};
114printf "<input name=prog size=30 value='%s'></td> </tr>\n",
115	$mode == 2 ? $prog : "";
116
117print "</tr>\n";
118
119print "</table></td></tr></table>\n";
120print "<input type=submit value='$text{'save'}'></form>\n";
121
122&ui_print_footer("", $text{'index_return'});
123
124