Handle hostnames with upper-case letters
[webmin.git] / smf / property_group_editor.cgi
1 #!/usr/local/bin/perl
2 # index.cgi
3 # Display a list of services, built from svcs command
4
5 require './smf-lib.pl';
6 &ReadParse();
7 &ui_print_header(undef, $text{'property_group_editor_title'}, "");
8
9 # get instance fmri
10 if (defined($in{'fmri'})) {
11         $fmri = $in{'fmri'};
12         # remove quotes...
13         $fmri =~ /\'([^\']*)\'/;
14         $fmri = $1;
15         if ($fmri =~ /(svc:\/[^:]*):(.*)/) {
16                 $svc = $1;
17                 $inst = $2;
18         } else {
19                 &error("Invalid fmri: instance must be specified!");
20                 }
21 } else {
22         &error("No fmri supplied to property group editor!");
23         }
24
25 # deal with add/deletion of property groups first. this way
26 # pgroup list will show changes...
27 if ((defined($in{'add'})) &&
28     (defined($in{'addname'})) &&
29     (defined($in{'addtype'})) &&
30     (defined($in{'addsinst'}))) {
31         $addname = "$in{'addname'}";
32         $addtype = "$in{'addtype'}";
33         $addsinst = "$in{'addsinst'}";
34         if (($addname =~ /.+/) && ($addtype =~ /.+/) && ($addsinst =~ /.+/)) {
35                 &svc_addpg("$svc", "$addsinst", "$addname", "$addtype");
36                 }
37         }
38 if (defined($in{'remove'})) {
39         # get remove pg list
40         @remove_pgs = split(/\0/, $in{'applyto'});
41         foreach $rpg (@remove_pgs) { 
42                 # split into service or instance level/name
43                 if ($rpg =~ /([^\/]*)\/(.*)/) {
44                         $pgsinst = $1;
45                         $pgname = $2;
46                         &svc_delpg("$svc", "$pgsinst", "$pgname");
47                         }
48                 }
49         }
50
51 @pgroup_listing_svc = &svc_listpg($svc, "service");
52 @pgroup_listing_inst = &svc_listpg($svc, $inst);
53 @pgroup_listing = (@pgroup_listing_svc, @pgroup_listing_inst);
54
55 print "<h2>";
56 &text_and_whats_this("property_group_editor_detail");
57 print " : $fmri </h2>\n";
58
59 print "<form method=\"POST\" action=\"property_group_editor.cgi?fmri='$fmri'\">\n";
60
61 # add pg table first...
62 print "<p><h3>$text{'property_group_editor_addpg'}</h3>\n";
63 print "<table><tr>";
64 print "<td><b>$text{'property_group_editor_addsinst'}</b></td>\n";
65 print "<td><b>$text{'property_group_editor_addname'}</b></td>\n";
66 print "<td><b>$text{'property_group_editor_addtype'}</b></td></tr>\n";
67 print "<tr><td>\n";
68 @sinstarray = ("service", "$inst");
69 &print_selection("addsinst", "service", \@sinstarray);
70 print "</td><td>\n";
71 print "<input size=30 name=\"addname\" value=\"\">\n";
72 print "</td><td>\n";
73 print "<input size=30 name=\"addtype\" value=\"\">\n";
74 print "</td></tr>\n";
75 print "<tr><td>&nbsp;</td><td>&nbsp;</td><td>";
76 print "<input type=submit name=\"add\" value=\"$text{'property_group_editor_add'}\">\n";
77 print "</td></tr></table></b>\n";
78
79 print "<table border width=100%>\n";
80 print "<tr><td><table width=100%>\n";
81 print "<tr $cb><td><b>$text{'property_group_editor_apply'}</b>:&nbsp;";
82 print "<input type=submit name=\"remove\" onClick=\"return (confirm(\'$text{'property_group_editor_deleteconfirm'}\'))\" value=\"$text{'property_group_editor_delete'}\">&nbsp;\n";
83 print "</td></tr></table></td></tr>\n";
84 print "<tr><td><table width=100%>\n";
85 print "<tr $cb>\n";
86 print "<td><b>$text{'property_group_editor_select'}</b></td>\n";
87 print "<td><b>$text{'property_group_editor_sinst'}</b></td>\n";
88 print "<td><b>$text{'property_group_editor_pgroup_name'}</b></td>\n";
89 print "<td><b>$text{'property_group_editor_pgroup_type'}</b></td></tr>\n";
90
91 foreach $pg (@pgroup_listing) {
92         print "<tr $cb>";
93         $sinst = $pg->{'sinst'};
94         $name = $pg->{'pgroup_name'};
95         $type = $pg->{'pgroup_type'};
96         print "<td>\n";
97         print "<input type=checkbox name=\"applyto\" value=\"$sinst/$name\">";
98         print "</td><td>\n";
99         print "$sinst</td><td>\n";
100         # dont allow edit of nonpersistent items!
101         if ($type =~ /NONPERSISTENT/) {
102                 print "$name";
103         } else {
104                 $entity = ($sinst eq "service") ? "$svc" : "$fmri";
105                 print
106         "<a href=\"property_editor.cgi?fmri='$fmri'&sinst=$sinst&pgroup=$name\">$name</a>";
107                 }
108         print "</td><td>$type</td>\n";
109         print "</tr>\n";
110 }
111 print "</table></td></tr></table></form>\n";
112
113 &print_cmds_run();
114
115 &ui_print_footer("instance_viewer.cgi?fmri='$fmri'",
116         $text{'property_group_editor_back'});
117