3 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
5 my $conf = new FS::Conf;
7 my @config_items = $conf->config_items;
8 my %confitems = map { $_->key => $_ } $conf->config_items;
10 my $agentnum = $cgi->param('agentnum');
11 my $key = $cgi->param('key');
12 my $i = $confitems{$key};
17 foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
19 } elsif ( $type eq 'textarea' ) {
20 if ( $cgi->param($i->key.$n) ne '' ) {
21 my $value = $cgi->param($i->key.$n);
22 $value =~ s/\r\n/\n/g; #browsers?
23 $conf->set($i->key, $value, $agentnum);
25 $conf->delete($i->key, $agentnum);
27 } elsif ( $type eq 'binary' ) {
28 if ( defined($cgi->param($i->key.$n)) && $cgi->param($i->key.$n) ) {
29 my $fh = $cgi->upload($i->key.$n);
32 $conf->set_binary($i->key, <$fh>, $agentnum);
35 warn "Condition failed for " . $i->key;
37 } elsif ( $type eq 'checkbox' ) {
38 if ( defined $cgi->param($i->key.$n) ) {
41 push @delete, $i->key;
43 } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) {
44 if ( $cgi->param($i->key.$n) ne '' ) {
45 $conf->set($i->key, $cgi->param($i->key.$n), $agentnum);
47 $conf->delete($i->key, $agentnum);
49 } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) {
50 if ( scalar(@{[ $cgi->param($i->key.$n) ]}) ) {
51 $conf->set($i->key, join("\n", @{[ $cgi->param($i->key.$n) ]} ), $agentnum);
53 $conf->delete($i->key, $agentnum);
59 $conf->touch($_, $agentnum) foreach @touch;
60 $conf->delete($_, $agentnum) foreach @delete;
63 <% header('Configuration set') %>
64 <SCRIPT TYPE="text/javascript">
65 window.top.location.reload();