3 # Add a new line to the M4 file
5 require './sendmail-lib.pl';
6 require './features-lib.pl';
8 $features_access || &error($text{'features_ecannot'});
9 &error_setup($text{'feature_err'});
11 @features = &list_features();
13 $feature = { 'type' => $in{'type'} };
16 $feature = $features[$in{'idx'}];
19 &lock_file($config{'sendmail_mc'});
21 # Just delete this entry
22 &delete_feature($feature);
25 # Validate and store inputs
26 if ($feature->{'type'} == 0) {
27 $feature->{'text'} = $in{'text'};
29 elsif ($feature->{'type'} == 1) {
30 #local ($same) = grep { $_->{'type'} == 1 &&
31 # $_->{'name'} eq $in{'name'} } @features;
32 #$same && ($in{'new'} || $feature->{'name'} ne $in{'name'}) &&
33 # &error(&text('feature_efeat', "<tt>$in{'name'}</tt>"));
34 $feature->{'name'} = $in{'name'};
36 for($i=0; defined($in{"value_$i"}); $i++) {
37 push(@v, $in{"value_$i"});
39 while($v[$#v] eq '' && @v) { pop(@v); }
40 $feature->{'values'} = \@v;
42 elsif ($feature->{'type'} == 2 || $feature->{'type'} == 3) {
43 local ($same) = grep { ($_->{'type'} == 2 || $_->{'type'} == 3) &&
44 $_->{'name'} eq $in{'name'} } @features;
45 $same && ($in{'new'} || $feature->{'name'} ne $in{'name'}) &&
46 &error(&text('feature_edef', "<tt>$in{'name'}</tt>"));
47 $feature->{'name'} = $in{'name'};
49 $feature->{'type'} = 3;
52 $feature->{'type'} = 2;
53 $feature->{'value'} = $in{'value'};
56 elsif ($feature->{'type'} == 4) {
57 local ($same) = grep { $_->{'type'} == 4 &&
58 $_->{'mailer'} eq $in{'mailer'} } @features;
59 $same && ($in{'new'} || $feature->{'mailer'} ne $in{'mailer'}) &&
60 &error(&text('feature_emailer', "<tt>$in{'mailer'}</tt>"));
61 $feature->{'mailer'} = $in{'mailer'};
63 elsif ($feature->{'type'} == 5) {
64 local ($same) = grep { $_->{'type'} == 5 } @features;
65 $same && $in{'new'} &&
66 &error(&text('feature_eostype', "<tt>$in{'ostype'}</tt>"));
67 $feature->{'ostype'} = $in{'ostype'};
70 # Save or create the entry
72 &create_feature($feature);
75 &modify_feature($feature);
79 &unlock_file($config{'sendmail_mc'});
80 &webmin_log($in{'new'} ? 'create' : $in{'delete'} ? 'delete' : 'modify',
81 "feature", undef, $feature);
82 &redirect("list_features.cgi");