#!/usr/bin/perl -wT -I.
use CGI;
use Tinderbox3::Header;
use Tinderbox3::DB;
use Tinderbox3::InitialValues;
use Tinderbox3::Login;
use strict;
#
# Init
#
my $p = new CGI;
my $dbh = get_dbh();
my ($login, $cookie) = check_session($p, $dbh);
# For delete_machine
Tinderbox3::DB::update_machine_action($p, $dbh, $login);
# For delete_patch, stop_using_patch
Tinderbox3::DB::update_patch_action($p, $dbh, $login);
# For delete_bonsai
Tinderbox3::DB::update_bonsai_action($p, $dbh, $login);
# For edit_tree
my $tree = Tinderbox3::DB::update_tree_action($p, $dbh, $login);
#
# Get the tree info to fill in the fields
#
my $tree_info;
my %initial_machine_config;
if (!$tree) {
$tree_info = [ $Tinderbox3::InitialValues::field_short_names,
$Tinderbox3::InitialValues::field_processors,
$Tinderbox3::InitialValues::statuses,
$Tinderbox3::InitialValues::min_row_size,
$Tinderbox3::InitialValues::max_row_size,
$Tinderbox3::InitialValues::default_tinderbox_view,
$Tinderbox3::InitialValues::new_machines_visible,
'',
];
%initial_machine_config = %Tinderbox3::InitialValues::initial_machine_config;
} else {
$tree_info = $dbh->selectrow_arrayref("SELECT field_short_names, field_processors, statuses, min_row_size, max_row_size, default_tinderbox_view, new_machines_visible, editors FROM tbox_tree WHERE tree_name = ?", undef, $tree);
if (!defined($tree_info)) {
die "Could not get tree!";
}
my $sth = $dbh->prepare("SELECT name, value FROM tbox_initial_machine_config WHERE tree_name = ?");
$sth->execute($tree);
while (my $row = $sth->fetchrow_arrayref) {
$initial_machine_config{$row->[0]} = $row->[1];
}
}
#
# Edit / Add tree form
#
header($p, $login, $cookie, ($tree ? "Edit $tree" : "Add Tree"), $tree);
print <
@{[$p->hidden(-name=>'tree', -default=>$tree, -override=>1)]}
Tree Name (this is the name used to identify the tree):