1#!/usr/local/bin/perl 2# edit_group.cgi 3# Display a form for editing an existing group 4 5require './cluster-useradmin-lib.pl'; 6&ReadParse(); 7 8@hosts = &list_useradmin_hosts(); 9@servers = &list_servers(); 10if ($in{'host'} ne '') { 11 ($host) = grep { $_->{'id'} == $in{'host'} } @hosts; 12 local ($g) = grep { $_->{'group'} eq $in{'group'} } @{$host->{'groups'}}; 13 %ginfo = %$g; 14 } 15else { 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 31print "<form action=\"save_group.cgi\" method=post>\n"; 32print "<input type=hidden name=group value=\"$in{'group'}\">\n"; 33print "<table border width=100%>\n"; 34print "<tr $tb> <td><b>$text{'gedit_details'}</b></td> </tr>\n"; 35print "<tr $cb> <td><table width=100%>\n"; 36 37print "<tr> <td valign=top><b>$text{'gedit_group'}</b></td>\n"; 38print "<td valign=top><font size=3><i>$ginfo{'group'}</i></font></td>\n"; 39 40print "<td valign=top><b>$text{'gedit_gid'}</b></td>\n"; 41printf "<td><input type=radio name=gid_def value=1 checked> %s (%s)\n", 42 $text{'uedit_leave'}, $ginfo{'gid'}; 43printf "<input type=radio name=gid_def value=0> %s\n", 44 $text{'gedit_set'}; 45print "<input name=gid size=10></td> </tr>\n"; 46 47print "<tr> <td valign=top><b>$text{'pass'}</b></td>\n"; 48printf "<td><input type=radio name=passmode value=-1 checked> %s (%s)\n", 49 $text{'uedit_leave'}, $ginfo{'pass'} ? $ginfo{'pass'} 50 : $text{'uedit_none'}; 51print "<input type=radio name=passmode value=0> $text{'none2'}<br>\n"; 52print "<input type=radio name=passmode value=1> $text{'encrypted'}\n"; 53print "<input name=encpass size=13><br>\n"; 54print "<input type=radio name=passmode value=2> $text{'clear'}\n"; 55print "<input name=pass size=15></td>\n"; 56 57print "<td valign=top><b>$text{'gedit_members'}</b></td> <td>\n"; 58printf "<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'}; 61printf "<input type=radio name=members_def value=1> %s\n", $text{'gedit_add'}; 62print "<input name=membersadd size=20> ", 63 &user_chooser_button("membersadd", 1),"<br>\n"; 64printf "<input type=radio name=members_def value=2> %s\n", $text{'gedit_del'}; 65print "<input name=membersdel size=20> ", 66 &user_chooser_button("membersdel", 1),"</td> </tr>\n"; 67 68print "</table></td> </tr></table><p>\n"; 69 70print "<table border width=100%>\n"; 71print "<tr $tb> <td><b>$text{'onsave'}</b></td> </tr>\n"; 72print "<tr $cb> <td><table>\n"; 73print "<tr> <td><b>$text{'chgid'}</b></td>\n"; 74print "<td><input type=radio name=chgid value=0 checked> $text{'no'}</td>\n"; 75print "<td><input type=radio name=chgid value=1> $text{'gedit_homedirs'}</td>\n"; 76print "<td><input type=radio name=chgid value=2> $text{'gedit_allfiles'}</td> </tr>\n"; 77 78print "<tr> <td><b>$text{'uedit_servs'}</b></td>\n"; 79print "<td><input type=radio name=servs value=1> $text{'uedit_mall'}</td>\n"; 80print "<td colspan=2><input type=radio name=servs value=0 checked> $text{'uedit_mthis'}</td> </tr>\n"; 81 82print "<tr> <td><b>$text{'gedit_mothers'}</b></td>\n"; 83print "<td><input type=radio name=others value=1 checked> $text{'yes'}</td>\n"; 84print "<td colspan=2><input type=radio name=others value=0> $text{'no'}</td> </tr>\n"; 85 86print "</table></td> </tr></table><p>\n"; 87 88print "<table width=100%>\n"; 89print "<tr> <td><input type=submit value=\"$text{'save'}\"></td>\n"; 90 91# Find the servers this group is on 92foreach $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, $gconfig{'webprefix'} ? 97 ($gconfig{'webprefix'}."/servers/images/".$s->{'type'}.".gif") : 98 ("../servers/images/".$s->{'type'}.".gif")); 99 push(@links, "edit_host.cgi?id=$h->{'id'}"); 100 push(@titles, $s->{'desc'} ? $s->{'desc'} : $s->{'host'}); 101 } 102 } 103if (@icons < @hosts) { 104 # Offer to create on all servers 105 print "</form><form action=\"sync.cgi\">\n"; 106 print "<input type=hidden name=server value=-1>\n"; 107 print "<input type=hidden name=users_mode value=0>\n"; 108 print "<input type=hidden name=groups_mode value=2>\n"; 109 print "<input type=hidden name=gsel value='$ginfo{'group'}'>\n"; 110 print "<td align=middle><input type=submit ", 111 "value=\"$text{'uedit_sync'}\"></td>\n"; 112 } 113 114print "</tr></table></form><p><form action=\"delete_group.cgi\">\n"; 115print "<input type=hidden name=group value=\"$ginfo{'group'}\">\n"; 116print "<input type=submit value=\"$text{'delete'}\">\n"; 117print "</form><p>\n"; 118 119print &ui_hr(); 120print &ui_subheading($text{'uedit_hosts'}); 121if ($config{'table_mode'}) { 122 # Show as table 123 print &ui_columns_start([ $text{'index_thost'}, 124 $text{'index_tdesc'}, 125 $text{'index_ttype'} ]); 126 foreach $h (@hosts) { 127 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; 128 next if (!$s); 129 local ($type) = grep { $_->[0] eq $s->{'type'} } 130 @servers::server_types; 131 local ($link) = $config{'conf_host_links'} ? 132 &ui_link("edit_host.cgi?id=$h->{'id'}",($s->{'host'} || &get_system_hostname())) : 133 ($s->{'host'} || &get_system_hostname()); 134 print &ui_columns_row([ 135 $link, 136 $s->{'desc'}, 137 $type->[1], 138 ]); 139 } 140 print &ui_columns_end(); 141 } 142else { 143 # Show as icons 144 &icons_table(\@links, \@titles, \@icons); 145 print "<br>"; 146 } 147 148&ui_print_footer("", $text{'index_return'}); 149 150