3 # Display an existing Webmin group for editing
5 require './cluster-webmin-lib.pl';
7 &ui_print_header(undef, $text{'group_title2'}, "");
9 @hosts = &list_webmin_hosts();
10 @mods = &all_modules(\@hosts);
11 @wgroups = &all_groups(\@hosts);
12 @servers = &list_servers();
13 if ($in{'host'} ne '') {
14 ($host) = grep { $_->{'id'} == $in{'host'} } @hosts;
15 ($edgrp) = grep { $_->{'name'} eq $in{'group'} } @{$host->{'groups'}};
19 local ($g) =grep { $_->{'name'} eq $in{'group'} } @{$h->{'groups'}};
27 ($serv) = grep { $_->{'id'} == $host->{'id'} } @servers;
29 local ($g) = grep { $_->{'name'} eq $in{'group'} } @{$h->{'groups'}};
31 push(@got, grep { $_->{'id'} == $h->{'id'} } @servers);
35 print "<form action=save_group.cgi method=post>\n";
36 print "<input type=hidden name=old value=\"$in{'group'}\">\n";
37 print "<input type=hidden name=host value=\"$host->{'id'}\">\n";
38 print "<table border width=100%>\n";
39 print "<tr $tb> <td><b>",&text('group_header2', &server_name($serv)),
41 print "<tr $cb> <td><table width=100%>\n";
43 print "<tr> <td><b>$text{'group_name'}</b></td>\n";
44 printf "<td><input name=name size=15 value='%s'></td> </tr>\n",
47 @gm = @{$edgrp->{'members'}};
48 print "<tr> <td><b>$text{'group_mems'}</b></td>\n";
49 print "<td>",@gm ? join(" ", @gm) : $text{'group_nomems'},"</td> </tr>\n";
51 foreach $g (@{$host->{'groups'}}) {
52 if (&indexof($edgrp->{'name'}, @{$g->{'members'}}) >= 0) {
57 print "<tr> <td><b>$text{'group_group'}</b></td> <td>\n";
58 printf "<input type=radio name=group_def value=1 checked> %s (%s)\n",
59 $text{'user_leave'}, $group ? $group->{'name'} : $text{'user_nogroup2'};
60 printf "<input type=radio name=group_def value=0> %s\n",
62 print "<select name=group>\n";
63 print "<option selected value=''>$text{'user_nogroup'}\n";
64 foreach $g (@wgroups) {
65 print "<option>$g->{'name'}\n";
67 print "</select></td> </tr>\n";
69 $mp = int((scalar(@mods)+2)/3);
70 @umods = $group ? @{$edgrp->{'ownmods'}} : @{$edgrp->{'modules'}};
71 map { $umods{$_}++ } @umods;
72 print "<tr> <td valign=top><b>$text{'group_mods'}</b><br>",
73 "$text{'group_groupmods'}</td> <td nowrap>\n";
74 print "<input type=radio name=mods_def value=1 checked> ",
75 &text('user_mleave', scalar(@umods)),"<br>\n";
76 print "<input type=radio name=mods_def value=2> $text{'user_modsel'}\n";
77 print "<input type=radio name=mods_def value=3> $text{'user_modadd'}\n";
78 print "<input type=radio name=mods_def value=0> $text{'user_moddel'}\n";
80 print "<select name=mods1 size=$mp multiple>\n";
81 for($i=0; $i<$mp; $i++) {
82 printf "<option value=%s %s>%s\n",
83 $mods[$i]->{'dir'}, $umods{$mods[$i]->{'dir'}} ? "selected" : "",
87 print "<select name=mods2 size=$mp multiple>\n";
88 for($i=$mp; $i<$mp*2; $i++) {
89 printf "<option value=%s %s>%s\n",
90 $mods[$i]->{'dir'}, $umods{$mods[$i]->{'dir'}} ? "selected" : "",
94 print "<select name=mods3 size=$mp multiple>\n";
95 for($i=$mp*2; $i<@mods; $i++) {
96 printf "<option value=%s %s>%s\n",
97 $mods[$i]->{'dir'}, $umods{$mods[$i]->{'dir'}} ? "selected" : "",
103 print "<a href='' onClick='for(i=0; i<document.forms[0].mods1.options.length; i++) { document.forms[0].mods1.options[i].selected = true; } for(i=0; i<document.forms[0].mods2.options.length; i++) { document.forms[0].mods2.options[i].selected = true; } for(i=0; i<document.forms[0].mods3.options.length; i++) { document.forms[0].mods3.options[i].selected = true; } return false'>$text{'user_sall'}</a> \n";
104 print "<a href='' onClick='for(i=0; i<document.forms[0].mods1.options.length; i++) { document.forms[0].mods1.options[i].selected = false; } for(i=0; i<document.forms[0].mods2.options.length; i++) { document.forms[0].mods2.options[i].selected = false; } for(i=0; i<document.forms[0].mods3.options.length; i++) { document.forms[0].mods3.options[i].selected = false; } return false'>$text{'user_snone'}</a> \n";
105 print "<a href='' onClick='for(i=0; i<document.forms[0].mods1.options.length; i++) { document.forms[0].mods1.options[i].selected = !document.forms[0].mods1.options[i].selected; } for(i=0; i<document.forms[0].mods2.options.length; i++) { document.forms[0].mods2.options[i].selected = !document.forms[0].mods2.options[i].selected; } for(i=0; i<document.forms[0].mods3.options.length; i++) { document.forms[0].mods3.options[i].selected = !document.forms[0].mods3.options[i].selected; } return false'>$text{'user_sinvert'}</a><br>\n";
107 print "</td> </tr>\n";
109 print "</table></td></tr></table>\n";
110 print "<table width=100%><tr>\n";
111 print "<td><input type=submit value='$text{'save'}'></td></form>\n";
113 %mdesc = map { $_->{'dir'}, $_->{'desc'} } @mods;
114 foreach $h (@hosts) {
116 foreach $g (@{$h->{'groups'}}) {
117 map { $ingroup{$_}++ } @{$g->{'members'}};
119 local ($g) = grep { $_->{'name'} eq $in{'group'} } @{$h->{'groups'}};
121 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
122 local $d = &server_name($s);
123 $sel .= "<option value='$h->{'id'},'>".&text('user_aclhg', $d)."\n"
124 if (!$ingroup{$in{'group'}});
125 foreach $m (@{$h->{'modules'}}) {
126 local @gm = $ingroup{$in{'group'}} ? @{$g->{'ownmods'}}
127 : @{$g->{'modules'}};
128 next if (&indexof($m->{'dir'}, @gm) < 0);
129 $sel .= "<option value='$h->{'id'},$m->{'dir'}'>".
130 &text('user_aclh', $m->{'desc'}, $d)."\n";
134 print "<form action=edit_acl.cgi><td align=center>\n";
135 print "<input type=hidden name=group value='$in{'group'}'>\n";
136 print "<input type=submit value='$text{'user_acl'}'>\n";
137 print "<select name=modhost>\n";
139 print "</select></td></form>\n";
142 print "<form action=delete_group.cgi>\n";
143 print "<input type=hidden name=group value=\"$in{'group'}\">\n";
144 print "<td align=right><input type=submit value='$text{'delete'}'></td></form>\n";
145 print "</tr></table>\n";
147 # Show hosts with the group
149 print &ui_subheading($text{'group_hosts'});
150 @icons = map { "/servers/images/$_->{'type'}.gif" } @got;
151 @links = map { "edit_host.cgi?id=$_->{'id'}" } @got;
152 @titles = map { &server_name($_) } @got;
153 &icons_table(\@links, \@titles, \@icons);
155 &ui_print_footer("", $text{'index_return'});