Handle hostnames with upper-case letters
[webmin.git] / cluster-useradmin / edit_group.cgi
1 #!/usr/local/bin/perl
2 # edit_group.cgi
3 # Display a form for editing an existing group
4
5 require './cluster-useradmin-lib.pl';
6 &ReadParse();
7
8 @hosts = &list_useradmin_hosts();
9 @servers = &list_servers();
10 if ($in{'host'} ne '') {
11         ($host) = grep { $_->{'id'} == $in{'host'} } @hosts;
12         local ($g) = grep { $_->{'group'} eq $in{'group'} } @{$host->{'groups'}};
13         %ginfo = %$g;
14         }
15 else {
16         foreach $h (@hosts) {
17                 local ($g) = grep { $_->{'group'} eq $in{'group'} }
18                                   @{$h->{'groups'}};
19                 if ($g) {
20                         $host = $h;
21                         %ginfo = %$g;
22                         last;
23                         }
24                 }
25         }
26 ($serv) = grep { $_->{'id'} == $host->{'id'} } @servers;
27 $desc = &text('gedit_host', $serv->{'desc'} ?
28                 $serv->{'desc'} : $serv->{'host'});
29 &ui_print_header($desc, $text{'gedit_title'}, "");
30
31 print "<form action=\"save_group.cgi\" method=post>\n";
32 print "<input type=hidden name=group value=\"$in{'group'}\">\n";
33 print "<table border width=100%>\n";
34 print "<tr $tb> <td><b>$text{'gedit_details'}</b></td> </tr>\n";
35 print "<tr $cb> <td><table width=100%>\n";
36
37 print "<tr> <td valign=top><b>$text{'gedit_group'}</b></td>\n";
38 print "<td valign=top><font size=+1><i>$ginfo{'group'}</i></font></td>\n";
39
40 print "<td valign=top><b>$text{'gedit_gid'}</b></td>\n";
41 printf "<td><input type=radio name=gid_def value=1 checked> %s (%s)\n",
42         $text{'uedit_leave'}, $ginfo{'gid'};
43 printf "<input type=radio name=gid_def value=0> %s\n",
44         $text{'gedit_set'};
45 print "<input name=gid size=10></td> </tr>\n";
46
47 print "<tr> <td valign=top><b>$text{'pass'}</b></td>\n";
48 printf "<td><input type=radio name=passmode value=-1 checked> %s (%s)\n",
49         $text{'uedit_leave'}, $ginfo{'pass'} ? $ginfo{'pass'}
50                                              : $text{'uedit_none'};
51 print "<input type=radio name=passmode value=0> $text{'none2'}<br>\n";
52 print "<input type=radio name=passmode value=1> $text{'encrypted'}\n";
53 print "<input name=encpass size=13><br>\n";
54 print "<input type=radio name=passmode value=2> $text{'clear'}\n";
55 print "<input name=pass size=15></td>\n";
56
57 print "<td valign=top><b>$text{'gedit_members'}</b></td> <td>\n";
58 printf "<input type=radio name=members_def value=0 checked> %s (%s)<br>\n",
59         $text{'uedit_leave'}, $ginfo{'members'} ? $ginfo{'members'}
60                                                 : $text{'uedit_none'};
61 printf "<input type=radio name=members_def value=1> %s\n", $text{'gedit_add'};
62 print "<input name=membersadd size=20> ",
63         &user_chooser_button("membersadd", 1),"<br>\n";
64 printf "<input type=radio name=members_def value=2> %s\n", $text{'gedit_del'};
65 print "<input name=membersdel size=20> ",
66         &user_chooser_button("membersdel", 1),"</td> </tr>\n";
67
68 print "</table></td> </tr></table><p>\n";
69
70 print "<table border width=100%>\n";
71 print "<tr $tb> <td><b>$text{'onsave'}</b></td> </tr>\n";
72 print "<tr $cb> <td><table>\n";
73 print "<tr> <td><b>$text{'chgid'}</b></td>\n";
74 print "<td><input type=radio name=chgid value=0 checked> $text{'no'}</td>\n";
75 print "<td><input type=radio name=chgid value=1> $text{'gedit_homedirs'}</td>\n";
76 print "<td><input type=radio name=chgid value=2> $text{'gedit_allfiles'}</td> </tr>\n";
77
78 print "<tr> <td><b>$text{'uedit_servs'}</b></td>\n";
79 print "<td><input type=radio name=servs value=1> $text{'uedit_mall'}</td>\n";
80 print "<td><input type=radio name=servs value=0 checked> $text{'uedit_mthis'}</td> </tr>\n";
81
82 print "<tr> <td><b>$text{'gedit_mothers'}</b></td>\n";
83 print "<td><input type=radio name=others value=1 checked> $text{'yes'}</td>\n";
84 print "<td><input type=radio name=others value=0> $text{'no'}</td> </tr>\n";
85
86 print "</table></td> </tr></table><p>\n";
87
88 print "<table width=100%>\n";
89 print "<tr> <td><input type=submit value=\"$text{'save'}\"></td>\n";
90
91 # Find the servers this group is on
92 foreach $h (@hosts) {
93         local ($og) = grep { $_->{'group'} eq $in{'group'} } @{$h->{'groups'}};
94         if ($og) {
95                 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
96                 push(@icons, "/servers/images/$s->{'type'}.gif");
97                 push(@links, "edit_host.cgi?id=$h->{'id'}");
98                 push(@titles, $s->{'desc'} ? $s->{'desc'} : $s->{'host'});
99                 }
100         }
101 if (@icons < @hosts) {
102         # Offer to create on all servers
103         print "</form><form action=\"sync.cgi\">\n";
104         print "<input type=hidden name=server value=-1>\n";
105         print "<input type=hidden name=users_mode value=0>\n";
106         print "<input type=hidden name=groups_mode value=2>\n";
107         print "<input type=hidden name=gsel value='$ginfo{'group'}'>\n";
108         print "<td align=middle><input type=submit ",
109               "value=\"$text{'uedit_sync'}\"></td>\n";
110         }
111
112 print "</form><form action=\"delete_group.cgi\">\n";
113 print "<input type=hidden name=group value=\"$ginfo{'group'}\">\n";
114 print "<td align=right><input type=submit value=\"$text{'delete'}\"></td> </tr>\n";
115 print "</form></table><p>\n";
116
117 print &ui_hr();
118 print &ui_subheading($text{'uedit_hosts'});
119 &icons_table(\@links, \@titles, \@icons);
120
121 &ui_print_footer("", $text{'index_return'});
122