X-Git-Url: http://git.freeside.biz/gitweb/?p=freeside.git;a=blobdiff_plain;f=httemplate%2Fconfig%2Fconfig-process.cgi;h=c96f8d44d86df77ccf3b3d9c6c4e2df10ce80a03;hp=99957ebd9a3e8dbf8cdfdc4825fd361f4e6ef7f6;hb=dad1e2689ba5ff448bf1bbc9a586023137864d12;hpb=4308bf79cf9f31b6ec471788c34cde9b92a3c29b diff --git a/httemplate/config/config-process.cgi b/httemplate/config/config-process.cgi index 99957ebd9..c96f8d44d 100644 --- a/httemplate/config/config-process.cgi +++ b/httemplate/config/config-process.cgi @@ -1,46 +1,149 @@ -<% - my $conf = new FS::Conf; - $FS::Conf::DEBUG = 1; - my @config_items = $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) ) { - 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' ) { - if ( $cgi->param($i->key. $n) ) { - $conf->set($i->key, $cgi->param($i->key. $n)); - } else { - $conf->delete($i->key); - } - } else { - } - $n++; +<% header('Configuration set') %> + + + +<%once> +#false laziness w/config-view.cgi +my %namecol = ( + 'part_svc' => 'svc', + 'part_pkg' => 'pkg', + 'pkg_class' => 'classname', +); + +<%init> + +my $curuser = $FS::CurrentUser::CurrentUser; +die "access denied\n" unless $curuser->access_right('Configuration'); + +my $conf = new FS::Conf; + +if ( $conf->exists('disable_settings_changes') ) { + my @changers = split(/\s*,\s*/, $conf->config('disable_settings_changes')); + my %changers = map { $_=>1 } @changers; + unless ( $changers{$curuser->username} ) { + errorpage("Disabled in web demo"); + die "shouldn't be reached"; } +} + +$FS::Conf::DEBUG = 1; +my @config_items = grep { $_->key != ~/^invoice_(html|latex|template)/ } + $conf->config_items; +my %confitems = map { $_->key => $_ } $conf->config_items; -%> -<%= $cgi->redirect("config-view.cgi") %> +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); + } + }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); + } + } + $n++; +} +# warn @touch; +$conf->touch($_, $agentnum) foreach @touch; +$conf->delete($_, $agentnum) foreach @delete; +