## OpenCA - CA Command
## (c) 2001 by Michael Bell and OpenCA Group
##
##   File Name: show_script
##       Brief: show a special script
## Description: show a special script
##  Parameters: script, owner_method, operation, owner_argument

sub cmdShow_script {

## Get required parameters ( return only the value string )
my $sheet    = getRequired( 'ShowPreparedScriptSheet' );

my @cols;
my $page;

## Get the base Page ( got in $page variable )
if( not $page = $query->getFile( "$sheet" ) ) {
	configError ( i18nGettext ("File not Found : __SHEET__", "__SHEET__", $sheet) );
};

my $script         = $query->param ('script');

## check for the existence of the script
my $conffile = getRequired ('RBAC_DIR')."/".
               getRequired ('SCRIPT_CONFIG_DIR')."/".
               encodeName ($script).".conf";
if ( not -e $conffile ) {
  configError ( i18nGettext ("The requested configurationfile __FILE__ of the script __SCRIPT__ doesn't exist!",
                             "__FILE__", $conffile,
                             "__SCRIPT__", $script) );
}

## load file
my $ret;
my $script_config =  new OpenCA::Configuration;
if( not ($ret = $script_config->loadCfg( $conffile ) ) ) {
  print "Content-type: text/html\n\n";
  configError( i18nGettext ("Error while Loading Configuration (__FILE__)!", "__FILE__", $conffile) );
  return undef;
}

## build table
my $table .= $query->startTable(COLS=>[ gettext("Variable"), gettext("Data") ],
                                WIDTH=>"100%",
                                TITLE_BGCOLOR=>"#DDCCFF" );
$table .= $query->addTableLine( DATA => [ 
            gettext("Scriptname"),
            $script_config->getParam ('SCRIPT')->{VALUES}->[0] 
                                        ] );
$table .= $query->addTableLine( DATA => [ 
            gettext("Operation"),
            $script_config->getParam ('OPERATION')->{VALUES}->[0] 
                                        ] );
$table .= $query->addTableLine( DATA => [
            gettext("Owner_Method"),
            $script_config->getParam ('OWNER_METHOD')->{VALUES}->[0] 
                                        ] );
$table .= $query->addTableLine( DATA => [
            gettext("Owner_Argument"),
            $script_config->getParam ('OWNER_ARGUMENT')->{VALUES}->[0] 
                                        ] );
$table .= $query->endTable();

## Substitute the Variables in the $page
$page = $query->subVar( $page, '$script', $script );
$page = $query->subVar( $page, '$table', $table );
$page = $query->subVar( $page, '$data', $data );

print "$page";

}

1;
