X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fconfig%2Fconfig-process.cgi;h=a5918c035c17457ab329de0bddc1f3c1e7012656;hb=8cda5aa78a9ae58afe4b9f3684165658eb73c163;hp=2597132609524fc2d0a20050090bc16eff073ac4;hpb=eb9668a6f3181ee02cb335272c5ee4616e61fd09;p=freeside.git diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 259713260..a5918c035 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,51 +1,114 @@ -<% - my $conf = new FS::Conf; - $FS::Conf::DEBUG = 1; - my @config_items = $conf->config_items; +<%init> +die "access denied\n" + unless $FS::CurrentUser::CurrentUser->access_right('Configuration'); - 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 $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; + +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 eq 'text' || $type eq 'select' || $type eq 'select-sub' ) { + if ( $cgi->param($i->key.$n) ne '' ) { + $conf->set($i->key, $cgi->param($i->key.$n), $agentnum); + } else { + $conf->delete($i->key, $agentnum); + } + } 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) ]} ), $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; + + +<% header('Configuration set') %> + +