Handle hostnames with upper-case letters
[webmin.git] / zones / save_attr.cgi
1 #!/usr/local/bin/perl
2 # Update, add or delete a generic attribute
3
4 require './zones-lib.pl';
5 do 'forms-lib.pl';
6 &ReadParse();
7 $zinfo = &get_zone($in{'zone'});
8 $zinfo || &error($text{'edit_egone'});
9 if (!$in{'new'}) {
10         # Find the filesystem object
11         ($attr) = grep { $_->{'name'} eq $in{'old'} } @{$zinfo->{'attr'}};
12         $attr || &error($text{'attr_egone'});
13         }
14 $attr ||= { 'keytype' => 'attr' };
15
16 if ($in{'delete'}) {
17         # Just remove this attribute
18         &delete_zone_object($zinfo, $attr);
19         }
20 else {
21         # Validate inputs
22         $form = &get_attr_form(\%in, $zinfo, $attr);
23         $form->validate_redirect("edit_attr.cgi");
24         $attr->{'name'} = $form->get_value("name");
25         $attr->{'type'} = $form->get_value("type");
26         $attr->{'value'} = $form->get_value("value");
27         &find_clash($zinfo, $attr) &&
28                 $form->validate_redirect("edit_attr.cgi",
29                                         [ [ "name", $text{'attr_eclash'} ] ]);
30
31         # Save the attribute
32         if ($in{'new'}) {
33                 &create_zone_object($zinfo, $attr);
34                 }
35         else {
36                 &modify_zone_object($zinfo, $attr);
37                 }
38         }
39
40 &webmin_log($in{'new'} ? "create" : $in{'delete'} ? "delete" : "modify",
41             "attr", $in{'old'} || $attr->{'name'}, $attr);
42 &redirect("edit_zone.cgi?zone=$in{'zone'}");
43