X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fconfig%2Fconfig.cgi;h=50b3eba85dd3c47323d2b2c8dcf501f7f3c78f22;hb=7b0bbc4117a7959b9f7b7b2cf999b8188ba34160;hp=369314d98986d947acf29925a4178e1a97eccd06;hpb=3ce7691203a7737406bf2d4442f7fd84b81f847e;p=freeside.git diff --git a/httemplate/config/config.cgi b/httemplate/config/config.cgi index 369314d98..50b3eba85 100644 --- a/httemplate/config/config.cgi +++ b/httemplate/config/config.cgi @@ -1,5 +1,5 @@ - -<% include("/elements/header.html",'Edit Configuration', menubar( 'Main Menu' => $p ) ) %> +<% include("/elements/header-popup.html", $title) %> + -% my $conf = new FS::Conf; my @config_items = $conf->config_items; - - -
-% 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') %>] -% } -% } - -
- <% table("#cccccc", 2) %> - - - <% ucfirst($section || 'unclassified') %> configuration options - - -% foreach my $i (grep $_->section eq $section, @config_items) { - - - + +<% include('/elements/error.html') %> + + + + + + +Setting <% $key %> + +% my $description_printed = 0; +% if ( grep $_ eq 'textarea', @types ) { +% $description_printed = 1; + + - <% $description %> + +% } + + -% if ( defined $i->editlist_parts ) { -% my $pnum=0; foreach my $part ( @{$i->editlist_parts} ) { + + +% if ( defined $config_item->editlist_parts ) { +% my $pnum=0; +% foreach my $part ( @{$config_item->editlist_parts} ) { + + + +% $pnum++; +% } +% } else { + + + +% } + + +
+ % my $n = 0; -% foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { -% #warn $i->key unless defined($type); -% -% if ( $type eq '' ) { +% my $submit = 0; +% foreach my $type (@types) { +% if ( $type eq '' ) { + + no type + +% } elsif ( $type eq 'image' ) { +% $submit++; + + <% $conf->exists($key, $agentnum) + ? 'Current image
'. + '
' + : '' + %> + +
+ New image filename "> +% } elsif ( $type eq 'binary' ) { +% $submit++; - no type -% } elsif ( $type eq 'textarea' ) { + Filename "> + +% } elsif ( $type eq 'textarea' ) { +% $submit++; + + + +% } elsif ( $type eq 'checkbox' ) { +% +% if ( $agentnum && $conf->exists($key) && ! $agent_bool ) { + " type="checkbox" value="1" CHECKED DISABLED> + (global setting cannot yet be overridden) - -% } elsif ( $type eq 'checkbox' ) { +% } else { +% $submit++; + " type="checkbox" value="1" + <% $conf->config_bool($key, $agentnum) ? 'CHECKED' : '' %> > +% } - exists($i->key) ? ' CHECKED' : '' %>> -% } elsif ( $type eq 'text' ) { +% } elsif ( $type eq 'text' ) { +% $submit++; + " type="text" value="<% $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : '' |h %>"> - -% } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) { +% } elsif ( $type eq 'select' || $type eq 'selectmultiple' ) { +% $submit++; + + > -% -% my %hash = (); -% if ( $i->select_enum ) { -% tie %hash, 'Tie::IxHash', -% '' => '', map { $_ => $_ } @{ $i->select_enum }; -% } elsif ( $i->select_hash ) { -% if ( ref($i->select_hash) eq 'ARRAY' ) { -% tie %hash, 'Tie::IxHash', -% '' => '', @{ $i->select_hash }; -% } else { -% tie %hash, 'Tie::IxHash', -% '' => '', %{ $i->select_hash }; -% } -% } else { -% %hash = ( '' => 'WARNING: neither select_enum nor select_hash specified in Conf.pm for configuration option "'. $i->key. '"' ); -% } % -% my %saw = (); -% foreach my $value ( keys %hash ) { -% local($^W)=0; next if $saw{$value}++; -% my $label = $hash{$value}; -% - - -
-% if ( $part->{type} eq 'text' ) { +% } - "> -% } elsif ( $part->{type} eq 'immutable' ) { + - <% $part->{value} %>" value="<% $part->{value} %>"> -% } elsif ( $part->{type} eq 'select' ) { +% } elsif ( $type eq 'editlist' ) { +% $submit++; + +
+ ()"> + +
<% itable() %>
+ +% if ( $part->{type} eq 'text' ) { + + "> + +% } elsif ( $part->{type} eq 'immutable' ) { + + <% $part->{value} %> + " value="<% $part->{value} %>"> + +% } elsif ( $part->{type} eq 'select' ) { + + + +% } else { + + unknown type <% $part->type %> + +% } + + >(this.form)">
+ +% } elsif ( $element_types{$type} ) { +% $submit++; +% +% my %opt = ( 'element_name' => "$key$n", +% 'empty_label' => ' ', +% ); +% if ( $config_item->multiple ) { +% $opt{'multiple'} = 1 if $config_item->multiple; +% $opt{'curr_value'} = [ $conf->config($key, $agentnum) ]; +% } else { +% $opt{'curr_value'} = +% $conf->exists($key, $agentnum) ? $conf->config($key, $agentnum) : ''; +% } + + <% include("/elements/$type.html", %opt ) %> + +% } else { + + unknown type <% $type %> + +% } +% $n++; +% } + + +% unless ( $description_printed ) { + <% $description %> +% } + + + +% if ( $submit ) { + +% } +
+ + + +<%once> + +my %element_types = map { $_ => 1 } qw( + select-part_svc select-part_pkg select-pkg_class select-agent +); + + +<%init> + +die "access denied" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $action = 'Set'; + +my $agentnum = ''; +if ($cgi->param('agentnum') =~ /(\d+)$/) { + $agentnum=$1; +} + +my $locale = ''; +if ( $cgi->param('locale') =~ /^(\w+_\w+)$/) { + $locale = $1; +} + +my $conf = new FS::Conf { 'locale' => $locale, 'localeonly' => 1 }; +my @config_items = $conf->config_items; +my %confitems = map { $_->key => $_ } @config_items; + +my $agent = ''; +my $title; +if ($agentnum) { + $agent = qsearchs('agent', { 'agentnum' => $1 } ); + die "Agent $agentnum not found!" unless $agent; + + $title = "$action configuration override for ". $agent->agent; +} else { + $title = "$action global configuration"; +} +$cgi->param('key') =~ /^([-.\w]+)$/ or die "illegal configuration item"; +my $key = $1; +my $value = $conf->config($key); +my $config_item = $confitems{$key}; - +my $description = $config_item->description; +my $config_type = $config_item->type; +my @types = ref($config_type) ? @$config_type : ($config_type); +my $agent_bool = $config_item->agent_bool; - +