## OpenCA - CA Command
## (c) 2001 by Michael Bell and OpenCA Group
##
##   File Name: show_prepared_right
##       Brief: show a special right
## Description: show a special right and a button to add/delete the right
##  Parameters: module, operator, owner, operation, next_cmd

sub cmdShow_prepared_right {

## load form-data
my $module    = $query->param ('module');
my $operation = $query->param ('operation');
my $operator  = $query->param ('operator');
my $owner     = $query->param ('owner');

## Get required parameters ( return only the value string )
my $sheet    = getRequired( 'ShowPreparedRightSheet' );
my $uptime   = $tools->getDate();

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) );
};

## build data
my $data = "<input type=hidden name=module    value=\"".$module."\">\n".
           "<input type=hidden name=operation value=\"".$operation."\">\n".
           "<input type=hidden name=operator  value=\"".$operator."\">\n".
           "<input type=hidden name=owner     value=\"".$owner."\">\n";
if ( $query->param ('next_cmd') =~ /^delete$/i ) {
  $data .= "<input type=hidden name=cmd value=delete_right>\n";
  $data .= "<input type=submit value=\"".gettext("DELETE the Access Right")."\">\n";
} else {
  $data .= "<input type=hidden name=cmd value=new_right>";
  $data .= "<input type=submit value=\"".gettext("Add the Access Right")."\">\n";
}

## build table
my $table = $query->startTable( COLS=>[ gettext("Name"), gettext("Value") ],
				WIDTH=>"100%",
				TITLE_BGCOLOR=>"#DDCCFF" );
$table .= $query->addTableLine ( DATA => [ gettext("Module"), $module ] );
$table .= $query->addTableLine ( DATA => [ gettext("Operation"), $operation ] );
if ( $operator =~ /^$/ ) {
  $table .= $query->addTableLine ( DATA => [ gettext("Operator"), gettext("New OpenCA User") ] );
} else {
  $table .= $query->addTableLine ( DATA => [ gettext("Operator"), $operator ] );
}
if ( $owner =~ /^$/ ) {
  $table .= $query->addTableLine ( DATA => [ gettext("Owner"), gettext("CA itself or any role") ] );
} else {
  $table .= $query->addTableLine ( DATA => [ gettext("Owner"), $owner ] );
}
$table .= $query->endTable();

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

print "$page";

}

1;

