X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fconfig%2Fconfig-view.cgi;h=534de02314a1fa7a30fd2b98fc770ae56fb3c22e;hb=8cda5aa78a9ae58afe4b9f3684165658eb73c163;hp=b769e0813992287624d81a84e1fbced0c5b06b91;hpb=4026c3c89e0c73b261e071508b863479aaf12628;p=freeside.git diff --git a/httemplate/config/config-view.cgi b/httemplate/config/config-view.cgi index b769e0813..534de0231 100644 --- a/httemplate/config/config-view.cgi +++ b/httemplate/config/config-view.cgi @@ -1,43 +1,43 @@ -<% include("/elements/header.html", - $title, - menubar( - 'View all agents' => $p.'browse/agent.cgi', - ) - ) -%> +<% include("/elements/header.html", $title, menubar(@menubar)) %> Click on a configuration value to change it.

- - - - +% unless ( $page_agent ) { +% +% if ( $cgi->param('showagent') ) { +% $cgi->param('showagent', 0); + ( hide agent overrides ) +% $cgi->param('showagent', 1); +% } else { +% $cgi->param('showagent', 1); + ( show agent overrides ) +% $cgi->param('showagent', 0); +% } +% +% } +

-% if ($FS::UID::use_confcompat) { +<% include('/elements/init_overlib.html') %> +% if ($FS::UID::use_confcompat) { CONFIGURATION NOT STORED IN DATABASE -- USING COMPATIBILITY MODE

%} + +% foreach my $section (@sections) { + + + + +% foreach my $nav_section (@sections) { % -% foreach my $section ( qw(required billing username password UI session -% shell BIND -% ), -% '', 'deprecated') { - - - -% foreach my $nav_section ( qw(required billing username password UI session -% shell BIND -% ), -% '', 'deprecated') { -% if ( $section eq $nav_section ) { - - [<% ucfirst($nav_section || 'unclassified') %>] -% } else { - - [<% ucfirst($nav_section || 'unclassified') %>] -% } -% } +% if ( $section eq $nav_section ) { + [<% ucfirst($nav_section || 'unclassified') %>] +% } else { + [<% ucfirst($nav_section || 'unclassified') %>] +% } +% +% }
@@ -46,7 +46,7 @@ Click on a configuration value to change it. <% ucfirst($section || 'unclassified') %> configuration options -% foreach my $i (grep $_->section eq $section, @config_items) { +% foreach my $i (@{ $section_items{$section} }) { % my @types = ref($i->type) ? @{$i->type} : ($i->type); % my( $width, $height ) = ( 522, 336 ); % if ( grep $_ eq 'textarea', @types ) { @@ -57,6 +57,26 @@ Click on a configuration value to change it. % #$width = % #$height = % } +% +% my @agents = (); +% if ( $page_agent ) { +% @agents = ( $page_agent ); +% } else { +% @agents = ( +% '', +% grep { defined( _config_agentonly($conf, $i->key, $_->agentnum) ) } +% @all_agents +% ); +% } +% +% foreach my $agent ( @agents ) { +% my $agentnum = $agent ? $agent->agentnum : ''; +% +% my $label = $i->key; +% $label = '['. $agent->agent. "] $label" +% if $agent && $cgi->param('showagent'); +% +% #indentation :/ -% } + +% } # foreach my $agentnum + +% } # foreach my $i
<% include('/elements/popup_link.html', @@ -65,102 +85,178 @@ Click on a configuration value to change it. 'width' => $width, 'height' => $height, 'actionlabel' => 'Enter configuration value', - 'label' => ''. $i->key. '', - 'aname' => $i->key, + 'label' => "$label", + 'aname' => $i->key, #agentnum + # if $cgi->param('showagent')? ) %>: <% $i->description %> + +% my $n = 0; % foreach my $type (@types) { -% my $n = 0; -% if ( $type eq '' ) { + +% if ( $type eq '' ) { -% } elsif ( $type eq 'binary' ) { + +% } elsif ( $type eq 'image' ) { - <% $conf->exists($i->key, $agentnum) - ? qq!download! - : 'empty' - %> + + + + -% } elsif ( $type eq 'textarea' -% || $type eq 'editlist' -% || $type eq 'selectmultiple' ) { + +% } elsif ( $type eq 'binary' ) { - + + +% } elsif ( $type eq 'textarea' +% || $type eq 'editlist' +% || $type eq 'selectmultiple' ) { + + + -% } elsif ( $type eq 'checkbox' ) { + +% } elsif ( $type eq 'checkbox' ) { - + -% } elsif ( $type eq 'text' || $type eq 'select' ) { + +% } elsif ( $type eq 'select' && $i->select_hash ) { +% +% my %hash; +% if ( ref($i->select_hash) eq 'ARRAY' ) { +% tie %hash, 'Tie::IxHash', '' => '', @{ $i->select_hash }; +% } else { +% tie %hash, 'Tie::IxHash', '' => '', %{ $i->select_hash }; +% } + + + + + +% } elsif ( $type eq 'text' || $type eq 'select' ) { - -% } elsif ( $type eq 'select-sub' ) { + + + +% } elsif ( $type eq 'select-sub' ) { - -% } else { + +% } else { +% } +% $n++; % } -% $n++; }
no type
+ <% $conf->exists($i->key, $agentnum) + ? '' + : 'empty' + %> +
+ <% $conf->exists($i->key, $agentnum) + ? qq!download! + : '' + %> +
-
-<% encode_entities(join("\n",
+              
+ <% $conf->exists($i->key, $agentnum) + ? qq!download! + : 'empty' + %> +
+
<% encode_entities(join("\n",
      map { length($_) > 88 ? substr($_,0,88).'...' : $_ }
          $conf->config($i->key, $agentnum)
    ) )
-%>
-
+%>
YES' : 'ff0000">NO' %>YES' : 'ff0000">NO' %>
+ <% $conf->exists($i->key, $agentnum) ? $hash{ $conf->config($i->key, $agentnum) } : '' %> +
+ <% $conf->exists($i->key, $agentnum) ? $conf->config($i->key, $agentnum) : '' %> -
+ <% $conf->config($i->key, $agentnum) %>: <% &{ $i->option_sub }( $conf->config($i->key, $agentnum) ) %>
unknown type <% $type %>


-% } +% } # foreach my $nav_section +<%once> + +#should probably be a Conf method. what else would need to use it? +sub _config_agentonly { + my($self,$name,$agentnum)=@_; + my $hashref = { 'name' => $name }; + $hashref->{agentnum} = $agentnum; + local $FS::Record::conf = undef; # XXX evil hack prevents recursion + FS::Record::qsearchs('conf', $hashref); +} + + <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); -my $agentnum = ''; -if ($cgi->param('agentnum') =~ /^(\d+)$/) { - $agentnum = $1; -} - +my $page_agent = ''; my $title; -if ($agentnum) { - my $agent = qsearchs('agent', { 'agentnum' => $agentnum } ); - die "Agent $agentnum not found!" unless $agent; +my @menubar = (); +if ($cgi->param('agentnum') =~ /^(\d+)$/) { + my $page_agentnum = $1; + $page_agent = qsearchs('agent', { 'agentnum' => $page_agentnum } ); + die "Agent $page_agentnum not found!" unless $page_agent; - $title = "Configuration for ". $agent->agent; + push @menubar, 'View all agents' => $p.'browse/agent.cgi'; + $title = 'Agent Configuration for '. $page_agent->agent; } else { $title = 'Global Configuration'; } my $conf = new FS::Conf; -my @config_items = grep { $agentnum ? $_->per_agent : 1 } +my @config_items = grep { $page_agent ? $_->per_agent : 1 } grep { $_->key != ~/^invoice_(html|latex|template)/ } $conf->config_items; - + +my @sections = qw(required billing username password UI session shell BIND ); +push @sections, '', 'deprecated'; + +my %section_items = (); +foreach my $section (@sections) { + $section_items{$section} = [ grep $_->section eq $section, @config_items ]; +} + +@sections = grep scalar( @{ $section_items{$_} } ), @sections; + +my @all_agents = (); +if ( $cgi->param('showagent') ) { + @all_agents = qsearch('agent', { 'disabled' => '' } ); +} +warn 'all agents: '. join('-', @all_agents); +