Handle hostnames with upper-case letters
[webmin.git] / bacula-backup / list_groups.cgi
1 #!/usr/local/bin/perl
2 # Show all groups that are actually templates for OC-Host node groups
3
4 require './bacula-backup-lib.pl';
5 &ui_print_header(undef, $text{'groups_title'}, "", "groups");
6
7 $conf = &get_director_config();
8 @groups = &find("Client", $conf);
9 @groups = grep { $name = &find_value("Name", $_->{'members'});
10                  $name =~ /^ocgroup_/ } @groups;
11 &sort_by_name(\@groups);
12 if (@groups) {
13         print &ui_form_start("delete_groups.cgi", "post");
14         @links = ( &select_all_link("d"),
15                    &select_invert_link("d") );
16         print &ui_links_row(\@links);
17         @tds = ( "width=5", "width=30%", "width=40%", "width=30%" );
18         print &ui_columns_start([ "", $text{'groups_name'},
19                                   $text{'groups_port'},
20                                   $text{'groups_catalog'} ], "100%", 0, \@tds);
21         foreach $f (@groups) {
22                 $name = &find_value("Name", $f->{'members'});
23                 $name =~ s/^ocgroup_//g;
24                 $port = &find_value("FDPort", $f->{'members'});
25                 $cat = &find_value("Catalog", $f->{'members'});
26                 $done{$name}++;
27                 print &ui_checked_columns_row([
28                         "<a href='edit_group.cgi?name=".&urlize($name)."'>".
29                         $name."</a>",
30                         $port,
31                         $cat,
32                         ], \@tds, "d", $name);
33                 }
34         print &ui_columns_end();
35         print &ui_links_row(\@links);
36         print &ui_form_end([ [ "delete", $text{'groups_delete'} ] ]);
37         }
38 else {
39         print "<b>$text{'groups_none'}</b><p>\n";
40         }
41
42 @ng = &list_node_groups();
43 @canng = grep { !$done{$_->{'name'}} } @ng;
44 if (@canng) {
45         # Show adding form
46         print &ui_form_start("edit_group.cgi");
47         print "<b>$text{'groups_add'}</b>\n";
48         print &ui_select("new", undef,
49                 [ map { [ $_->{'name'}, &text('groups_info', $_->{'name'}, scalar(@{$_->{'members'}})) ] } @canng ]);
50         print &ui_submit($text{'groups_ok'});
51         print &ui_form_end();
52         }
53 elsif (@ng) {
54         print "<b>$text{'groups_already'}</b><p>\n";
55         }
56 else {
57         print "<b>$text{'groups_noadd'}</b><p>\n";
58         }
59
60 &ui_print_footer("", $text{'index_return'});
61