$table{components} =
'value tinytext,
program varchar(64),
- initialowner tinytext not null, # Should arguably be a mediumint!
- initialqacontact tinytext not null, # Should arguably be a mediumint!
+ initialowner mediumint not null,
+ initialqacontact mediumint not null,
description mediumtext not null';
"DUPLICATE", "WORKSFORME", "MOVED");
CheckEnumField('bugs', 'resolution', @resolutions);
+if (($_ = GetFieldDef('components', 'initialowner')) and ($_->[1] eq 'tinytext')) {
+ $sth = $dbh->prepare("SELECT program, value, initialowner, initialqacontact FROM components");
+ $sth->execute();
+ while (my ($program, $value, $initialowner) = $sth->fetchrow_array()) {
+ $initialowner =~ s/([\\\'])/\\$1/g; $initialowner =~ s/\0/\\0/g;
+ $program =~ s/([\\\'])/\\$1/g; $program =~ s/\0/\\0/g;
+ $value =~ s/([\\\'])/\\$1/g; $value =~ s/\0/\\0/g;
+
+ my $s2 = $dbh->prepare("SELECT userid FROM profiles WHERE login_name = '$initialowner'");
+ $s2->execute();
+
+ my $initialownerid = $s2->fetchrow_array();
+
+ unless (defined $initialownerid) {
+ print "Warning: You have an invalid initial owner '$initialowner' in program '$program', component '$value'!\n";
+ $initialownerid = 0;
+ }
+
+ my $update = "UPDATE components SET initialowner = $initialownerid ".
+ "WHERE program = '$program' AND value = '$value'";
+ my $s3 = $dbh->prepare("UPDATE components SET initialowner = $initialownerid ".
+ "WHERE program = '$program' AND value = '$value';");
+ $s3->execute();
+ }
+
+ ChangeFieldType('components','initialowner','mediumint');
+}
+
+if (($_ = GetFieldDef('components', 'initialqacontact')) and ($_->[1] eq 'tinytext')) {
+ $sth = $dbh->prepare("SELECT program, value, initialqacontact, initialqacontact FROM components");
+ $sth->execute();
+ while (my ($program, $value, $initialqacontact) = $sth->fetchrow_array()) {
+ $initialqacontact =~ s/([\\\'])/\\$1/g; $initialqacontact =~ s/\0/\\0/g;
+ $program =~ s/([\\\'])/\\$1/g; $program =~ s/\0/\\0/g;
+ $value =~ s/([\\\'])/\\$1/g; $value =~ s/\0/\\0/g;
+
+ my $s2 = $dbh->prepare("SELECT userid FROM profiles WHERE login_name = '$initialqacontact'");
+ $s2->execute();
+
+ my $initialqacontactid = $s2->fetchrow_array();
+
+ unless (defined $initialqacontactid) {
+ if ($initialqacontact ne '') {
+ print "Warning: You have an invalid initial QA contact '$initialqacontact' in program '$program', component '$value'!\n";
+ }
+ $initialqacontactid = 0;
+ }
+
+ my $update = "UPDATE components SET initialqacontact = $initialqacontactid ".
+ "WHERE program = '$program' AND value = '$value'";
+ my $s3 = $dbh->prepare("UPDATE components SET initialqacontact = $initialqacontactid ".
+ "WHERE program = '$program' AND value = '$value';");
+ $s3->execute();
+ }
+
+ ChangeFieldType('components','initialqacontact','mediumint');
+}
+
+
+
my @states = ("UNCONFIRMED", "NEW", "ASSIGNED", "REOPENED", "RESOLVED",
"VERIFIED", "CLOSED");
CheckEnumField('bugs', 'bug_status', @states);
sub EmitFormElements ($$$$$)
{
- my ($product, $component, $initialowner, $initialqacontact, $description) = @_;
+ my ($product, $component, $initialownerid, $initialqacontactid, $description) = @_;
+
+ my ($initialowner, $initialqacontact) = ($initialownerid ? DBID_to_name ($initialownerid) : '',
+ $initialqacontactid ? DBID_to_name ($initialqacontactid) : '');
print " <TH ALIGN=\"right\">Component:</TH>\n";
print " <TD><INPUT SIZE=64 MAXLENGTH=255 NAME=\"component\" VALUE=\"" .
if $dobugcounts;
print " <TH ALIGN=\"left\">Delete</TH>\n";
print "</TR>";
- while ( MoreSQLData() ) {
- my ($component,$desc,$initialowner,$initialqacontact, $bugs) = FetchSQLData();
+ my @data;
+ while (MoreSQLData()) {
+ push @data, [FetchSQLData()];
+ }
+ foreach (@data) {
+ my ($component,$desc,$initialownerid,$initialqacontactid, $bugs) = @$_;
+
$desc ||= "<FONT COLOR=\"red\">missing</FONT>";
- $initialowner ||= "<FONT COLOR=\"red\">missing</FONT>";
- $initialqacontact ||= "<FONT COLOR=\"red\">none</FONT>";
+ my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : "<FONT COLOR=\"red\">missing</FONT>";
+ my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : "<FONT COLOR=\"red\">missing</FONT>";
print "<TR>\n";
print " <TD VALIGN=\"top\"><A HREF=\"editcomponents.cgi?product=", url_quote($product), "&component=", url_quote($component), "&action=edit\"><B>$component</B></A></TD>\n";
print " <TD VALIGN=\"top\">$desc</TD>\n";
print "<FORM METHOD=POST ACTION=editcomponents.cgi>\n";
print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0><TR>\n";
- EmitFormElements($product, '', '', '', '');
+ EmitFormElements($product, '', 0, 0, '');
print "</TR></TABLE>\n<HR>\n";
print "<INPUT TYPE=SUBMIT VALUE=\"Add\">\n";
exit;
}
+ my $initialownerid = DBname_to_id ($initialowner);
+ if (!$initialownerid) {
+ print "You must use an existing Bugzilla account as initial owner for the component
+'$component'. Please press\n";
+ print "<b>Back</b> and try again.\n";
+ PutTrailer($localtrailer);
+ exit;
+ }
+
my $initialqacontact = trim($::FORM{initialqacontact} || '');
+ my $initialqacontactid = DBname_to_id ($initialqacontact);
if (Param('useqacontact')) {
if ($initialqacontact eq '') {
print "You must enter an initial QA contact for the component '$component'. Please press\n";
PutTrailer($localtrailer);
exit;
}
+
+ if (!$initialqacontactid) {
+ print "You must use an existing Bugzilla account as initial QA contact for the component '$component'. Please press\n";
+ print "<b>Back</b> and try again.\n";
+ PutTrailer($localtrailer);
+ exit;
+ }
#
# Now validating to make sure it's too an existing account
#
SqlQuote($product) . "," .
SqlQuote($component) . "," .
SqlQuote($description) . "," .
- SqlQuote($initialowner) . "," .
- SqlQuote($initialqacontact) . ")");
+ SqlQuote($initialownerid) . "," .
+ SqlQuote($initialqacontactid) . ")");
# Make versioncache flush
unlink "data/versioncache";
my ($product,$pdesc,$milestoneurl,$disallownew,
- $dummy,$component,$initialowner,$initialqacontact,$cdesc) = FetchSQLData();
+ $dummy,$component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData();
+
+ my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : "<FONT COLOR=\"red\">missing</FONT>";
+ my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : "<FONT COLOR=\"red\">missing</FONT>";
$pdesc ||= "<FONT COLOR=\"red\">missing</FONT>";
$milestoneurl ||= "<FONT COLOR=\"red\">missing</FONT>";
$disallownew = $disallownew ? 'closed' : 'open';
- $initialowner ||= "<FONT COLOR=\"red\">missing</FONT>";
- $initialqacontact ||= "<FONT COLOR=\"red\">missing</FONT>";
$cdesc ||= "<FONT COLOR=\"red\">missing</FONT>";
print "<TABLE BORDER=1 CELLPADDING=4 CELLSPACING=0><TR BGCOLOR=\"#6666FF\">\n";
AND value=" . SqlQuote($component) );
my ($product,$pdesc,$milestoneurl,$disallownew,
- $dummy,$component,$initialowner,$initialqacontact,$cdesc) = FetchSQLData();
+ $dummy,$component,$initialownerid,$initialqacontactid,$cdesc) = FetchSQLData();
+
+ my $initialowner = $initialownerid ? DBID_to_name ($initialownerid) : '';
+ my $initialqacontact = $initialqacontactid ? DBID_to_name ($initialqacontactid) : '';
print "<FORM METHOD=POST ACTION=editcomponents.cgi>\n";
print "<TABLE BORDER=0 CELLPADDING=4 CELLSPACING=0><TR>\n";
#+++ display product/product description
- EmitFormElements($product, $component, $initialowner, $initialqacontact, $cdesc);
+ EmitFormElements($product, $component, $initialownerid, $initialqacontactid, $cdesc);
print "</TR><TR>\n";
print " <TH ALIGN=\"right\">Bugs:</TH>\n";
# them, be sure to test for WHERE='$component' or WHERE='$componentold'
SendSQL("LOCK TABLES bugs WRITE,
- components WRITE");
+ components WRITE, profiles READ");
if ($description ne $descriptionold) {
unless ($description) {
if ($initialowner ne $initialownerold) {
unless ($initialowner) {
print "Sorry, I can't delete the initial owner.";
- PutTrailer($localtrailer);
SendSQL("UNLOCK TABLES");
+ PutTrailer($localtrailer);
exit;
}
- #+++
- #DBNameToIdAndCheck($initialowner, 0);
+
+ my $initialownerid = DBname_to_id($initialowner);
+ unless ($initialownerid) {
+ print "Sorry, you must use an existing Bugzilla account as initial owner.";
+ SendSQL("UNLOCK TABLES");
+ PutTrailer($localtrailer);
+ exit;
+ }
+
SendSQL("UPDATE components
- SET initialowner=" . SqlQuote($initialowner) . "
+ SET initialowner=" . SqlQuote($initialownerid) . "
WHERE program=" . SqlQuote($product) . "
AND value=" . SqlQuote($componentold));
print "Updated initial owner.<BR>\n";
if (Param('useqacontact') && $initialqacontact ne $initialqacontactold) {
unless ($initialqacontact) {
print "Sorry, I can't delete the initial QA contact.";
- PutTrailer($localtrailer);
SendSQL("UNLOCK TABLES");
+ PutTrailer($localtrailer);
exit;
}
- #+++
- #DBNameToIdAndCheck($initialqacontact, 0);
+
+ my $initialqacontactid = DBname_to_id($initialqacontact);
+ unless ($initialqacontactid) {
+ print "Sorry, you must use an existing Bugzilla account as initial QA contact.";
+ SendSQL("UNLOCK TABLES");
+ PutTrailer($localtrailer);
+ exit;
+ }
+
SendSQL("UPDATE components
- SET initialqacontact=" . SqlQuote($initialqacontact) . "
+ SET initialqacontact=" . SqlQuote($initialqacontactid) . "
WHERE program=" . SqlQuote($product) . "
AND value=" . SqlQuote($componentold));
print "Updated initial QA contact.<BR>\n";