3 unless $FS::CurrentUser::CurrentUser->access_right('Configuration');
5 # errant GET/POST protection
6 my $Vars = scalar($cgi->Vars);
7 my $num_Vars = scalar(keys %$Vars);
8 die "only received $num_Vars params; errant or truncated GET/POST?".
9 " aborting - not updating config\n"
10 unless $num_Vars > 100;
12 my $conf = new FS::Conf;
14 my @config_items = $conf->config_items;
16 foreach my $i ( @config_items ) {
20 foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
22 } elsif ( $type eq 'textarea' ) {
23 if ( $cgi->param($i->key. $n) ne '' ) {
24 my $value = $cgi->param($i->key. $n);
25 $value =~ s/\r\n/\n/g; #browsers?
26 $conf->set($i->key, $value);
28 $conf->delete($i->key);
30 } elsif ( $type eq 'binary' ) {
31 if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) {
32 my $fh = $cgi->upload($i->key. $n);
35 $conf->set_binary($i->key, <$fh>);
38 warn "Condition failed for " . $i->key;
40 } elsif ( $type eq 'checkbox' ) {
41 # if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) {
42 if ( defined $cgi->param($i->key. $n) ) {
43 #$conf->touch($i->key);
46 #$conf->delete($i->key);
47 push @delete, $i->key;
49 } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' ) {
50 if ( $cgi->param($i->key. $n) ne '' ) {
51 $conf->set($i->key, $cgi->param($i->key. $n));
53 $conf->delete($i->key);
55 } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' ) {
56 if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) {
57 $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} ));
59 $conf->delete($i->key);
66 $conf->touch($_) foreach @touch;
67 $conf->delete($_) foreach @delete;
70 <% $cgi->redirect("config-view.cgi") %>