4 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
6 # errant GET/POST protection
7 my $Vars = scalar($cgi->Vars);
8 my $num_Vars = scalar(keys %$Vars);
9 die "only received $num_Vars params; errant or truncated GET/POST?".
10 " aborting - not updating config\n"
11 unless $num_Vars > 100;
13 my $conf = new FS::Conf;
15 my @config_items = $conf->config_items;
17 foreach my $i ( @config_items ) {
21 foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
23 } elsif ( $type eq 'textarea' ) {
24 if ( $cgi->param($i->key. $n) ne '' ) {
25 my $value = $cgi->param($i->key. $n);
26 $value =~ s/\r\n/\n/g; #browsers?
27 $conf->set($i->key, $value);
29 $conf->delete($i->key);
31 } elsif ( $type eq 'checkbox' ) {
32 # if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) {
33 if ( defined $cgi->param($i->key. $n) ) {
34 #$conf->touch($i->key);
37 #$conf->delete($i->key);
38 push @delete, $i->key;
40 } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) {
41 if ( $cgi->param($i->key. $n) ne '' ) {
42 $conf->set($i->key, $cgi->param($i->key. $n));
44 $conf->delete($i->key);
46 } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) {
47 if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) {
48 $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} ));
50 $conf->delete($i->key);
57 $conf->touch($_) foreach @touch;
58 $conf->delete($_) foreach @delete;
62 <% $cgi->redirect("config-view.cgi") %>