3 # Edit or create a webmin group
5 require './acl-lib.pl';
7 $access{'groups'} || &error($text{'gedit_ecannot'});
9 # Editing an existing group
10 &ui_print_header(undef, $text{'gedit_title'}, "");
11 $g = &get_group($in{'group'});
12 $g || &error($text{'gedit_egone'});
16 # Creating a new group
17 &ui_print_header(undef, $text{'gedit_title2'}, "");
20 # Copy modules from clone
21 $g = &get_group($in{'clone'});
23 $group{'modules'} = $g->{'modules'};
28 print &ui_form_start("save_group.cgi", "post");
29 print &ui_hidden("old", $in{'group'});
31 print &ui_hidden("clone", $in{'clone'});
33 print &ui_hidden_table_start($text{'gedit_rights'}, "width=100%", 2, "rights",
37 print &ui_table_row($text{'gedit_group'},
38 &ui_textbox("name", $group{'name'}, 30, 0, undef, "autocomplete=off"));
40 # Show group description
41 print &ui_table_row($text{'gedit_desc'},
42 &ui_textbox("desc", $group{'desc'}, 60));
44 # Find and show the parent group
45 @glist = grep { $_->{'name'} ne $group{'name'} } &list_groups();
46 @mcan = $access{'gassign'} eq '*' ?
47 ( ( map { $_->{'name'} } @glist ), '_none' ) :
48 split(/\s+/, $access{'gassign'});
49 map { $gcan{$_}++ } @mcan;
50 if (@glist && %gcan) {
53 push(@opts, [ undef, "<$text{'edit_none'}>" ]);
57 if (&indexof('@'.$group{'name'}, @{$g->{'members'}}) >= 0) {
60 next if (!$gcan{$g->{'name'}} && $memg ne $g->{'name'});
61 push(@opts, [ $g->{'name'} ]);
63 print &ui_table_row($text{'edit_group'},
64 &ui_select("group", $memg, \@opts));
68 # Show all current members
69 @grid = map { $_ =~ /^\@(.*)$/ ? "<a href='edit_group.cgi?group=$1'><i>$1</i></a>" : "<a href='edit_user.cgi?user=$_'>$_</a>" }
72 print &ui_table_row($text{'gedit_members'},
73 &ui_links_row(\@grid));
79 print &ui_table_row($text{'edit_proto'},
80 $text{'edit_proto_'.$group{'proto'}});
83 print &ui_hidden_table_end("basic");
85 # Start of modules section
86 print &ui_hidden_table_start(@groups ? $text{'edit_modsg'} : $text{'edit_mods'},
87 "width=100%", 2, "mods");
89 # Show available modules, under categories
90 @mlist = &list_module_infos();
91 map { $has{$_}++ } @{$group{'modules'}};
92 @links = ( &select_all_link("mod", 0, $text{'edit_selall'}),
93 &select_invert_link("mod", 0, $text{'edit_invert'}) );
94 @cats = &unique(map { $_->{'category'} } @mlist);
95 &read_file("$config_directory/webmin.catnames", \%catnames);
97 foreach $c (sort { $b cmp $a } @cats) {
98 @cmlist = grep { $_->{'category'} eq $c } @mlist;
99 $grids .= "<b>".($catnames{$c} || $text{'category_'.$c})."</b><br>\n";
102 foreach $m (@cmlist) {
103 local $md = $m->{'dir'};
105 if ($access{'acl'} && $in{'group'}) {
106 # Show link for editing ACL
107 $label = sprintf "<a href='edit_acl.cgi?".
108 "mod=%s&%s=%s'>%s</a>\n",
109 &urlize($m->{'dir'}),
110 "group", &urlize($in{'group'}),
114 $label = $m->{'desc'};
116 push(@grid, &ui_checkbox("mod", $md, $label,$has{$md}));
118 $grids .= &ui_grid_table(\@grid, 2, 100, [ "width=50%", "width=50%" ]);
120 print &ui_table_row(undef, &ui_links_row(\@links).
122 &ui_links_row(\@links), 2);
123 print &ui_hidden_table_end("mods");
125 # Add global ACL section
126 if ($access{'acl'} && $in{'group'}) {
127 print &ui_hidden_table_start($text{'edit_global'}, "width=100%", 2,
128 "global", 0, [ "width=30%" ]);
129 %uaccess = &get_group_module_acl($in{'group'}, "");
130 print &ui_hidden("acl_security_form", 1);
131 &foreign_require("", "acl_security.pl");
132 &foreign_call("", "acl_security_form", \%uaccess);
133 print &ui_hidden_table_end("global");
136 # Generate form end buttons
138 push(@buts, [ undef, $in{'group'} ? $text{'save'} : $text{'create'} ]);
140 push(@buts, [ "but_clone", $text{'edit_clone'} ]);
141 push(@buts, [ "but_delete", $text{'delete'} ]);
143 print &ui_form_end(\@buts);
145 &ui_print_footer("", $text{'index_return'});