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 ) {
106 % ? _config_agentonly($conf, $i->key, $agent->agentnum)->confnum
107 % : $conf->_config( $i->key )->confnum;
108 % my $showagent = $cgi->param('showagent') ? '_showagent' : '';
109 (<A HREF="javascript:areyousure('delete this configuration item', 'config-delete.cgi?confnum=<% $confnum %>;redirect=config_view<%$showagent%>')">delete configuration item</A>)
116 % foreach my $type (@types) {
118 % if ( $type eq '' ) {
121 <td><font color="#ff0000">no type</font></td>
124 % } elsif ( $type eq 'image' ) {
127 <td bgcolor='#ffffff'>
128 <% $conf->exists($i->key, $agentnum)
129 ? '<img src="config-image.cgi?key='. $i->key.
130 ';agentnum='. $agentnum. '">'
137 <% $conf->exists($i->key, $agentnum)
138 ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
144 % } elsif ( $type eq 'binary' ) {
148 <% $conf->exists($i->key, $agentnum)
149 ? qq!<a href="config-download.cgi?key=!. $i->key. ';agentnum='. $agentnum. qq!">download</a>!
155 % } elsif ( $type eq 'textarea'
156 % || $type eq 'editlist'
157 % || $type eq 'selectmultiple' ) {
160 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
161 <font size="-2"><pre><% encode_entities(join("\n",
162 map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
163 $conf->config($i->key, $agentnum)
169 % } elsif ( $type eq 'checkbox' ) {
172 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#<% $conf->exists($i->key, $agentnum) ? '00ff00">YES' : 'ff0000">NO' %></td>
175 % } elsif ( $type eq 'select' && $i->select_hash ) {
178 % if ( ref($i->select_hash) eq 'ARRAY' ) {
179 % tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash };
181 % tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash };
185 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
186 <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %>
190 % } elsif ( $type eq 'text' || $type eq 'select' ) {
193 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
194 <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %>
198 % } elsif ( $type eq 'select-sub' ) {
201 <td id="<% $agentnum.$i->key.$n %>" bgcolor="#ffffff">
202 <% $conf->config($i->key, $agentnum) %>:
203 <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
210 <font color="#ff0000">unknown type <% $type %></font>
219 % } # foreach my $agentnum
221 % if ( @add_agents ) {
226 Add <b><% $i->key %></b> override for
227 <% include('/elements/select-agent.html',
228 'agents' => \@add_agents,
229 'empty_label' => 'Select agent',
230 'onchange' => "agent_changed",
231 'id' => 'agent_'. $i->key,
236 % my $agent_el = "document.getElementById('agent_". $i->key. "')";
237 <INPUT TYPE = "button"
239 ID = "add_<% $i->key %>"
242 include('/elements/popup_link_onclick.html',
244 'config.cgi?key='. $i->key.
246 "$agent_el.options[$agent_el.selectedIndex].value".
250 'actionlabel' => 'Enter configuration value',
264 % } # foreach my $nav_section
266 <SCRIPT TYPE="text/javascript">
268 function agent_changed(what) {
269 var key = what.id.substring(6); // trim agent_
270 var button = document.getElementById('add_'+key);
271 if ( what.selectedIndex > 0 ) {
272 button.disabled = false;
274 button.disabled = true;
278 function areyousure(what, href) {
279 if ( confirm("Are you sure you want to " + what + "?") == true )
280 window.location.href = href;
288 #should probably be a Conf method. what else would need to use it?
289 sub _config_agentonly {
290 my($self,$name,$agentnum)=@_;
291 my $hashref = { 'name' => $name };
292 $hashref->{agentnum} = $agentnum;
293 local $FS::Record::conf = undef; # XXX evil hack prevents recursion
294 FS::Record::qsearchs('conf', $hashref);
301 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
306 if ($cgi->param('agentnum') =~ /^(\d+)$/) {
307 my $page_agentnum = $1;
308 $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } );
309 die "Agent $page_agentnum not found!" unless $page_agent;
311 push @menubar, 'View all agents' => $p.'browse/agent.cgi';
312 $title = 'Agent Configuration for '. $page_agent->agent;
314 $title = 'Global Configuration';
317 my $conf = new FS::Conf;
319 my @config_items = grep { $page_agent ? $_->per_agent : 1 }
322 my @sections = qw(required billing username password UI session shell BIND );
323 push @sections, '', 'deprecated';
325 my %section_items = ();
326 foreach my $section (@sections) {
327 $section_items{$section} = [ grep $_->section eq $section, @config_items ];
330 @sections = grep scalar( @{ $section_items{$_} } ), @sections;
333 if ( $cgi->param('showagent') ) {
334 @all_agents = qsearch('agent', { 'disabled' => '' } );
336 warn 'all agents: '. join('-', @all_agents);