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