#!/usr/local/bin/perl # edit_group.cgi # Display an existing Webmin group for editing require './cluster-webmin-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'group_title2'}, ""); @hosts = &list_webmin_hosts(); @mods = &all_modules(\@hosts); @wgroups = &all_groups(\@hosts); @servers = &list_servers(); if ($in{'host'} ne '') { ($host) = grep { $_->{'id'} == $in{'host'} } @hosts; ($edgrp) = grep { $_->{'name'} eq $in{'group'} } @{$host->{'groups'}}; } else { foreach $h (@hosts) { local ($g) =grep { $_->{'name'} eq $in{'group'} } @{$h->{'groups'}}; if ($g) { $host = $h; $edgrp = $g; last; } } } ($serv) = grep { $_->{'id'} == $host->{'id'} } @servers; foreach $h (@hosts) { local ($g) = grep { $_->{'name'} eq $in{'group'} } @{$h->{'groups'}}; if ($g) { push(@got, grep { $_->{'id'} == $h->{'id'} } @servers); } } print "
\n"; print "\n"; print "{'id'}\">\n"; print "\n"; print "\n"; print "
",&text('group_header2', &server_name($serv)), "
\n"; print "\n"; printf "\n", $edgrp->{'name'}; @gm = @{$edgrp->{'members'}}; print "\n"; print "\n"; foreach $g (@{$host->{'groups'}}) { if (&indexof($edgrp->{'name'}, @{$g->{'members'}}) >= 0) { $group = $g; last; } } print "\n"; $mp = int((scalar(@mods)+2)/3); @umods = $group ? @{$edgrp->{'ownmods'}} : @{$edgrp->{'modules'}}; map { $umods{$_}++ } @umods; print "\n"; print "
$text{'group_name'}
$text{'group_mems'}",@gm ? join(" ", @gm) : $text{'group_nomems'},"
$text{'group_group'} \n"; printf " %s (%s)\n", $text{'user_leave'}, $group ? $group->{'name'} : $text{'user_nogroup2'}; printf " %s\n", $text{'user_set'}; print "
$text{'group_mods'}
", "$text{'group_groupmods'}
\n"; print " ", &text('user_mleave', scalar(@umods)),"
\n"; print " $text{'user_modsel'}\n"; print " $text{'user_modadd'}\n"; print " $text{'user_moddel'}\n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "
\n"; print "$text{'user_sall'} \n"; print "$text{'user_snone'} \n"; print "$text{'user_sinvert'}
\n"; print "
\n"; print "\n"; print "\n"; %mdesc = map { $_->{'dir'}, $_->{'desc'} } @mods; foreach $h (@hosts) { local %ingroup; foreach $g (@{$h->{'groups'}}) { map { $ingroup{$_}++ } @{$g->{'members'}}; } local ($g) = grep { $_->{'name'} eq $in{'group'} } @{$h->{'groups'}}; next if (!$g); local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers; local $d = &server_name($s); $sel .= "\n"; } print "\n"; print "\n"; print "\n"; print "
\n"; print "\n"; print "\n"; print "
\n"; # Show hosts with the group print &ui_hr(); print &ui_subheading($text{'group_hosts'}); @icons = map { "/servers/images/$_->{'type'}.gif" } @got; @links = map { "edit_host.cgi?id=$_->{'id'}" } @got; @titles = map { &server_name($_) } @got; &icons_table(\@links, \@titles, \@icons); &ui_print_footer("", $text{'index_return'});