#!/usr/bin/perl -wT -I.
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1
#
# The contents of this file are subject to the Mozilla Public License Version
# 1.1 (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
# http://www.mozilla.org/MPL/
#
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
#
# The Original Code is Tinderbox 3.
#
# The Initial Developer of the Original Code is
# John Keiser (john@johnkeiser.com).
# Portions created by the Initial Developer are Copyright (C) 2004
# the Initial Developer. All Rights Reserved.
#
# Contributor(s):
#
# ***** END LICENSE BLOCK *****
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::DB::sql_get_bool($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):
Initial Machine Config: ";
print "(Empty a line to delete it) ";
print "
Var
Value
\n";
my $config_num = 1;
foreach my $var (sort keys %initial_machine_config) {
my $value = $initial_machine_config{$var};
if ($var ne "mozconfig") {
print "
\n";
$sth = $dbh->prepare('SELECT machine_id, machine_name FROM tbox_machine WHERE tree_name = ? ORDER BY machine_name');
$sth->execute($tree);
while (my $machine_info = $sth->fetchrow_arrayref) {
print "
\n";
$sth = $dbh->prepare('SELECT bonsai_id, display_name FROM tbox_bonsai WHERE tree_name = ? ORDER BY display_name');
$sth->execute($tree);
while (my $bonsai_info = $sth->fetchrow_arrayref) {
print "