view all overrides when asked, even the ones without values. hmm :/ RT#5218
[freeside.git] / httemplate / config / config-view.cgi
1 <% include("/elements/header.html", $title, menubar(@menubar)) %>
2
3 Click on a configuration value to change it.
4 <BR><BR>
5
6 % unless ( $page_agent ) {
7 %
8 %   if ( $cgi->param('showagent') ) {
9 %     $cgi->param('showagent', 0);
10       ( <a href="<% $cgi->self_url %>">hide agent overrides</a> )
11 %     $cgi->param('showagent', 1);
12 %   } else {
13 %     $cgi->param('showagent', 1);
14       ( <a href="<% $cgi->self_url %>">show agent overrides</a> )
15 %     $cgi->param('showagent', 0);
16 %   }
17 %
18 % }
19 <BR><BR>
20
21 <% include('/elements/init_overlib.html') %>
22
23 % if ($FS::UID::use_confcompat) {
24   <FONT SIZE="+1" COLOR="#ff0000">CONFIGURATION NOT STORED IN DATABASE -- USING COMPATIBILITY MODE</FONT><BR><BR>
25 %}
26
27 % foreach my $section (@sections) {
28
29     <A NAME="<% $section || 'unclassified' %>"></A>
30     <FONT SIZE="-2">
31
32 %   foreach my $nav_section (@sections) {
33 %
34 %     if ( $section eq $nav_section ) { 
35         [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
36 %     } else { 
37         [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
38 %     } 
39 %
40 %   } 
41
42   </FONT><BR>
43   <TABLE BGCOLOR="#cccccc" BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR="#999999">
44   <tr>
45     <th colspan="2" bgcolor="#dcdcdc">
46       <% ucfirst($section || 'unclassified') %> configuration options
47     </th>
48   </tr>
49 % foreach my $i (@{ $section_items{$section} }) { 
50 %   my @types = ref($i->type) ? @{$i->type} : ($i->type);
51 %   my( $width, $height ) = ( 522, 336 );
52 %   if ( grep $_ eq 'textarea', @types ) {
53 %     #800x600
54 %     $width = 763;
55 %     $height = 408;
56 %     #1024x768
57 %     #$width =
58 %     #$height = 
59 %   }
60 %
61 %   my @agents = $page_agent ? ( $page_agent ) : ( '', @all_agents );
62 %
63 %   foreach my $agent ( @agents ) {
64 %     my $agentnum = $agent ? $agent->agentnum : '';
65 %
66 %     my $label = $i->key;
67 %     $label = '['. $agent->agent. "] $label"
68 %       if $agent && $cgi->param('showagent');
69 %
70 %     #indentation :/
71
72     <tr>
73       <td><% include('/elements/popup_link.html',
74                        'action'      => 'config.cgi?key='.      $i->key.
75                                                   ';agentnum='. $agentnum,
76                        'width'       => $width,
77                        'height'      => $height,
78                        'actionlabel' => 'Enter configuration value',
79                        'label'       => "<b>$label</b>",
80                        'aname'       => $i->key, #agentnum
81                                                  # if $cgi->param('showagent')?
82                     )
83           %>: <% $i->description %>
84       </td>
85       <td><table border=0>
86
87 % my $n = 0;
88 % foreach my $type (@types) {
89
90 %   if ( $type eq '' ) { 
91
92             <tr>
93               <td><font color="#ff0000">no type</font></td>
94             </tr>
95
96 %   } elsif ( $type eq 'image' ) {
97
98             <tr>
99               <td bgcolor='#ffffff'>
100                 <% $conf->exists($i->key, $agentnum)
101                      ? '<img src="config-image.cgi?key='.      $i->key.
102                                                  ';agentnum='. $agentnum. '">'
103                      : 'empty'
104                 %>
105               </td>
106             </tr>
107             <tr>
108               <td>
109                 <% $conf->exists($i->key, $agentnum)
110                      ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
111                      : ''
112                 %>
113               </td>
114             </tr>
115
116 %   } elsif ( $type eq 'binary' ) {
117
118             <tr>
119               <td>
120                 <% $conf->exists($i->key, $agentnum)
121                      ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
122                      : 'empty'
123                 %>
124               </td>
125             </tr>
126
127 %   } elsif (    $type eq 'textarea'
128 %             || $type eq 'editlist'
129 %             || $type eq 'selectmultiple' ) { 
130
131             <tr>
132               <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
133 <font size="-2"><pre><% encode_entities(join("\n",
134      map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
135          $conf->config($i->key, $agentnum)
136    ) )
137 %></pre></font>
138               </td>
139             </tr>
140
141 %   } elsif ( $type eq 'checkbox' ) {
142
143             <tr>
144               <td id="<% $agentnum.$i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
145             </tr>
146
147 %   } elsif ( $type eq 'select' && $i->select_hash ) {
148 %
149 %     my %hash;
150 %     if ( ref($i->select_hash) eq 'ARRAY' ) {
151 %       tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
152 %     } else {
153 %       tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
154 %     }
155
156             <tr>
157               <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
158                 <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %>
159               </td>
160             </tr>
161
162 %   } elsif ( $type eq 'text' || $type eq 'select' ) {
163
164             <tr>
165               <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
166                 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
167               </td>
168             </tr>
169
170 %   } elsif ( $type eq 'select-sub' ) { 
171
172             <tr>
173               <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
174                 <% $conf->config($i->key, $agentnum) %>: 
175                 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
176               </td>
177             </tr>
178
179 %   } else { 
180
181             <tr><td>
182               <font color="#ff0000">unknown type <% $type %></font>
183             </td></tr>
184 %   } 
185 %   $n++;
186 % } 
187
188       </table></td>
189     </tr>
190
191 % } # foreach my $agentnum
192
193 % } # foreach my $i
194
195   </table><br><br>
196
197 % } # foreach my $nav_section
198
199 </body></html>
200 <%once>
201
202 #should probably be a Conf method.  what else would need to use it?
203 #not even us, apparantly...
204 #  defined( _config_agentonly($conf, $i->key, $_->agentnum) )
205 #sub _config_agentonly {
206 #  my($self,$name,$agentnum)=@_;
207 #  my $hashref = { 'name' => $name };
208 #  $hashref->{agentnum} = $agentnum;
209 #  local $FS::Record::conf = undef;  # XXX evil hack prevents recursion
210 #  FS::Record::qsearchs('conf', $hashref);
211 #}
212
213 </%once>
214 <%init>
215
216 die "access denied"
217   unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
218
219 my $page_agent = '';
220 my $title;
221 my @menubar = ();
222 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
223   my $page_agentnum = $1;
224   $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } );
225   die "Agent $page_agentnum not found!" unless $page_agent;
226
227   push @menubar, 'View all agents' => $p.'browse/agent.cgi';
228   $title = 'Agent Configuration for '. $page_agent->agent;
229 } else {
230   $title = 'Global Configuration';
231 }
232
233 my $conf = new FS::Conf;
234  
235 my @config_items = grep { $page_agent ? $_->per_agent : 1 }
236                    grep { $_->key != ~/^invoice_(html|latex|template)/ }
237                         $conf->config_items; 
238
239 my @sections = qw(required billing username password UI session shell BIND );
240 push @sections, '', 'deprecated';
241
242 my %section_items = ();
243 foreach my $section (@sections) {
244   $section_items{$section} = [ grep $_->section eq $section, @config_items ];
245 }
246
247 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
248
249 my @all_agents = ();
250 if ( $cgi->param('showagent') ) {
251   @all_agents = qsearch('agent', { 'disabled' => '' } );
252 }
253 warn 'all agents: '. join('-', @all_agents);
254
255 </%init>