This commit was generated by cvs2svn to compensate for changes in r4888,
[freeside.git] / httemplate / config / config-process.cgi
1 %
2 %  my $conf = new FS::Conf;
3 %  $FS::Conf::DEBUG = 1;
4 %  my @config_items = $conf->config_items;
5 %
6 %  foreach my $i ( @config_items ) {
7 %    my @touch = ();
8 %    my @delete = ();
9 %    my $n = 0;
10 %    foreach my $type ( ref($i->type) ? @{$i->type} : $i->type ) {
11 %      if ( $type eq '' ) {
12 %      } elsif ( $type eq 'textarea' ) {
13 %        if ( $cgi->param($i->key. $n) ne '' ) {
14 %          my $value = $cgi->param($i->key. $n);
15 %          $value =~ s/\r\n/\n/g; #browsers?
16 %          $conf->set($i->key, $value);
17 %        } else {
18 %          $conf->delete($i->key);
19 %        }
20 %      } elsif ( $type eq 'checkbox' ) {
21 %#        if ( defined($cgi->param($i->key. $n)) && $cgi->param($i->key. $n) ) {
22 %        if ( defined $cgi->param($i->key. $n) ) {
23 %          #$conf->touch($i->key);
24 %          push @touch, $i->key;
25 %        } else {
26 %          #$conf->delete($i->key);
27 %          push @delete, $i->key;
28 %        }
29 %      } elsif ( $type eq 'text' || $type eq 'select' || $type eq 'select-sub' )  {
30 %        if ( $cgi->param($i->key. $n) ne '' ) {
31 %          $conf->set($i->key, $cgi->param($i->key. $n));
32 %        } else {
33 %          $conf->delete($i->key);
34 %        }
35 %      } elsif ( $type eq 'editlist' || $type eq 'selectmultiple' )  {
36 %        if ( scalar(@{[ $cgi->param($i->key. $n) ]}) ) {
37 %          $conf->set($i->key, join("\n", @{[ $cgi->param($i->key. $n) ]} ));
38 %        } else {
39 %          $conf->delete($i->key);
40 %        }
41 %      } else {
42 %      }
43 %      $n++;
44 %    }
45 %   # warn @touch;
46 %    $conf->touch($_) foreach @touch;
47 %    $conf->delete($_) foreach @delete;
48 %  }
49 %
50 %
51
52 <% $cgi->redirect("config-view.cgi") %>