properly deprecate ancient apache & sendmail config options
[freeside.git] / httemplate / config / config.cgi
1 <!-- mason kludge -->
2 <%= header('Edit Configuration', menubar( 'Main Menu' => $p ) ) %>
3 <SCRIPT>
4 var gSafeOnload = new Array();
5 var gSafeOnsubmit = new Array();
6 window.onload = SafeOnload;
7 function SafeAddOnLoad(f) {
8   gSafeOnload[gSafeOnload.length] = f;
9 }
10 function SafeOnload() {
11   for (var i=0;i<gSafeOnload.length;i++)
12     gSafeOnload[i]();
13 }
14 function SafeAddOnSubmit(f) {
15   gSafeOnsubmit[gSafeOnsubmit.length] = f;
16 }
17 function SafeOnsubmit() {
18   for (var i=0;i<gSafeOnsubmit.length;i++)
19     gSafeOnsubmit[i]();
20 }
21 </SCRIPT>
22
23 <% my $conf = new FS::Conf; my @config_items = $conf->config_items; %>
24
25 <form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()">
26
27 <% foreach my $section ( qw(required billing username password UI session
28                             shell BIND
29                            ),
30                          '', 'deprecated') { %>
31   <A NAME="<%= $section || 'unclassified' %>"></A>
32   <FONT SIZE="-2">
33   <% foreach my $nav_section ( qw(required billing username password UI session
34                                   shell BIND
35                                  ),
36                                '', 'deprecated') { %>
37     <% if ( $section eq $nav_section ) { %>
38       [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
39     <% } else { %>
40       [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
41     <% } %>
42   <% } %>
43   </FONT><BR>
44   <%= table("#cccccc", 2) %>
45   <tr>
46     <th colspan="2" bgcolor="#dcdcdc">
47       <%= ucfirst($section || 'unclassified') %> configuration options
48     </th>
49   </tr>
50   <% foreach my $i (grep $_->section eq $section, @config_items) { %>
51     <tr>
52       <td>
53         <% my $n = 0;
54            foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
55              #warn $i->key unless defined($type);
56         %>
57           <% if ( $type eq '' ) { %>
58             <font color="#ff0000">no type</font>
59           <% } elsif ( $type eq 'textarea' ) { %>
60             <textarea name="<%= $i->key. $n %>" rows=5><%= "\n". join("\n", $conf->config($i->key) ) %></textarea>
61           <% } elsif ( $type eq 'checkbox' ) { %>
62             <input name="<%= $i->key. $n %>" type="checkbox" value="1"<%= $conf->exists($i->key) ? ' CHECKED' : '' %>>
63           <% } elsif ( $type eq 'text' )  { %>
64             <input name="<%= $i->key. $n %>" type="<%= $type %>" value="<%= $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
65           <% } elsif ( $type eq 'select' || $type eq 'selectmultiple' )  { %>
66             <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
67               <% my %saw;
68                  foreach my $value ( "", @{$i->select_enum} ) {
69                     local($^W)=0; next if $saw{$value}++; %>
70                 <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $value %>
71               <% } %>
72               <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! grep { $conf->config($i->key) eq $_ } @{$i->select_enum}) { %>
73                 <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>
74               <% } %>
75             </select>
76           <% } elsif ( $type eq 'editlist' )  { %>
77             <script>
78               function doremove<%= $i->key. $n %>() {
79                 fromObject = document.OneTrueForm.<%= $i->key. $n %>;
80                 for (var i=fromObject.options.length-1;i>-1;i--) {
81                   if (fromObject.options[i].selected)
82                     deleteOption<%= $i->key. $n %>(fromObject,i);
83                 }
84               }
85               function deleteOption<%= $i->key. $n %>(object,index) {
86                 object.options[index] = null;
87               }
88               function selectall<%= $i->key. $n %>() {
89                 fromObject = document.OneTrueForm.<%= $i->key. $n %>;
90                 for (var i=fromObject.options.length-1;i>-1;i--) {
91                   fromObject.options[i].selected = true;
92                 }
93               }
94               function doadd<%= $i->key. $n %>(object) {
95                 var myvalue = "";
96                 <% if ( defined($i->editlist_parts) ) { %>
97
98                   <% foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) { %>
99
100                     if ( myvalue != "" ) { myvalue = myvalue + " "; }
101                     <% if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) { %>
102                       myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.options[object.add<%= $i->key. $n . "_$pnum" %>.selectedIndex].value;
103                       <!-- #RESET SELECT??  maybe not... -->
104                     <% } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) { %>
105                       myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
106                     <% } else { %>
107                       myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
108                       object.add<%= $i->key. $n. "_$pnum" %>.value = "";
109                     <% } %>
110
111
112                   <% } %>
113                 <% } else { %>
114                   myvalue = object.add<%= $i->key. $n. "_1" %>.value;
115                 <% } %>
116                 var optionName = new Option(myvalue, myvalue);
117                 var length = object.<%= $i->key. $n %>.length;
118                 object.<%= $i->key. $n %>.options[length] = optionName;
119               }
120             </script>
121             <select multiple size=5 name="<%= $i->key. $n %>">
122             <option selected>----------------------------------------------------------------</option>
123             <% foreach my $line ( $conf->config($i->key) ) { %>
124               <option value="<%= $line %>"><%= $line %></option>
125             <% } %>
126             </select><br>
127             <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()">
128             <script>SafeAddOnLoad(doremove<%= $i->key. $n %>);
129                     SafeAddOnSubmit(selectall<%= $i->key. $n %>);</script>
130             <br>
131             <%= itable() %><tr>
132             <% if ( defined $i->editlist_parts ) { %>
133               <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %>
134                 <td>
135                 <% if ( $part->{type} eq 'text' ) { %>
136                   <input type="text" name="add<%= $i->key. $n."_$pnum" %>">
137                 <% } elsif ( $part->{type} eq 'immutable' ) { %>
138                   <%= $part->{value} %><input type="hidden" name="add<%= $i->key. $n. "_$pnum" %>" value="<%= $part->{value} %>">
139                 <% } elsif ( $part->{type} eq 'select' ) { %>
140                   <select name="add<%= $i->key. $n. "_$pnum" %>">
141                   <% foreach my $key ( keys %{$part->{select_enum}} ) { %>
142                     <option value="<%= $key %>"><%= $part->{select_enum}{$key} %></option>
143                   <% } %>
144                   </select>
145                 <% } else { %>
146                   <font color="#ff0000">unknown type <%= $part->type %></font>
147                 <% } %>
148                 </td>
149               <% $pnum++; } %>
150             <% } else { %>
151               <td><input type="text" name="add<%= $i->key. $n %>_0"></td>
152             <% } %>
153             <td><input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)"></td>
154             </tr></table>
155           <% } else { %>
156             <font color="#ff0000">unknown type <%= $type %></font>
157           <% } %>
158         <% $n++; } %>
159       </td>
160       <td><a name="<%= $i->key %>">
161         <b><%= $i->key %></b> - <%= $i->description %>
162       </a></td>
163     </tr>
164   <% } %>
165   </table><br>
166
167   You may need to restart Apache and/or freeside-queued for configuration
168   changes to take effect.<br>
169
170   <input type="submit" value="Apply changes"><br><br>
171
172 <% } %>
173
174 </form>
175
176 </body></html>