X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fconfig%2Fconfig-process.cgi;h=788d9016e91006d7f205bc5bb5f362c865bab561;hb=7b125e587a4d1ee0aca692e23ea7897f671855ae;hp=38d9af0db778c156dc12cb0e75f2865174a1a01e;hpb=daac302e231e2e09b84e771c0413b0f2119c52e8;p=freeside.git diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 38d9af0db..788d9016e 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,51 +1,138 @@ -<% - my $conf = new FS::Conf; - $FS::Conf::DEBUG = 1; - my @config_items = $conf->config_items; +<% header('Configuration set') %> + + + +<%once> +#false laziness w/config-view.cgi +my %namecol = ( + 'part_svc' => 'svc', + 'part_pkg' => 'pkg', + 'pkg_class' => 'classname', +); + +<%init> +die "access denied\n" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); + +my $conf = new FS::Conf; +$FS::Conf::DEBUG = 1; +my @config_items = grep { $_->key != ~/^invoice_(html|latex|template)/ } + $conf->config_items; +my %confitems = map { $_->key => $_ } $conf->config_items; - foreach my $i ( @config_items ) { - my @touch = (); - my @delete = (); - my $n = 0; - foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { - if ( $type eq '' ) { - } elsif ( $type eq 'textarea' ) { - if ( $cgi->param($i->key. $n) ne '' ) { - my $value = $cgi->param($i->key. $n); - $value =~ s/\r\n/\n/g; #browsers? - $conf->set($i->key, $value); - } else { - $conf->delete($i->key); - } - } elsif ( $type eq 'checkbox' ) { -# if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) { - if ( defined $cgi->param($i->key. $n) ) { - #$conf->touch($i->key); - push @touch, $i->key; - } else { - #$conf->delete($i->key); - push @delete, $i->key; - } - } elsif ( $type eq 'text' || $type eq 'select' ) { - if ( $cgi->param($i->key. $n) ne '' ) { - $conf->set($i->key, $cgi->param($i->key. $n)); - } else { - $conf->delete($i->key); - } - } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) { - if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) { - $conf->set($i->key, join("\n", $cgi->param($i->key. $n) )); - } else { - $conf->delete($i->key); - } - } else { +my $agentnum = $cgi->param('agentnum'); +my $key = $cgi->param('key'); +my $i = $confitems{$key}; + +my @touch = (); +my @delete = (); +my $n = 0; +foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) { + if ( $type eq '' ) { + } elsif ( $type eq 'textarea' ) { + if ( $cgi->param($i->key.$n) ne '' ) { + my $value = $cgi->param($i->key.$n); + $value =~ s/\r\n/\n/g; #browsers? + $conf->set($i->key, $value, $agentnum); + } else { + $conf->delete($i->key, $agentnum); + } + } elsif ( $type eq 'binary' || $type eq 'image' ) { + if ( defined($cgi->param($i->key.$n)) && $cgi->param($i->key.$n) ) { + my $fh = $cgi->upload($i->key.$n); + if (defined($fh)) { + local $/; + $conf->set_binary($i->key, <$fh>, $agentnum); } - $n++; + }else{ + warn "Condition failed for " . $i->key; + } + } elsif ( $type eq 'checkbox' ) { + if ( defined $cgi->param($i->key.$n) ) { + push @touch, $i->key; + } else { + push @delete, $i->key; + } + } elsif ( + $type =~ /^(editlist|selectmultiple)$/ + or ( $type =~ /^select(-(sub|part_svc|part_pkg|pkg_class))?$/ + || $i->multiple ) + ) { + if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) { + $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum); + } else { + $conf->delete($i->key, $agentnum); + } + } elsif ( $type =~ /^(text|select(-(sub|part_svc|part_pkg|pkg_class))?)$/ ) { + if ( $cgi->param($i->key.$n) ne '' ) { + $conf->set($i->key, $cgi->param($i->key.$n), $agentnum); + } else { + $conf->delete($i->key, $agentnum); } - # warn @touch; - $conf->touch($_) foreach @touch; - $conf->delete($_) foreach @delete; } + $n++; +} +# warn @touch; +$conf->touch($_, $agentnum) foreach @touch; +$conf->delete($_, $agentnum) foreach @delete; -%> -<%= $cgi->redirect("config-view.cgi") %> +