Handle hostnames with upper-case letters
[webmin.git] / cluster-useradmin / edit_host.cgi
1 #!/usr/local/bin/perl
2 # edit_host.cgi
3 # Display users and groups on some host
4
5 require './cluster-useradmin-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'host_title'}, "");
8
9 @hosts = &list_useradmin_hosts();
10 ($host) = grep { $_->{'id'} == $in{'id'} } @hosts;
11 $server = &foreign_call("servers", "get_server", $in{'id'});
12 @packages = @{$host->{'packages'}};
13
14 # Show host details
15 print "<table border width=100%>\n";
16 print "<tr $tb> <td><b>$text{'host_header'}</b></td> </tr>\n";
17 print "<tr $cb> <td><table width=100%>\n";
18
19 print "<tr> <td><b>$text{'host_name'}</b></td>\n";
20 if ($server->{'id'}) {
21         printf "<td><a href='/servers/link.cgi/%s/'>%s</a></td>\n",
22                 $server->{'id'}, $server->{'desc'} ? "$server->{'desc'} ($server->{'host'}:$server->{'port'})" : "$server->{'host'}:$server->{'port'}";
23         }
24 else {
25         print "<td><a href=/>$text{'this_server'}</a></td>\n";
26         }
27
28 if ($server->{'id'}) {
29         print "<td><b>$text{'host_type'}</b></td> <td>\n";
30         foreach $t (@servers::server_types) {
31                 print $t->[1] if ($t->[0] eq $server->{'type'});
32                 }
33         print "</td>\n";
34         }
35 print "</tr>\n";
36
37 print "<tr> <td><b>$text{'host_users'}</b></td>\n";
38 printf "<td>%d</td>\n", scalar(@{$host->{'users'}});
39
40 print "<td><b>$text{'host_groups'}</b></td>\n";
41 printf "<td>%d</td> </tr>\n", scalar(@{$host->{'groups'}});
42
43 print "</table></td></tr></table>\n";
44
45 # Show delete and refresh buttons
46 print "<table width=100%><tr>\n";
47 print "<form action=delete_host.cgi>\n";
48 print "<input type=hidden name=id value=$in{'id'}>\n";
49 print "<td><input type=submit value='$text{'host_delete'}'></td>\n";
50 print "</form>\n";
51
52 print "<form action=refresh.cgi>\n";
53 print "<input type=hidden name=id value=$in{'id'}>\n";
54 print "<td align=right><input type=submit value='$text{'host_refresh'}'></td>\n";
55 print "</form>\n";
56 print "</tr></table>\n";
57
58 # Show users and groups
59 print &ui_hr();
60 print &ui_subheading($text{'host_ulist'});
61 print "<table width=100% border>\n";
62 print "<tr $tb> <td><b>$text{'index_users'}</b></td> </tr>\n";
63 print "<tr $cb> <td><table width=100%>\n";
64 foreach $u (@{$host->{'users'}}) {
65         if ($i%4 == 0) { print "<tr>\n"; }
66         print "<td><a href=\"edit_user.cgi?user=$u->{'user'}&",
67               "host=$server->{'id'}\">$u->{'user'}</a></td>\n";
68         if ($i%4 == 3) { print "</tr>\n"; }
69         $i++;
70         }
71 print "</table></td> </tr></table>\n";
72
73 print &ui_subheading($text{'host_glist'});
74 print "<table width=100% border>\n";
75 print "<tr $tb> <td><b>$text{'index_groups'}</b></td> </tr>\n";
76 print "<tr $cb> <td><table width=100%>\n";
77 foreach $g (@{$host->{'groups'}}) {
78         if ($j%4 == 0) { print "<tr>\n"; }
79         print "<td><a href=\"edit_group.cgi?group=$g->{'group'}&",
80               "host=$server->{'id'}\">$g->{'group'}</a></td>\n";
81         if ($j%4 == 3) { print "</tr>\n"; }
82         $j++;
83         }
84 print "</table></td> </tr></table>\n";
85
86 &ui_print_footer("", $text{'index_return'});
87