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') ) {
100 (<A HREF="javascript:areyousure('delete this agent override', 'config-delete.cgi?confnum=<% _config_agentonly($conf, $i->key, $agent->agentnum)->confnum %>;redirect=config_view')">delete agent override</A>)
107 % foreach my $type (@types) {
109 % if ( $type eq '' ) {
112 <td><font color="#ff0000">no type</font></td>
115 % } elsif ( $type eq 'image' ) {
118 <td bgcolor='#ffffff'>
119 <% $conf->exists($i->key, $agentnum)
120 ? '<img src="config-image.cgi?key='. $i->key.
121 ';agentnum='. $agentnum. '">'
128 <% $conf->exists($i->key, $agentnum)
129 ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
135 % } elsif ( $type eq 'binary' ) {
139 <% $conf->exists($i->key, $agentnum)
140 ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
146 % } elsif ( $type eq 'textarea'
147 % || $type eq 'editlist'
148 % || $type eq 'selectmultiple' ) {
151 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
152 <font size="-2"><pre><% encode_entities(join("\n",
153 map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
154 $conf->config($i->key, $agentnum)
160 % } elsif ( $type eq 'checkbox' ) {
163 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
166 % } elsif ( $type eq 'select' && $i->select_hash ) {
169 % if ( ref($i->select_hash) eq 'ARRAY' ) {
170 % tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
172 % tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
176 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
177 <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %>
181 % } elsif ( $type eq 'text' || $type eq 'select' ) {
184 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
185 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
189 % } elsif ( $type eq 'select-sub' ) {
192 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
193 <% $conf->config($i->key, $agentnum) %>:
194 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
201 <font color="#ff0000">unknown type <% $type %></font>
210 % } # foreach my $agentnum
212 % if ( @add_agents ) {
217 Add <b><% $i->key %></b> override for
218 <% include('/elements/select-agent.html',
219 'agents' => \@add_agents,
220 'empty_label' => 'Select agent',
221 'onchange' => "agent_changed",
222 'id' => 'agent_'. $i->key,
227 % my $agent_el = "document.getElementById('agent_". $i->key. "')";
228 <INPUT TYPE = "button"
230 ID = "add_<% $i->key %>"
233 include('/elements/popup_link_onclick.html',
235 'config.cgi?key='. $i->key.
237 "$agent_el.options[$agent_el.selectedIndex].value".
241 'actionlabel' => 'Enter configuration value',
255 % } # foreach my $nav_section
257 <SCRIPT TYPE="text/javascript">
259 function agent_changed(what) {
260 var key = what.id.substring(6); // trim agent_
261 var button = document.getElementById('add_'+key);
262 if ( what.selectedIndex > 0 ) {
263 button.disabled = false;
265 button.disabled = true;
269 function areyousure(what, href) {
270 if ( confirm("Are you sure you want to " + what + "?") == true )
271 window.location.href = href;
279 #should probably be a Conf method. what else would need to use it?
280 sub _config_agentonly {
281 my($self,$name,$agentnum)=@_;
282 my $hashref = { 'name' => $name };
283 $hashref->{agentnum} = $agentnum;
284 local $FS::Record::conf = undef; # XXX evil hack prevents recursion
285 FS::Record::qsearchs('conf', $hashref);
292 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
297 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
298 my $page_agentnum = $1;
299 $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } );
300 die "Agent $page_agentnum not found!" unless $page_agent;
302 push @menubar, 'View all agents' => $p.'browse/agent.cgi';
303 $title = 'Agent Configuration for '. $page_agent->agent;
305 $title = 'Global Configuration';
308 my $conf = new FS::Conf;
310 my @config_items = grep { $page_agent ? $_->per_agent : 1 }
311 grep { $_->key != ~/^invoice_(html|latex|template)/ }
314 my @sections = qw(required billing username password UI session shell BIND );
315 push @sections, '', 'deprecated';
317 my %section_items = ();
318 foreach my $section (@sections) {
319 $section_items{$section} = [ grep $_->section eq $section, @config_items ];
322 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
325 if ( $cgi->param('showagent') ) {
326 @all_agents = qsearch('agent', { 'disabled' => '' } );
328 warn 'all agents: '. join('-', @all_agents);