Commit 65695473 authored by endico%mozilla.org's avatar endico%mozilla.org

Bug moving code is now fully implemented. To use it, turn on the param and set…

Bug moving code is now fully implemented. To use it, turn on the param and set the move related params.
parent 17c6ef4a
...@@ -423,6 +423,9 @@ if ($status eq $::unconfirmedstate) { ...@@ -423,6 +423,9 @@ if ($status eq $::unconfirmedstate) {
} }
} }
my $movers = Param("movers");
$movers =~ s/\s?,\s?/|/g;
$movers =~ s/@/\@/g;
if ($canedit || $::userid == $assignedtoid || if ($canedit || $::userid == $assignedtoid ||
$::userid == $reporterid || $::userid == $qacontactid) { $::userid == $reporterid || $::userid == $qacontactid) {
...@@ -472,6 +475,22 @@ if ($canedit || $::userid == $assignedtoid || ...@@ -472,6 +475,22 @@ if ($canedit || $::userid == $assignedtoid ||
print "&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=checkbox NAME=compconfirm> and confirm bug (change status to <b>NEW</b>)<BR>"; print "&nbsp;&nbsp;&nbsp;&nbsp;<INPUT TYPE=checkbox NAME=compconfirm> and confirm bug (change status to <b>NEW</b>)<BR>";
} }
$knum++; $knum++;
} elsif ( Param("move-enabled") && ($bug{'resolution'} eq "MOVED") ) {
if ( (defined $::COOKIE{"Bugzilla_login"})
&& ($::COOKIE{"Bugzilla_login"} =~ /($movers)/) ){
print "<INPUT TYPE=radio NAME=knob VALUE=reopen> Reopen bug<br>\n";
$knum++;
if ($status eq "RESOLVED") {
print "<INPUT TYPE=radio NAME=knob VALUE=verify>
Mark bug as <b>VERIFIED</b><br>\n";
$knum++;
}
if ($status ne "CLOSED") {
print "<INPUT TYPE=radio NAME=knob VALUE=close>
Mark bug as <b>CLOSED</b><br>\n";
$knum++;
}
}
} else { } else {
print "<INPUT TYPE=radio NAME=knob VALUE=reopen> Reopen bug<br>\n"; print "<INPUT TYPE=radio NAME=knob VALUE=reopen> Reopen bug<br>\n";
$knum++; $knum++;
...@@ -491,14 +510,25 @@ if ($canedit || $::userid == $assignedtoid || ...@@ -491,14 +510,25 @@ if ($canedit || $::userid == $assignedtoid ||
print " print "
<INPUT TYPE=\"submit\" VALUE=\"Commit\"> <INPUT TYPE=\"submit\" VALUE=\"Commit\">
<INPUT TYPE=\"reset\" VALUE=\"Reset\"> <INPUT TYPE=\"reset\" VALUE=\"Reset\">
<INPUT TYPE=hidden name=form_name VALUE=process_bug> <INPUT TYPE=\"hidden\" name=\"form_name\" VALUE=\"process_bug\">
<P> <P>
<FONT size=\"+1\"><B> <FONT size=\"+1\"><B>
<A HREF=\"show_activity.cgi?id=$id\">View Bug Activity</A> <A HREF=\"show_activity.cgi?id=$id\">View Bug Activity</A>
&nbsp; | &nbsp; &nbsp; | &nbsp;
<A HREF=\"long_list.cgi?buglist=$id\">Format For Printing</A> <A HREF=\"long_list.cgi?buglist=$id\">Format For Printing</A>
</B></FONT><BR> </B></FONT><BR>
</FORM> ";
if ( Param("move-enabled") && (defined $::COOKIE{"Bugzilla_login"}) && ($::COOKIE{"Bugzilla_login"} =~ /($movers)/) ){
print "
<P>
<INPUT TYPE=\"SUBMIT\" NAME=\"action\" VALUE=\""
. Param("move-button-text") . "\">";
}
print "</FORM>";
print "
<table><tr><td align=left><B>Description:</B></td> <table><tr><td align=left><B>Description:</B></td>
<td align=right width=100%>Opened: $bug{'creation_ts'}</td></tr></table> <td align=right width=100%>Opened: $bug{'creation_ts'}</td></tr></table>
<HR> <HR>
......
...@@ -1277,7 +1277,6 @@ document.write(\" <input type=button value=\\\"Uncheck All\\\" onclick=\\\"SetCh ...@@ -1277,7 +1277,6 @@ document.write(\" <input type=button value=\\\"Uncheck All\\\" onclick=\\\"SetCh
value_quote($::dontchange) . "\"></TD> value_quote($::dontchange) . "\"></TD>
</TR>"; </TR>";
} }
if (@::legal_keywords) { if (@::legal_keywords) {
print qq{ print qq{
...@@ -1394,8 +1393,21 @@ To make changes to a bunch of bugs at once: ...@@ -1394,8 +1393,21 @@ To make changes to a bunch of bugs at once:
comment explaining what you're doing.) comment explaining what you're doing.)
<li> Click the below \"Commit\" button. <li> Click the below \"Commit\" button.
</ol></font> </ol></font>
<INPUT TYPE=SUBMIT VALUE=Commit> <INPUT TYPE=SUBMIT VALUE=Commit>";
</FORM><hr>\n";
my $movers = Param("movers");
$movers =~ s/\s?,\s?/|/g;
$movers =~ s/@/\@/g;
if ( Param("move-enabled")
&& (defined $::COOKIE{"Bugzilla_login"})
&& ($::COOKIE{"Bugzilla_login"} =~ /($movers)/) ){
print "<P>";
print "<INPUT TYPE=\"SUBMIT\" NAME=\"action\" VALUE=\"";
print Param("move-button-text") . "\">";
}
print "</FORM><hr>\n";
} }
...@@ -1425,8 +1437,10 @@ if ($count > 0) { ...@@ -1425,8 +1437,10 @@ if ($count > 0) {
} }
print qq{&nbsp;&nbsp;\n}; print qq{&nbsp;&nbsp;\n};
print qq{<NOBR><A HREF="query.cgi?$::buffer">Edit this query</A></NOBR>\n}; print qq{<NOBR><A HREF="query.cgi?$::buffer">Edit this query</A></NOBR>\n};
print "</FORM>\n"; print "</FORM>\n";
} }
PutFooter(); PutFooter();
if ($serverpush) { if ($serverpush) {
......
...@@ -560,5 +560,41 @@ DefParam("supportwatchers", ...@@ -560,5 +560,41 @@ DefParam("supportwatchers",
" about) another's bugs. Useful for people going on vacation, and" . " about) another's bugs. Useful for people going on vacation, and" .
" QA folks watching particular developers' bugs", " QA folks watching particular developers' bugs",
"b", 0 ); "b", 0 );
1;
DefParam("move-enabled",
"If this is on, Bugzilla will allow certain people to move bugs to the defined database.",
"b",
0);
DefParam("move-button-text",
"The text written on the Move button. Explain where the bug is being moved to.",
"t",
'Move To Bugscape');
DefParam("move-to-url",
"The URL of the database we allow some of our bugs to be moved to.",
"t",
'');
DefParam("move-to-address",
"To move bugs, an email is sent to the target database. This is the email address that database
uses to listen for incoming bugs.",
"t",
'bugzilla-import');
DefParam("moved-from-address",
"To move bugs, an email is sent to the target database. This is the email address from which
this mail, and error messages are sent.",
"t",
'bugzilla-admin');
DefParam("movers",
"A list of people with permission to move bugs and reopen moved bugs (in case the move operation fails).",
"t",
'');
DefParam("moved-default-product",
"Bugs moved from other databases to here are assigned to this product.",
"t",
'');
DefParam("moved-default-component",
"Bugs moved from other databases to here are assigned to this component.",
"t",
'');
1;
...@@ -67,6 +67,7 @@ sub sillyness { ...@@ -67,6 +67,7 @@ sub sillyness {
my $zz; my $zz;
$zz = %::components; $zz = %::components;
$zz = %::versions; $zz = %::versions;
$zz = %::keywordsbyname;
$zz = @::legal_bug_status; $zz = @::legal_bug_status;
$zz = @::legal_opsys; $zz = @::legal_opsys;
$zz = @::legal_platform; $zz = @::legal_platform;
...@@ -94,7 +95,9 @@ sub MailMessage { ...@@ -94,7 +95,9 @@ sub MailMessage {
my $to = join (", ", @recipients); my $to = join (", ", @recipients);
my $header = "To: $to\n"; my $header = "To: $to\n";
$header.= "From: Bugzilla <bugzilla\@beefaroni>\n"; my $from = Param("moved-from-address");
$from =~ s/@/\@/g;
$header.= "From: Bugzilla <$from>\n";
$header.= "Subject: $subject\n\n"; $header.= "Subject: $subject\n\n";
open(SENDMAIL, open(SENDMAIL,
...@@ -180,6 +183,17 @@ if (defined $tree->[1][0]->{'exporter'}) { ...@@ -180,6 +183,17 @@ if (defined $tree->[1][0]->{'exporter'}) {
exit; exit;
} }
unless ( Param("move-enabled") ) {
my $subject = "Error: bug importing is disabled here";
my $message = "Cannot import these bugs because importing is disabled\n";
$message .= "at this site. For more info, contact ";
$message .= Param("maintainer") . ".\n";
my @to = (Param("maintainer"), $maintainer, $exporter);
MailMessage ($subject, $message, @to);
exit;
}
my $exporterid = DBname_to_id($exporter); my $exporterid = DBname_to_id($exporter);
if ( ! $exporterid ) { if ( ! $exporterid ) {
my $subject = "Bug import error: invalid exporter"; my $subject = "Bug import error: invalid exporter";
...@@ -187,7 +201,7 @@ if ( ! $exporterid ) { ...@@ -187,7 +201,7 @@ if ( ! $exporterid ) {
$message .= "bugs here does not have an account in this database.\n"; $message .= "bugs here does not have an account in this database.\n";
$message .= "\n\nPlease re-open the original bug.\n"; $message .= "\n\nPlease re-open the original bug.\n";
$message .= "\n\n$xml"; $message .= "\n\n$xml";
my @to = (Param("maintainer"), $maintainer); my @to = (Param("maintainer"), $maintainer, $exporter);
MailMessage ($subject, $message, @to); MailMessage ($subject, $message, @to);
exit; exit;
} }
...@@ -233,7 +247,7 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -233,7 +247,7 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
foreach my $field (qw (dependson product bug_status priority cc version foreach my $field (qw (dependson product bug_status priority cc version
bug_id rep_platform short_desc assigned_to bug_file_loc resolution bug_id rep_platform short_desc assigned_to bug_file_loc resolution
delta_ts component reporter urlbase target_milestone bug_severity delta_ts component reporter urlbase target_milestone bug_severity
creation_ts qa_contact keyword status_whiteboard op_sys blocks)) { creation_ts qa_contact keywords status_whiteboard op_sys blocks)) {
$all_fields{$field} = "x"; $all_fields{$field} = "x";
} }
...@@ -294,15 +308,13 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -294,15 +308,13 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
$long_description .= "$sorted_descs[$z]->{'bug_when'}"; $long_description .= "$sorted_descs[$z]->{'bug_when'}";
$long_description .= " ----\n\n"; $long_description .= " ----\n\n";
} }
$long_description .= "$sorted_descs[$z]->{'thetext'}\n"; $long_description .= UnQuoteXMLChars($sorted_descs[$z]->{'thetext'});
$long_description .= "\n";
} }
my $comments; my $comments;
my $query = "INSERT INTO bugs (\n";
my $values = "VALUES (\n";
$comments .= "\n\n------- Bug Moved by $exporter "; $comments .= "\n\n------- Bug moved to this database by $exporter ";
$comments .= time2str("%Y-%m-%d %H:%M", time); $comments .= time2str("%Y-%m-%d %H:%M", time);
$comments .= " -------\n\n"; $comments .= " -------\n\n";
$comments .= "This bug previously known as bug $bug_fields{'bug_id'} at "; $comments .= "This bug previously known as bug $bug_fields{'bug_id'} at ";
...@@ -318,56 +330,85 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -318,56 +330,85 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
$comments .= "Bug blocks bug(s) $bug_fields{'blocks'}.\n"; $comments .= "Bug blocks bug(s) $bug_fields{'blocks'}.\n";
} }
my @query = ();
foreach my $field ( qw(creation_ts delta_ts keywords status_whiteboard) ) { my @values = ();
foreach my $field ( qw(creation_ts delta_ts status_whiteboard) ) {
if ( (defined $bug_fields{$field}) && ($bug_fields{$field}) ){ if ( (defined $bug_fields{$field}) && ($bug_fields{$field}) ){
$query .= "$field,\n"; push (@query, "$field");
$values .= SqlQuote($bug_fields{$field}) . ",\n"; push (@values, SqlQuote($bug_fields{$field}));
} }
} }
if ( (defined $bug_fields{'bug_file_loc'}) && ($bug_fields{'bug_file_loc'}) ){ if ( (defined $bug_fields{'bug_file_loc'}) && ($bug_fields{'bug_file_loc'}) ){
$query .= "bug_file_loc,\n"; push (@query, "bug_file_loc");
$values .= SqlQuote(UnQuoteXMLChars($bug_fields{'bug_file_loc'})) . ",\n"; push (@values, SqlQuote(UnQuoteXMLChars($bug_fields{'bug_file_loc'})));
} }
if ( (defined $bug_fields{'short_desc'}) && ($bug_fields{'short_desc'}) ){ if ( (defined $bug_fields{'short_desc'}) && ($bug_fields{'short_desc'}) ){
$query .= "short_desc,\n"; push (@query, "short_desc");
$values .= SqlQuote(UnQuoteXMLChars($bug_fields{'short_desc'})) . ",\n"; push (@values, SqlQuote(UnQuoteXMLChars($bug_fields{'short_desc'})) );
} }
my $prod;
my $comp;
my $default_prod = Param("moved-default-product");
my $default_comp = Param("moved-default-component");
if ( (defined ($bug_fields{'product'})) &&
(defined ($bug_fields{'component'})) ) {
$prod = $bug_fields{'product'};
$comp = $bug_fields{'component'};
} else {
$prod = $default_prod;
$comp = $default_comp;
}
my @product; my @product;
if (defined ($bug_fields{'product'}) && my @component;
(@product = grep /^$bug_fields{'product'}$/i, @::legal_product) ){ if ((@product = grep /^$prod$/i, @::legal_product) &&
$query .= "product,\n"; (@component = grep /^$comp$/i, @{$::components{$product[0]}}) ) {
$values .= SqlQuote($product[0]) . ",\n"; push (@query, "product");
push (@values, SqlQuote($product[0]) );
push (@query, "component");
push (@values, SqlQuote($component[0]) );
} elsif ((@product = grep /^$default_prod$/i, @::legal_product) &&
(@component = grep /^$default_comp$/i, @{$::components{$product[0]}}) ) {
push (@query, "product");
push (@values, SqlQuote($product[0]) );
push (@query, "component");
push (@values, SqlQuote($component[0]) );
} else { } else {
$query .= "product,\n"; my $subject = "Bug import error: invalid default product or component";
$values .= "\'From Bugzilla\',\n"; my $message = "Cannot import these bugs because an invalid default ";
$product[0] = "From Bugzilla"; $message .= "product and/or component was defined for the target db.\n";
$err .= "Unknown product $bug_fields{'product'}. "; $message .= Param("maintainer") . " needs to fix the definitions of ";
$err .= "Moving to default product \"From Bugzilla\".\n"; $message .= "moved-default-product and moved-default-component.\n";
$message .= "\n\nPlease re-open the original bug.\n";
$message .= "\n\n$xml";
my @to = (Param("maintainer"), $maintainer, $exporter);
MailMessage ($subject, $message, @to);
exit;
} }
if (defined ($::versions{$product[0]} ) && if (defined ($::versions{$product[0]} ) &&
(my @version = grep /^$bug_fields{'version'}$/i, (my @version = grep /^$bug_fields{'version'}$/i,
@{$::versions{$product[0]}}) ){ @{$::versions{$product[0]}}) ){
$values .= SqlQuote($version[0]) . ",\n"; push (@values, SqlQuote($version[0]) );
$query .= "version,\n"; push (@query, "version");
} else { } else {
$query .= "version,\n"; push (@query, "version");
$values .= "\'@{$::versions{$product[0]}}->[0]\',\n"; push (@values, SqlQuote(@{$::versions{$product[0]}}->[0]));
$err .= "Unknown version $bug_fields{'version'} in product $product[0]. "; $err .= "Unknown version $bug_fields{'version'} in product $product[0]. ";
$err .= "Setting version to \"@{$::versions{$product[0]}}->[0]\".\n"; $err .= "Setting version to \"@{$::versions{$product[0]}}->[0]\".\n";
} }
if (defined ($bug_fields{'priority'}) && if (defined ($bug_fields{'priority'}) &&
(my @priority = grep /^$bug_fields{'priority'}$/i, @::legal_priority) ){ (my @priority = grep /^$bug_fields{'priority'}$/i, @::legal_priority) ){
$values .= SqlQuote($priority[0]) . ",\n"; push (@values, SqlQuote($priority[0]) );
$query .= "priority,\n"; push (@query, "priority");
} else { } else {
$values .= "\'P3\',\n"; push (@values, SqlQuote("P3"));
$query .= "priority,\n"; push (@query, "priority");
$err .= "Unknown priority "; $err .= "Unknown priority ";
$err .= (defined $bug_fields{'priority'})?$bug_fields{'priority'}:"unknown"; $err .= (defined $bug_fields{'priority'})?$bug_fields{'priority'}:"unknown";
$err .= ". Setting to default priority \"P3\".\n"; $err .= ". Setting to default priority \"P3\".\n";
...@@ -375,11 +416,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -375,11 +416,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
if (defined ($bug_fields{'rep_platform'}) && if (defined ($bug_fields{'rep_platform'}) &&
(my @platform = grep /^$bug_fields{'rep_platform'}$/i, @::legal_platform) ){ (my @platform = grep /^$bug_fields{'rep_platform'}$/i, @::legal_platform) ){
$values .= SqlQuote($platform[0]) . ",\n"; push (@values, SqlQuote($platform[0]) );
$query .= "rep_platform,\n"; push (@query, "rep_platform");
} else { } else {
$values .= "\'Other\',\n"; push (@values, SqlQuote("Other") );
$query .= "rep_platform,\n"; push (@query, "rep_platform");
$err .= "Unknown platform "; $err .= "Unknown platform ";
$err .= (defined $bug_fields{'rep_platform'})? $err .= (defined $bug_fields{'rep_platform'})?
$bug_fields{'rep_platform'}:"unknown"; $bug_fields{'rep_platform'}:"unknown";
...@@ -388,45 +429,28 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -388,45 +429,28 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
if (defined ($bug_fields{'op_sys'}) && if (defined ($bug_fields{'op_sys'}) &&
(my @opsys = grep /^$bug_fields{'op_sys'}$/i, @::legal_opsys) ){ (my @opsys = grep /^$bug_fields{'op_sys'}$/i, @::legal_opsys) ){
$values .= SqlQuote($opsys[0]) . ",\n"; push (@values, SqlQuote($opsys[0]) );
$query .= "op_sys,\n"; push (@query, "op_sys");
} else { } else {
$values .= "\'other\',\n"; push (@values, SqlQuote("other"));
$query .= "op_sys,\n"; push (@query, "op_sys");
$err .= "Unknown operating system "; $err .= "Unknown operating system ";
$err .= (defined $bug_fields{'op_sys'})?$bug_fields{'op_sys'}:"unknown"; $err .= (defined $bug_fields{'op_sys'})?$bug_fields{'op_sys'}:"unknown";
$err .= ". Setting to default OS \"other\".\n"; $err .= ". Setting to default OS \"other\".\n";
} }
my @component;
if (defined ($::components{$product[0]} ) &&
(@component = grep /^$bug_fields{'component'}$/i,
@{$::components{$product[0]}}) ){
$values .= SqlQuote($component[0]) . ",\n";
$query .= "component,\n";
} else {
$component[0] = $::components{$product[0]}->[0];
$values .= SqlQuote($component[0]) . ",\n";
$query .= "component,\n";
$err .= "Unknown component \"";
$err .= (defined $bug_fields{'component'})?$bug_fields{'component'}:"unknown";
$err .= "\" in product \"$product[0]\".\n";
$err .= " Setting to this product\'s first component, ";
$err .= "\'$::components{$product[0]}->[0]\'.\n";
}
if (Param("usetargetmilestone")) { if (Param("usetargetmilestone")) {
if (defined ($::target_milestone{$product[0]} ) && if (defined ($::target_milestone{$product[0]} ) &&
(my @tm = grep /^$bug_fields{'target_milestone'}$/i, (my @tm = grep /^$bug_fields{'target_milestone'}$/i,
@{$::target_milestone{$product[0]}}) ){ @{$::target_milestone{$product[0]}}) ){
$values .= SqlQuote($tm[0]) . ",\n"; push (@values, SqlQuote($tm[0]) );
$query .= "target_milestone,\n"; push (@query, "target_milestone");
} else { } else {
SendSQL("SELECT defaultmilestone FROM products " . SendSQL("SELECT defaultmilestone FROM products " .
"WHERE product = " . SqlQuote($product[0])); "WHERE product = " . SqlQuote($product[0]));
my $tm = FetchOneColumn(); my $tm = FetchOneColumn();
$values .= "\'$tm\',\n"; push (@values, SqlQuote($tm));
$query .= "target_milestone,\n"; push (@query, "target_milestone");
$err .= "Unknown milestone \""; $err .= "Unknown milestone \"";
$err .= (defined $bug_fields{'target_milestone'})? $err .= (defined $bug_fields{'target_milestone'})?
$bug_fields{'target_milestone'}:"unknown"; $bug_fields{'target_milestone'}:"unknown";
...@@ -439,11 +463,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -439,11 +463,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
if (defined ($bug_fields{'bug_severity'}) && if (defined ($bug_fields{'bug_severity'}) &&
(my @severity= grep /^$bug_fields{'bug_severity'}$/i, (my @severity= grep /^$bug_fields{'bug_severity'}$/i,
@::legal_severity) ){ @::legal_severity) ){
$values .= SqlQuote($severity[0]) . ",\n"; push (@values, SqlQuote($severity[0]) );
$query .= "bug_severity,\n"; push (@query, "bug_severity");
} else { } else {
$values .= "\'normal',\n"; push (@values, SqlQuote("normal"));
$query .= "bug_severity,\n"; push (@query, "bug_severity");
$err .= "Unknown severity "; $err .= "Unknown severity ";
$err .= (defined $bug_fields{'bug_severity'})? $err .= (defined $bug_fields{'bug_severity'})?
$bug_fields{'bug_severity'}:"unknown"; $bug_fields{'bug_severity'}:"unknown";
...@@ -452,11 +476,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -452,11 +476,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
my $reporterid = DBname_to_id($bug_fields{'reporter'}); my $reporterid = DBname_to_id($bug_fields{'reporter'});
if ( ($bug_fields{'reporter'}) && ( $reporterid ) ) { if ( ($bug_fields{'reporter'}) && ( $reporterid ) ) {
$values .= "'$reporterid',\n"; push (@values, SqlQuote($reporterid));
$query .= "reporter,\n"; push (@query, "reporter");
} else { } else {
$values .= "'$exporterid',\n"; push (@values, SqlQuote($exporterid));
$query .= "reporter,\n"; push (@query, "reporter");
$err .= "The original reporter of this bug does not have\n"; $err .= "The original reporter of this bug does not have\n";
$err .= " an account here. Reassigning to the person who moved\n"; $err .= " an account here. Reassigning to the person who moved\n";
$err .= " it here, $exporter.\n"; $err .= " it here, $exporter.\n";
...@@ -470,11 +494,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -470,11 +494,11 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
my $changed_owner = 0; my $changed_owner = 0;
if ( ($bug_fields{'assigned_to'}) && if ( ($bug_fields{'assigned_to'}) &&
( DBname_to_id($bug_fields{'assigned_to'})) ) { ( DBname_to_id($bug_fields{'assigned_to'})) ) {
$values .= "'" . DBname_to_id($bug_fields{'assigned_to'}) . "',\n"; push (@values, SqlQuote(DBname_to_id($bug_fields{'assigned_to'})));
$query .= "assigned_to,\n"; push (@query, "assigned_to");
} else { } else {
$values .= "'" . $exporterid . "',\n"; push (@values, SqlQuote($exporterid) );
$query .= "assigned_to,\n"; push (@query, "assigned_to");
$changed_owner = 1; $changed_owner = 1;
$err .= "The original owner of this bug does not have\n"; $err .= "The original owner of this bug does not have\n";
$err .= " an account here. Reassigning to the person who moved\n"; $err .= " an account here. Reassigning to the person who moved\n";
...@@ -489,8 +513,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -489,8 +513,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
my @resolution; my @resolution;
if (defined ($bug_fields{'resolution'}) && if (defined ($bug_fields{'resolution'}) &&
(@resolution= grep /^$bug_fields{'resolution'}$/i, @::legal_resolution) ){ (@resolution= grep /^$bug_fields{'resolution'}$/i, @::legal_resolution) ){
$values .= SqlQuote($resolution[0]) . ",\n"; push (@values, SqlQuote($resolution[0]) );
$query .= "resolution,\n"; push (@query, "resolution");
} elsif ( (defined $bug_fields{'resolution'}) && (!$resolution[0]) ){ } elsif ( (defined $bug_fields{'resolution'}) && (!$resolution[0]) ){
$err .= "Unknown resolution \"$bug_fields{'resolution'}\".\n"; $err .= "Unknown resolution \"$bug_fields{'resolution'}\".\n";
} }
...@@ -499,8 +523,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -499,8 +523,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
# resolution is set, which indicates that the bug should be closed. # resolution is set, which indicates that the bug should be closed.
# #
if ( ($changed_owner) && (!$resolution[0]) ) { if ( ($changed_owner) && (!$resolution[0]) ) {
$values .= "\'NEW\',\n"; push (@values, SqlQuote("NEW"));
$query .= "bug_status,\n"; push (@query, "bug_status");
$err .= "Bug assigned to new owner, setting status to \"NEW\".\n"; $err .= "Bug assigned to new owner, setting status to \"NEW\".\n";
$err .= " Previous status was \""; $err .= " Previous status was \"";
$err .= (defined $bug_fields{'bug_status'})? $err .= (defined $bug_fields{'bug_status'})?
...@@ -508,8 +532,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -508,8 +532,8 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
$err .= "\".\n"; $err .= "\".\n";
} elsif ( (defined ($bug_fields{'resolution'})) && (!$resolution[0]) ){ } elsif ( (defined ($bug_fields{'resolution'})) && (!$resolution[0]) ){
#if the resolution was illegal then set status to NEW #if the resolution was illegal then set status to NEW
$values .= "\'NEW\',\n"; push (@values, SqlQuote("NEW"));
$query .= "bug_status,\n"; push (@query, "bug_status");
$err .= "Resolution was invalid. Setting status to \"NEW\".\n"; $err .= "Resolution was invalid. Setting status to \"NEW\".\n";
$err .= " Previous status was \""; $err .= " Previous status was \"";
$err .= (defined $bug_fields{'bug_status'})? $err .= (defined $bug_fields{'bug_status'})?
...@@ -518,12 +542,12 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -518,12 +542,12 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
} elsif (defined ($bug_fields{'bug_status'}) && } elsif (defined ($bug_fields{'bug_status'}) &&
(my @status = grep /^$bug_fields{'bug_status'}$/i, @::legal_bug_status) ){ (my @status = grep /^$bug_fields{'bug_status'}$/i, @::legal_bug_status) ){
#if a bug status was set then use it, if its legal #if a bug status was set then use it, if its legal
$values .= SqlQuote($status[0]) . ",\n"; push (@values, SqlQuote($status[0]));
$query .= "bug_status,\n"; push (@query, "bug_status");
} else { } else {
# if all else fails, make the bug new # if all else fails, make the bug new
$values .= "\'NEW\',\n"; push (@values, SqlQuote("NEW"));
$query .= "bug_status,\n"; push (@query, "bug_status");
$err .= "Unknown status "; $err .= "Unknown status ";
$err .= (defined $bug_fields{'bug_status'})? $err .= (defined $bug_fields{'bug_status'})?
$bug_fields{'bug_status'}:"unknown"; $bug_fields{'bug_status'}:"unknown";
...@@ -534,21 +558,26 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -534,21 +558,26 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
my $qa_contact; my $qa_contact;
if ( (defined $bug_fields{'qa_contact'}) && if ( (defined $bug_fields{'qa_contact'}) &&
($qa_contact = DBname_to_id($bug_fields{'qa_contact'})) ){ ($qa_contact = DBname_to_id($bug_fields{'qa_contact'})) ){
$values .= "'$qa_contact'"; push (@values, SqlQuote($qa_contact));
$query .= "qa_contact\n"; push (@query, "qa_contact");
} else { } else {
SendSQL("select initialqacontact from components where program=" . SendSQL("select initialqacontact from components where program=" .
SqlQuote($product[0]) . SqlQuote($product[0]) .
" and value=" . SqlQuote($component[0]) ); " and value=" . SqlQuote($component[0]) );
$qa_contact = FetchOneColumn(); $qa_contact = FetchOneColumn();
$values .= SqlQuote(DBname_to_id($qa_contact)) . "\n"; push (@values, SqlQuote(DBname_to_id($qa_contact)) );
$query .= "qa_contact\n"; push (@query, "qa_contact");
$err .= "Setting qa contact to the default for this product.\n"; $err .= "Setting qa contact to the default for this product.\n";
$err .= " This bug either had no qa contact or an invalid one.\n"; $err .= " This bug either had no qa contact or an invalid one.\n";
} }
} }
$query .= ") $values )\n";
my $query = "INSERT INTO bugs (\n"
. join (",\n", @query)
. "\n) VALUES (\n"
. join (",\n", @values)
. "\n)\n";
SendSQL($query); SendSQL($query);
SendSQL("select LAST_INSERT_ID()"); SendSQL("select LAST_INSERT_ID()");
my $id = FetchOneColumn(); my $id = FetchOneColumn();
...@@ -562,6 +591,24 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -562,6 +591,24 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
} }
} }
if (defined ($bug_fields{'keywords'})) {
my %keywordseen;
foreach my $keyword (split(/[\s,]+/, $bug_fields{'keywords'})) {
if ($keyword eq '') {
next;
}
my $i = $::keywordsbyname{$keyword};
if (!$i) {
$err .= "Skipping unknown keyword: $keyword.\n";
next;
}
if (!$keywordseen{$i}) {
SendSQL("INSERT INTO keywords (bug_id, keywordid) VALUES ($id, $i)");
$keywordseen{$i} = 1;
}
}
}
$long_description .= "\n" . $comments; $long_description .= "\n" . $comments;
if ($err) { if ($err) {
$long_description .= "\n$err\n"; $long_description .= "\n$err\n";
...@@ -570,13 +617,17 @@ for (my $k=1 ; $k <= $bugqty ; $k++) { ...@@ -570,13 +617,17 @@ for (my $k=1 ; $k <= $bugqty ; $k++) {
SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " . SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " .
"($id, $exporterid, now(), " . SqlQuote($long_description) . ")"); "($id, $exporterid, now(), " . SqlQuote($long_description) . ")");
$log .= "Bug $bug_fields{'bug_id'}\@$urlbase imported as bug $id.\n"; $log .= "Bug $urlbase/show_bug.cgi?id=$bug_fields{'bug_id'} ";
$log .= "imported as bug $id.\n";
$log .= Param("urlbase") . "/show_bug.cgi?id=$id\n\n";
if ($err) { if ($err) {
$log .= "The following problems were encountered importing this bug.\n"; $log .= "The following problems were encountered creating bug $id.\n";
$log .= "You may have to set certain fields in the new bug by hand.\n"; $log .= "You may have to set certain fields in the new bug by hand.\n\n";
$log .= $err; $log .= $err;
$log .= "\n\n"; $log .= "\n\n\n";
} }
system("./processmail", $id, $exporter);
} }
my $subject = "$bugqty bug(s) successfully moved from $urlbase to " my $subject = "$bugqty bug(s) successfully moved from $urlbase to "
......
...@@ -27,6 +27,12 @@ use Bug; ...@@ -27,6 +27,12 @@ use Bug;
require "CGI.pl"; require "CGI.pl";
$::lockcount = 0; $::lockcount = 0;
unless ( Param("move-enabled") ) {
print "\n<P>Sorry. Bug moving is not enabled here. ";
print "If you need to move a bug, contact " . Param("maintainer");
exit;
}
ConnectToDatabase(); ConnectToDatabase();
sub Log { sub Log {
...@@ -65,14 +71,22 @@ sub Unlock { ...@@ -65,14 +71,22 @@ sub Unlock {
} }
if ( !defined $::FORM{'buglist'} ) { if ( !defined $::FORM{'buglist'} ) {
print "To move bugs, perform a "; print "Content-type: text/html\n\n";
PutHeader("Move Bugs");
print "Move bugs either from the bug display page or perform a ";
print "<A HREF=\"query.cgi\">query</A> and change several bugs at once.\n"; print "<A HREF=\"query.cgi\">query</A> and change several bugs at once.\n";
print "If you don't see the move button, then you either aren't ";
print "logged in or aren't permitted to.";
PutFooter();
exit; exit;
} }
confirm_login(); confirm_login();
my $exporter = $::COOKIE{"Bugzilla_login"}; my $exporter = $::COOKIE{"Bugzilla_login"};
unless ($exporter =~ /(lchaing\@netscape.com|leger\@netscape.com|endico\@mozilla.org|dmose\@mozilla.org)/) { my $movers = Param("movers");
$movers =~ s/\w?,\w?/|/g;
$movers =~ s/@/\@/g;
unless ($exporter =~ /($movers)/) {
print "Content-type: text/html\n\n"; print "Content-type: text/html\n\n";
PutHeader("Move Bugs"); PutHeader("Move Bugs");
print "<P>You do not have permission to move bugs<P>\n"; print "<P>You do not have permission to move bugs<P>\n";
...@@ -88,15 +102,32 @@ foreach my $id (split(/:/, $::FORM{'buglist'})) { ...@@ -88,15 +102,32 @@ foreach my $id (split(/:/, $::FORM{'buglist'})) {
my $bug = new Bug($id, $::userid); my $bug = new Bug($id, $::userid);
$xml .= $bug->emitXML; $xml .= $bug->emitXML;
if (!$bug->error) { if (!$bug->error) {
SendSQL("UPDATE bugs SET bug_status =\"MOVED\" where bug_id=\"$id\""); my $exporterid = DBNameToIdAndCheck($exporter);
SendSQL("UPDATE bugs SET resolution =\"\" where bug_id=\"$id\"");
my $exp = $exporter; my $fieldid = GetFieldID("bug_status");
$exp =~ s/@/\@/; my $cur_status= $bug->bug_status;
my $comment = "Bug moved to http://bugscape.netscape.com/ by $exp.\n"; SendSQL("INSERT INTO bugs_activity " .
"(bug_id,who,bug_when,fieldid,oldvalue,newvalue) VALUES " .
"($id,$exporterid,now(),$fieldid,'$cur_status','RESOLVED')");
my $fieldid = GetFieldID("resolution");
my $cur_res= $bug->resolution;
SendSQL("INSERT INTO bugs_activity " .
"(bug_id,who,bug_when,fieldid,oldvalue,newvalue) VALUES " .
"($id,$exporterid,now(),$fieldid,'$cur_res','MOVED')");
SendSQL("UPDATE bugs SET bug_status =\"RESOLVED\" where bug_id=\"$id\"");
SendSQL("UPDATE bugs SET resolution =\"MOVED\" where bug_id=\"$id\"");
my $comment = "Bug moved to " . Param("move-to-url") . ".\n\n";
$comment .= "If the move succeeded, $exporter will recieve a mail\n";
$comment .= "containing the number of the new bug in the other database.\n";
$comment .= "If all went well, please mark this bug verified, and paste\n";
$comment .= "in a link to the new bug. Otherwise, reopen this bug.\n";
SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " . SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " .
"($id, " . DBNameToIdAndCheck($exporter) "($id, $exporterid, now(), " . SqlQuote($comment) . ")");
. ", now(), " . SqlQuote($comment) . ")");
print "Bug $id moved to http://bugscape.netscape.com/.<BR>\n"; print "<P>Bug $id moved to " . Param("move-to-url") . ".<BR>\n";
system("./processmail", $id, $exporter);
} }
} }
print "<P>\n"; print "<P>\n";
...@@ -106,9 +137,12 @@ my $buglist = $::FORM{'buglist'}; ...@@ -106,9 +137,12 @@ my $buglist = $::FORM{'buglist'};
$buglist =~ s/:/,/g; $buglist =~ s/:/,/g;
my $host = Param("urlbase"); my $host = Param("urlbase");
$host =~ s#http://([^/]+)/.*#$1#; $host =~ s#http://([^/]+)/.*#$1#;
my $to = "endico\@localhost"; my $to = Param("move-to-address");
$to =~ s/@/\@/;
my $msg = "To: $to\n"; my $msg = "To: $to\n";
$msg .= "From: Bugzilla <bugzilla\@$host>\n"; my $from = Param("moved-from-address");
$from =~ s/@/\@/;
$msg .= "From: Bugzilla <" . $from . ">\n";
$msg .= "Subject: Moving bug(s) $buglist\n\n"; $msg .= "Subject: Moving bug(s) $buglist\n\n";
$msg .= $xml . "\n"; $msg .= $xml . "\n";
...@@ -120,4 +154,3 @@ close SENDMAIL; ...@@ -120,4 +154,3 @@ close SENDMAIL;
my $logstr = "XML: bugs $buglist sent to $to"; my $logstr = "XML: bugs $buglist sent to $to";
Log($logstr); Log($logstr);
...@@ -255,6 +255,18 @@ if (defined $::FORM{'id'}) { ...@@ -255,6 +255,18 @@ if (defined $::FORM{'id'}) {
} }
} }
my $action = '';
if (defined $::FORM{action}) {
$action = trim($::FORM{action});
}
if ($action eq Param("move-button-text")) {
$::FORM{'buglist'} = join (":", @idlist);
do "move.pl" || die "Error executing move.cgi: $!";
PutFooter();
exit;
}
if (!defined $::FORM{'who'}) { if (!defined $::FORM{'who'}) {
$::FORM{'who'} = $::COOKIE{'Bugzilla_login'}; $::FORM{'who'} = $::COOKIE{'Bugzilla_login'};
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment