config in database cleanup, editing, and agent-specific config (452, 1419)
[freeside.git] / httemplate / config / config-view.cgi
1 <% include("/elements/header.html",
2      $title,
3      menubar(
4        'Main Menu' => $p,
5        'View all agents' => $p.'browse/agent.cgi',
6      )
7    )
8 %>
9
10 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws.js"></SCRIPT>
11 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_iframe.js"></SCRIPT>
12 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/overlibmws_draggable.js"></SCRIPT>
13 <SCRIPT TYPE="text/javascript" SRC="<%$fsurl%>elements/iframecontentmws.js"></SCRIPT>
14
15 % if ($FS::UID::use_confcompat) {
16
17   <FONT SIZE="+1" COLOR="#ff0000">CONFIGURATION NOT STORED IN DATABASE -- USING COMPATIBILITY MODE</FONT><BR><BR>
18 %}
19 %
20 % foreach my $section ( qw(required billing username password UI session
21 %                            shell BIND
22 %                           ),
23 %                         '', 'deprecated') { 
24
25   <A NAME="<% $section || 'unclassified' %>"></A>
26   <FONT SIZE="-2">
27 % foreach my $nav_section ( qw(required billing username password UI session
28 %                                  shell BIND
29 %                                 ),
30 %                               '', 'deprecated') { 
31 % if ( $section eq $nav_section ) { 
32
33       [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
34 % } else { 
35
36       [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
37 % } 
38 % } 
39
40   </FONT><BR>
41   <% table("#cccccc", 2) %>
42   <tr>
43     <th colspan="2" bgcolor="#dcdcdc">
44       <% ucfirst($section || 'unclassified') %> configuration options
45     </th>
46   </tr>
47 % foreach my $i (grep $_->section eq $section, @config_items) { 
48
49     <tr>
50       <td><a href="javascript:void(0);" onClick="overlib( OLiframeContent('config.cgi?key=<% $i->key %>;agentnum=<% $agentnum %>', 522, 336, 'config_popup' ), CAPTION, 'Enter configuration value', STICKY, AUTOSTATUSCAP, MIDX, 0, MIDY, 0, DRAGGABLE, CLOSECLICK ); return false;" name="<% $i->key %>">
51         <b><% $i->key %></b>&nbsp;-&nbsp;<% $i->description %>
52       </a></td>
53       <td><table border=0>
54 % foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
55 %             my $n = 0; 
56 % if ( $type eq '' ) { 
57
58             <tr>
59               <td><font color="#ff0000">no type</font></td>
60             </tr>
61 % } elsif (   $type eq 'binary' ) {
62
63             <tr>
64               <% $conf->exists($i->key, $agentnum)
65                    ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
66                    : 'empty'
67               %>
68             </tr>
69 % } elsif (   $type eq 'textarea'
70 %                      || $type eq 'editlist'
71 %                      || $type eq 'selectmultiple' ) { 
72
73             <tr>
74               <td bgcolor="#ffffff">
75 <pre>
76 <% encode_entities(join("\n", $conf->config($i->key, $agentnum) ) ) %>
77 </pre>
78               </td>
79             </tr>
80 % } elsif ( $type eq 'checkbox' ) { 
81
82             <tr>
83               <td bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
84             </tr>
85 % } elsif ( $type eq 'text' || $type eq 'select' )  { 
86
87             <tr>
88               <td bgcolor="#ffffff">
89                 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
90               </td></tr>
91 % } elsif ( $type eq 'select-sub' ) { 
92
93             <tr>
94               <td bgcolor="#ffffff">
95                 <% $conf->config($i->key, $agentnum) %>: 
96                 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
97               </td>
98             </tr>
99 % } else { 
100
101             <tr><td>
102               <font color="#ff0000">unknown type <% $type %></font>
103             </td></tr>
104 % } 
105 % $n++; } 
106
107       </table></td>
108     </tr>
109 % } 
110
111   </table><br><br>
112 % } 
113
114
115 </body></html>
116 <%init>
117 die "access denied"
118   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
119
120 my ($conf, $title, @config_items, $agentnum);
121
122 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
123   $agentnum = $1;
124 }
125
126 if ($agentnum) {
127   my $agent = qsearchs('agent', { 'agentnum' => $agentnum } );
128   die "Agent $agentnum not found!" unless $agent;
129
130   $title = "Configuration for ". $agent->agent;
131 } else {
132   $title = 'Global Configuration';
133 }
134
135 $conf = new FS::Conf;
136 @config_items = grep { $agentnum ? $_->per_agent : 1 } $conf->config_items; 
137
138 </%init>