summaryrefslogtreecommitdiff
path: root/httemplate/config/config.cgi
blob: 409869e11517619d081adc42878d8d8f92172618 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
<!-- mason kludge -->
<%= header('Edit Configuration', menubar( 'Main Menu' => $p ) ) %>
<SCRIPT>
var gSafeOnload = new Array();
var gSafeOnsubmit = new Array();
window.onload = SafeOnload;
function SafeAddOnLoad(f) {
  gSafeOnload[gSafeOnload.length] = f;
}
function SafeOnload() {
  for (var i=0;i<gSafeOnload.length;i++)
    gSafeOnload[i]();
}
function SafeAddOnSubmit(f) {
  gSafeOnsubmit[gSafeOnsubmit.length] = f;
}
function SafeOnsubmit() {
  for (var i=0;i<gSafeOnsubmit.length;i++)
    gSafeOnsubmit[i]();
}
</SCRIPT>

<% my $conf = new FS::Conf; my @config_items = $conf->config_items; %>

<form name="OneTrueForm" action="config-process.cgi" METHOD="POST" onSubmit="SafeOnsubmit()">

<% foreach my $section ( qw(required billing username password UI session
                            shell BIND
                           ),
                         '', 'deprecated') { %>
  <A NAME="<%= $section || 'unclassified' %>"></A>
  <FONT SIZE="-2">
  <% foreach my $nav_section ( qw(required billing username password UI session
                                  shell BIND
                                 ),
                               '', 'deprecated') { %>
    <% if ( $section eq $nav_section ) { %>
      [<A NAME="not<%= $nav_section || 'unclassified' %>" style="background-color: #cccccc"><%= ucfirst($nav_section || 'unclassified') %></A>]
    <% } else { %>
      [<A HREF="#<%= $nav_section || 'unclassified' %>"><%= ucfirst($nav_section || 'unclassified') %></A>]
    <% } %>
  <% } %>
  </FONT><BR>
  <%= table("#cccccc", 2) %>
  <tr>
    <th colspan="2" bgcolor="#dcdcdc">
      <%= ucfirst($section || 'unclassified') %> configuration options
    </th>
  </tr>
  <% foreach my $i (grep $_->section eq $section, @config_items) { %>
    <tr>
      <td>
        <% my $n = 0;
           foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
             #warn $i->key unless defined($type);
        %>
          <% if ( $type eq '' ) { %>
            <font color="#ff0000">no type</font>
          <% } elsif ( $type eq 'textarea' ) { %>
            <textarea name="<%= $i->key. $n %>" rows=5><%= "\n". join("\n", $conf->config($i->key) ) %></textarea>
          <% } elsif ( $type eq 'checkbox' ) { %>
            <input name="<%= $i->key. $n %>" type="checkbox" value="1"<%= $conf->exists($i->key) ? ' CHECKED' : '' %>>
          <% } elsif ( $type eq 'text' )  { %>
            <input name="<%= $i->key. $n %>" type="<%= $type %>" value="<%= $conf->exists($i->key) ? $conf->config($i->key) : '' %>">
          <% } elsif ( $type eq 'select' || $type eq 'selectmultiple' )  { %>
            <select name="<%= $i->key. $n %>" <%= $type eq 'selectmultiple' ? 'MULTIPLE' : '' %>>
              <% my %saw;
                 foreach my $value ( "", @{$i->select_enum} ) {
                    local($^W)=0; next if $saw{$value}++; %>
                <option value="<%= $value %>"<%= $value eq $conf->config($i->key) || ( $type eq 'selectmultiple' && grep { $_ eq $value } $conf->config($i->key) ) ? ' SELECTED' : '' %>><%= $value %>
              <% } %>
              <% if ( $conf->exists($i->key) && $conf->config($i->key) && ! grep { $conf->config($i->key) eq $_ } @{$i->select_enum}) { %>
                <option value=<%= $conf->config($i->key) %> SELECTED><%= $conf->config($i->key) %>
              <% } %>
            </select>
          <% } elsif ( $type eq 'editlist' )  { %>
            <script>
              function doremove<%= $i->key. $n %>() {
                fromObject = document.OneTrueForm.<%= $i->key. $n %>;
                for (var i=fromObject.options.length-1;i>-1;i--) {
                  if (fromObject.options[i].selected)
                    deleteOption<%= $i->key. $n %>(fromObject,i);
                }
              }
              function deleteOption<%= $i->key. $n %>(object,index) {
                object.options[index] = null;
              }
              function selectall<%= $i->key. $n %>() {
                fromObject = document.OneTrueForm.<%= $i->key. $n %>;
                for (var i=fromObject.options.length-1;i>-1;i--) {
                  fromObject.options[i].selected = true;
                }
              }
              function doadd<%= $i->key. $n %>(object) {
                var myvalue = "";
                <% if ( defined($i->editlist_parts) ) { %>

                  <% foreach my $pnum ( 0 .. scalar(@{$i->editlist_parts})-1 ) { %>

                    if ( myvalue != "" ) { myvalue = myvalue + " "; }
                    <% if ( $i->editlist_parts->[$pnum]{type} eq 'select' ) { %>
                      myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.options[object.add<%= $i->key. $n . "_$pnum" %>.selectedIndex].value;
                      <!-- #RESET SELECT??  maybe not... -->
                    <% } elsif ( $i->editlist_parts->[$pnum]{type} eq 'immutable' ) { %>
                      myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
                    <% } else { %>
                      myvalue = myvalue + object.add<%= $i->key. $n . "_$pnum" %>.value;
                      object.add<%= $i->key. $n. "_$pnum" %>.value = "";
                    <% } %>


                  <% } %>
                <% } else { %>
                  myvalue = object.add<%= $i->key. $n. "_1" %>.value;
                <% } %>
                var optionName = new Option(myvalue, myvalue);
                var length = object.<%= $i->key. $n %>.length;
                object.<%= $i->key. $n %>.options[length] = optionName;
              }
            </script>
            <select multiple size=5 name="<%= $i->key. $n %>">
            <option selected>----------------------------------------------------------------</option>
            <% foreach my $line ( $conf->config($i->key) ) { %>
              <option value="<%= $line %>"><%= $line %></option>
            <% } %>
            </select><br>
            <input type="button" value="remove selected" onClick="doremove<%= $i->key. $n %>()">
            <script>SafeAddOnLoad(doremove<%= $i->key. $n %>);
                    SafeAddOnSubmit(selectall<%= $i->key. $n %>);</script>
            <br>
            <%= itable() %><tr>
            <% if ( defined $i->editlist_parts ) { %>
              <% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { %>
                <td>
                <% if ( $part->{type} eq 'text' ) { %>
                  <input type="text" name="add<%= $i->key. $n."_$pnum" %>">
                <% } elsif ( $part->{type} eq 'immutable' ) { %>
                  <%= $part->{value} %><input type="hidden" name="add<%= $i->key. $n. "_$pnum" %>" value="<%= $part->{value} %>">
                <% } elsif ( $part->{type} eq 'select' ) { %>
                  <select name="add<%= $i->key. $n. "_$pnum" %>">
                  <% foreach my $key ( keys %{$part->{select_enum}} ) { %>
                    <option value="<%= $key %>"><%= $part->{select_enum}{$key} %></option>
                  <% } %>
                  </select>
                <% } else { %>
                  <font color="#ff0000">unknown type <%= $part->type %></font>
                <% } %>
                </td>
              <% $pnum++; } %>
            <% } else { %>
              <td><input type="text" name="add<%= $i->key. $n %>_0"></td>
            <% } %>
            <td><input type="button" value="add" onClick="doadd<%= $i->key. $n %>(this.form)"></td>
            </tr></table>
          <% } else { %>
            <font color="#ff0000">unknown type <%= $type %></font>
          <% } %>
        <% $n++; } %>
      </td>
      <td><a name="<%= $i->key %>">
        <b><%= $i->key %></b> - <%= $i->description %>
      </a></td>
    </tr>
  <% } %>
  </table><br>

  You may need to restart Apache and/or freeside-queued for configuration
  changes to take effect.<br>

  <input type="submit" value="Apply changes"><br><br>

<% } %>

</form>

</body></html>