Handle hostnames with upper-case letters
[webmin.git] / dhcpd / lookup_group.cgi
1 #!/usr/local/bin/perl
2 # lookup_group.cgi
3 # Find a group with a certain name and re-direct to its editing form
4
5 require './dhcpd-lib.pl';
6 &ReadParse();
7 $in{'group'} || &error($text{'lookup_egroupname'});
8
9 # Recursively find groups
10 $conf = &get_config();
11 @groups = &find_recursive("group", $conf);
12
13 # Look for a match
14 %access = &get_module_acl();
15 foreach $g (@groups) {
16         local $can_view = &can('r', \%access, $g);
17         next if !$can_view && $access{'hide'};
18         local @opts = &find("option", $g->{'members'});
19         local ($dn) = grep { $_->{'values'}->[0] eq 'domain-name' } @opts;
20         if (&search_re($g->{'values'}->[0], $in{'group'}) ||
21             $dn && &search_re($dn->{'values'}->[1], $in{'group'})) {
22                 $group = $g;
23                 last;
24                 }
25         }
26
27 # Go to the group or show an error
28 if ($group) {
29         ($gidx, $uidx, $sidx) = &find_parents($group);
30         &redirect("edit_group.cgi?idx=$group->{'index'}".
31                   (defined($gidx) ? "&gidx=$gidx" : "").
32                   (defined($uidx) ? "&uidx=$uidx" : "").
33                   (defined($sidx) ? "&sidx=$sidx" : ""));
34         }
35 else {
36         &error(&text('lookup_egroup', $in{'group'}));
37         }
38