1 <% include("/elements/header.html", $title, menubar(@menubar)) %>
3 Click on a configuration value to change it.
6 % unless ( $page_agent ) {
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);
13 % $cgi->param('showagent', 1);
14 ( <a href="<% $cgi->self_url %>">show agent overrides</a> )
15 % $cgi->param('showagent', 0);
21 <% include('/elements/init_overlib.html') %>
23 % if ($FS::UID::use_confcompat) {
24 <FONT SIZE="+1" COLOR="#ff0000">CONFIGURATION NOT STORED IN DATABASE -- USING COMPATIBILITY MODE</FONT><BR><BR>
27 % foreach my $section (@sections) {
29 <A NAME="<% $section || 'unclassified' %>"></A>
32 % foreach my $nav_section (@sections) {
34 % if ( $section eq $nav_section ) {
35 [<A NAME="not<% $nav_section || 'unclassified' %>" style="background-color: #cccccc"><% ucfirst($nav_section || 'unclassified') %></A>]
37 [<A HREF="#<% $nav_section || 'unclassified' %>"><% ucfirst($nav_section || 'unclassified') %></A>]
43 <TABLE BGCOLOR="#cccccc" BORDER=1 CELLSPACING=0 CELLPADDING=0 BORDERCOLOR="#999999">
45 <th colspan="2" bgcolor="#dcdcdc">
46 <% ucfirst($section || 'unclassified') %> configuration options
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 ) {
62 % my @add_agents = ();
63 % if ( $page_agent ) {
64 % @agents = ( $page_agent );
67 % if ( $i->per_agent ) {
68 % foreach my $agent (@all_agents) {
69 % if ( defined(_config_agentonly($conf, $i->key, $agent->agentnum)) ) {
70 % push @agents, $agent;
72 % push @add_agents, $agent;
78 % foreach my $agent ( @agents ) {
79 % my $agentnum = $agent ? $agent->agentnum : '';
81 % my $label = $i->key;
82 % $label = '['. $agent->agent. "] $label"
83 % if $agent && $cgi->param('showagent');
88 <td><% include('/elements/popup_link.html',
89 'action' => 'config.cgi?key='. $i->key.
90 ';agentnum='. $agentnum,
93 'actionlabel' => 'Enter configuration value',
94 'label' => "<b>$label</b>",
95 'aname' => $i->key, #agentnum
96 # if $cgi->param('showagent')?
98 %>: <% $i->description %>
99 % if ( $agent && $cgi->param('showagent') ) {
101 % _config_agentonly($conf, $i->key, $agent->agentnum)->confnum;
102 (<A HREF="javascript:areyousure('delete this agent override', 'config-delete.cgi?confnum=<% $confnum %>;redirect=config_view_showagent')">delete agent override</A>)
103 % } elsif ( $i->base_key
104 % || ( $deleteable{$i->key} && $conf->exists($i->key) ) ) {
107 % ? _config_agentonly($conf, $i->key, $agent->agentnum)->confnum
108 % : $conf->_config( $i->key )->confnum;
109 % my $showagent = $cgi->param('showagent') ? '_showagent' : '';
110 (<A HREF="javascript:areyousure('delete this configuration item', 'config-delete.cgi?confnum=<% $confnum %>;redirect=config_view<%$showagent%>')">delete configuration item</A>)
117 % foreach my $type (@types) {
119 % if ( $type eq '' ) {
122 <td><font color="#ff0000">no type</font></td>
125 % } elsif ( $type eq 'image' ) {
128 <td bgcolor='#ffffff'>
129 <% $conf->exists($i->key, $agentnum)
130 ? '<img src="config-image.cgi?key='. $i->key.
131 ';agentnum='. $agentnum. '">'
138 <% $conf->exists($i->key, $agentnum)
139 ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
145 % } elsif ( $type eq 'binary' ) {
149 <% $conf->exists($i->key, $agentnum)
150 ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
156 % } elsif ( $type eq 'textarea'
157 % || $type eq 'editlist'
158 % || $type eq 'selectmultiple' ) {
161 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
162 <font size="-2"><pre><% encode_entities(join("\n",
163 map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
164 $conf->config($i->key, $agentnum)
170 % } elsif ( $type eq 'checkbox' ) {
173 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
176 % } elsif ( $type eq 'select' && $i->select_hash ) {
179 % if ( ref($i->select_hash) eq 'ARRAY' ) {
180 % tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
182 % tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
186 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
187 <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %>
191 % } elsif ( $type eq 'text' || $type eq 'select' ) {
194 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
195 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
199 % } elsif ( $type eq 'select-sub' ) {
202 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
203 <% $conf->config($i->key, $agentnum) %>:
204 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
211 <font color="#ff0000">unknown type <% $type %></font>
220 % } # foreach my $agentnum
222 % if ( @add_agents ) {
227 Add <b><% $i->key %></b> override for
228 <% include('/elements/select-agent.html',
229 'agents' => \@add_agents,
230 'empty_label' => 'Select agent',
231 'onchange' => "agent_changed",
232 'id' => 'agent_'. $i->key,
237 % my $agent_el = "document.getElementById('agent_". $i->key. "')";
238 <INPUT TYPE = "button"
240 ID = "add_<% $i->key %>"
243 include('/elements/popup_link_onclick.html',
245 'config.cgi?key='. $i->key.
247 "$agent_el.options[$agent_el.selectedIndex].value".
251 'actionlabel' => 'Enter configuration value',
265 % } # foreach my $nav_section
267 <SCRIPT TYPE="text/javascript">
269 function agent_changed(what) {
270 var key = what.id.substring(6); // trim agent_
271 var button = document.getElementById('add_'+key);
272 if ( what.selectedIndex > 0 ) {
273 button.disabled = false;
275 button.disabled = true;
279 function areyousure(what, href) {
280 if ( confirm("Are you sure you want to " + what + "?") == true )
281 window.location.href = href;
289 #should probably be a Conf method. what else would need to use it?
290 sub _config_agentonly {
291 my($self,$name,$agentnum)=@_;
292 my $hashref = { 'name' => $name };
293 $hashref->{agentnum} = $agentnum;
294 local $FS::Record::conf = undef; # XXX evil hack prevents recursion
295 FS::Record::qsearchs('conf', $hashref);
302 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
307 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
308 my $page_agentnum = $1;
309 $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } );
310 die "Agent $page_agentnum not found!" unless $page_agent;
312 push @menubar, 'View all agents' => $p.'browse/agent.cgi';
313 $title = 'Agent Configuration for '. $page_agent->agent;
315 $title = 'Global Configuration';
318 my $conf = new FS::Conf;
320 my @config_items = grep { $page_agent ? $_->per_agent : 1 }
323 my @deleteable = qw( invoice_latexreturnaddress invoice_htmlreturnaddress );
324 my %deleteable = map { $_ => 1 } @deleteable;
326 my @sections = qw(required billing username password UI session shell BIND );
327 push @sections, '', 'deprecated';
329 my %section_items = ();
330 foreach my $section (@sections) {
331 $section_items{$section} = [ grep $_->section eq $section, @config_items ];
334 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
337 if ( $cgi->param('showagent') ) {
338 @all_agents = qsearch('agent', { 'disabled' => '' } );
340 warn 'all agents: '. join('-', @all_agents);