#!/usr/local/bin/perl # property_editor.cgi # Display a list of properties for property group for fmri require './smf-lib.pl'; &ReadParse(); &ui_print_header(undef, $text{'property_editor_title'}, ""); # get instance fmri if (defined($in{'fmri'})) { $fmri = $in{'fmri'}; # remove quotes... $fmri =~ /\'([^\']*)\'/; $fmri = $1; if ($fmri =~ /(svc:\/[^:]*):(.*)/) { $svc = $1; $inst = $2; } else { &error("Invalid fmri: instance must be specified!"); } } else { &error("No fmri supplied to property editor!"); } if (defined($in{'sinst'})) { $sinst = "$in{'sinst'}"; $entity = ($sinst eq "service") ? "$svc" : "$svc:$inst"; } else { &error("Service/Instance level not specified for property editor!"); } if (defined($in{'pgroup'})) { $pgroup = $in{'pgroup'}; } else { &error("No property group supplied to property editor!"); } # deal with add/deletion/update of properties first. this way # prop list will show changes... if ((defined($in{'add'})) && (defined($in{'addname'})) && (defined($in{'addtype'})) && (defined($in{'addvalue'}))) { $addname = "$in{'addname'}"; $addtype = "$in{'addtype'}"; $addvalue = "$in{'addvalue'}"; if (($addname =~ /.+/) && ($addtype =~ /.+/) && ($addvalue =~ /.+/)) { &svc_setprop("$svc", "$sinst", "$pgroup", "$addname", "$addtype", "$addvalue"); } } if (defined($in{'remove'})) { # get remove prop list @remove_props = split(/\0/, $in{'applyto'}); foreach $rp (@remove_props) { &svc_delprop("$svc", "$sinst", "$pgroup", "$rp"); } } @prop_listing = &svc_listprop("$svc", "$sinst", $pgroup); # need prop listing to match against values for update. if we change # anything, we`ll regenerate the listing... $regenerate_listing = 0; if (defined($in{'update'})) { # update each prop in listing with new value foreach $prop (@prop_listing) { $prop_name = $prop->{'prop_name'}; $prop_type = $prop->{'prop_type'}; if (defined($in{"$prop_name/$prop_type"})) { $prop_value = $in{"$prop_name/$prop_type"}; &svc_setprop("$svc", "$sinst", "$pgroup", "$prop_name", "$prop_type", "$prop_value"); $regenerate_listing = 1; } } } if ($regenerate_listing == 1) { @prop_listing = &svc_listprop("$svc", "$sinst", $pgroup); } print "

"; &text_and_whats_this("property_editor_detail"); print " : $entity/$pgroup

\n"; print "
\n"; # add prop table first... print "

$text{'property_editor_addprop'}

\n"; print ""; print "\n"; print "\n"; print "\n"; print "\n"; print "
$text{'property_editor_addname'}$text{'property_editor_addtype'}$text{'property_editor_addvalue'}
\n"; print "\n"; print "\n"; &print_selection("addtype", "", \@propval_type_values); print "\n"; print "\n"; print "
  "; print "\n"; print "
\n"; print "\n"; print "\n"; print "
\n"; print "
$text{'property_editor_apply'}: "; print " \n"; print "
\n"; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; foreach $prop (@prop_listing) { print ""; $name = $prop->{'prop_name'}; $type = $prop->{'prop_type'}; $value = $prop->{'prop_value'}; print "\n"; print "\n"; print "\n"; print "\n"; print "\n"; } print "\n"; print "
$text{'property_editor_select'}$text{'property_editor_prop_name'}$text{'property_editor_prop_type'}$text{'property_editor_prop_value'}
\n"; print ""; print "$name$type
   \n"; print ""; print "
\n"; &print_cmds_run(); &ui_print_footer("property_group_editor.cgi?fmri='$fmri'", $text{'property_editor_back'});