3 # Display details of a module or theme
5 require './cluster-webmin-lib.pl';
7 $type = $in{'tedit'} || !$in{'mod'} ? 'theme' : 'mod';
9 &ui_print_header(undef, $text{"edit_title_$type"}, "");
11 # Find all hosts with the module or theme
12 @hosts = &list_webmin_hosts();
13 @servers = &list_servers();
15 local ($s) = grep { $_->{'id'} == $h->{'id'} } @servers;
16 foreach $m ($type eq 'theme' ? @{$h->{'themes'}}
17 : @{$h->{'modules'}}) {
18 if ($m->{'dir'} eq $name) {
23 if (!$checkon && ($s->{'id'} == $in{'host'} ||
24 !$s->{'id'} && !defined($in{'host'}))) {
32 # Get the details from this host, or the first in the list
37 #&remote_foreign_require($checkon->{'host'}, "software", "software-lib.pl");
38 #@pinfo = &remote_foreign_call($checkon->{'host'}, "software", "package_info",
41 # Show module/theme details
42 print "<table border width=100%>\n";
43 print "<tr $tb> <td><b>",&text("edit_header_$type", &server_name($checkon)),
45 print "<tr $cb> <td><table width=100%>\n";
47 print "<tr> <td><b>$text{'edit_desc'}</b></td>\n";
48 print "<td>",$mod->{'desc'},"</td>\n";
50 print "<td><b>$text{'edit_ver'}</b></td>\n";
51 print "<td>",$mod->{'version'} ? $mod->{'version'}
52 : $text{'edit_nover'},"</td> </tr>\n";
55 # Show details of module
56 foreach $m (@{$checkonh->{'modules'}}) {
57 $modmap{$m->{'dir'}} = $m;
58 foreach $d (split(/\s+/, $m->{'depends'})) {
59 push(@{$ondeps{$d}}, $m);
63 &read_file("$config_directory/webmin.catnames", \%catnames);
64 print "<tr> <td><b>$text{'edit_cat'}</b></td>\n";
65 $c = $mod->{'category'};
66 print "<td>",$catname{$c} ? $catname{$c} :
67 $text{"category_$c"} ? $text{"category_$c"} :
68 $text{"category_"},"</td>\n";
70 print "<td><b>$text{'edit_dir'}</b></td>\n";
71 if ($checkon->{'id'}) {
72 print "<td><tt><a href='/servers/link.cgi/$checkon->{'id'}/",
73 "$mod->{'dir'}/'>$mod->{'dir'}</a></tt></td> </tr>\n";
76 print "<td><tt><a href='/$mod->{'dir'}/'>$mod->{'dir'}</a>",
80 # Show operating systems
81 print "<tr> <td valign=top><b>$text{'edit_os'}</b></td>\n";
82 print "<td colspan=3>\n";
83 $oss = $mod->{'os_support'};
85 print $text{'edit_osall'};
88 open(OSLIST, "$root_directory/os_list.txt");
91 if (/^([^\t]+)\t+([^\t]+)\t+(\S+)\t+(\S+)\t*(.*)$/) {
96 $osname{"*-linux"} = "Linux";
98 local ($os, $ver, $codes);
99 if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) {
100 $os = $1; $ver = $2; $codes = $3; $oss = $4;
102 elsif ($oss =~ /^([^\/\s]+)\/([^\/\s]+)\s*(.*)$/) {
103 $os = $1; $ver = $2; $oss = $3;
105 elsif ($oss =~ /^([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) {
106 $os = $1; $codes = $2; $oss = $3;
108 elsif ($oss =~ /^\{([^\}]*)\}\s*(.*)$/) {
109 $codes = $1; $oss = $2;
111 elsif ($oss =~ /^(\S+)\s*(.*)$/) {
115 print " , \n" if ($doneone++);
116 $osn = $osname{$os} ? $osname{$os} : $os;
117 $osn =~ s/\s/ /g;
119 print "$osn $ver";
125 $codes =~ s/\s/ /g;
127 print " (",&text('edit_codes',
128 "<tt>$codes</tt>"),")";
131 print &text('edit_codes',
137 print "</td> </tr>\n";
139 # Show which modules this module depends upon
140 local @deps = grep { !/^[0-9\.]+$/ } split(/\s+/, $mod->{'depends'});
141 local @pdeps = split(/\s+/, $mod->{'perldepends'});
142 print "<tr> <td valign=top><b>$text{'edit_deps'}</b></td>\n";
143 print "<td valign=top>\n";
144 if (@deps || @pdeps) {
146 local $mm = $modmap{$d};
147 print $mm->{'desc'}," (<tt>$mm->{'dir'}</tt>)<br>\n";
149 foreach $d (@pdeps) {
150 print &text('edit_pdep', "<tt>$d</tt>"),"<br>\n";
154 print "$text{'edit_nodeps'}\n";
158 # Show which other modules depend on this one
159 print "<td valign=top><b>$text{'edit_ondeps'}</b></td>\n";
160 print "<td valign=top>\n";
161 if ($ondeps{$mod->{'dir'}}) {
162 foreach $d (@{$ondeps{$mod->{'dir'}}}) {
163 print $d->{'desc'}," (<tt>$d->{'dir'}</tt>)<br>\n";
167 print "$text{'edit_nodeps'}\n";
169 print "</td> </tr>\n";
172 # Show details of theme
175 print "</table></td></tr></table><p>\n";
177 print "<table width=100%><tr>\n";
179 # Show button to delete module
180 print "<form action=delete_mod.cgi>\n";
181 print "<input type=hidden name=type value=\"$type\">\n";
182 print "<input type=hidden name=mod value=\"$name\">\n";
183 print "<td><input type=submit value='",$text{"edit_uninst_$type"},"'>\n";
184 print "<select name=server>\n";
185 print "<option value=-1>$text{'edit_all'}\n";
187 print "<option value='$s->{'id'}'>",&server_name($s),"\n";
189 print "</select></td></form>\n";
191 if ($type eq 'mod') {
192 # Show button to edit config
193 print "<form action=edit_config.cgi>\n";
194 print "<input type=hidden name=type value=\"$type\">\n";
195 print "<input type=hidden name=mod value=\"$name\">\n";
196 print "<td><input type=submit value='$text{'edit_config'}'>\n";
197 &create_on_input(undef, 1, 0, 0);
198 print "</td></form>\n";
201 if ($type eq 'mod') {
202 # Show user/group ACL selector
203 print "<form action=edit_acl.cgi>\n";
204 print "<input type=hidden name=mod value=\"$name\">\n";
205 print "<input type=hidden name=host value=\"$checkonh->{'id'}\">\n";
206 print "<td align=right><input type=submit value='$text{'edit_acl'}'>\n";
207 print "<select name=whohost>\n";
208 for($i=0; $i<@goth; $i++) {
211 foreach $g (@{$h->{'groups'}}) {
212 map { $ingroup{$_}++ } @{$g->{'members'}};
214 local $d = &server_name($got[$i]);
215 foreach $u (@{$h->{'users'}}) {
216 local @m = $ingroup{$u->{'name'}} ? @{$u->{'ownmods'}}
217 : @{$u->{'modules'}};
218 print "<option value='$h->{'id'},$u->{'name'}'>",
219 &text('edit_uacl', $u->{'name'}, $d),"\n"
220 if (&indexof($name, @m) >= 0);
222 foreach $g (@{$h->{'groups'}}) {
223 local @m = $ingroup{$g->{'name'}} ? @{$g->{'ownmods'}}
224 : @{$g->{'modules'}};
225 print "<option value='$h->{'id'},$g->{'name'}'>",
226 &text('edit_gacl', $g->{'name'}, $d),"\n"
227 if (&indexof($name, @m) >= 0);
230 print "</select></td></form>\n";
233 print "</tr></table>\n";
235 # Show hosts with the module or theme
237 print &ui_subheading($text{'edit_hosts'});
238 @icons = map { "/servers/images/$_->{'type'}.gif" } @got;
239 @links = map { "edit_host.cgi?id=$_->{'id'}" } @got;
240 @titles = map { &server_name($_).
241 ($_->{'module'}->{'version'} ? " ($text{'host_version2'} $_->{'module'}->{'version'})" : "") } @got;
242 &icons_table(\@links, \@titles, \@icons);
245 &ui_print_footer("", $text{'index_return'});