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) {
}
}
my $movers = Param("movers");
$movers =~ s/\s?,\s?/|/g;
$movers =~ s/@/\@/g;
if ($canedit || $::userid == $assignedtoid ||
$::userid == $reporterid || $::userid == $qacontactid) {
......@@ -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>";
}
$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 {
print "<INPUT TYPE=radio NAME=knob VALUE=reopen> Reopen bug<br>\n";
$knum++;
......@@ -491,14 +510,25 @@ if ($canedit || $::userid == $assignedtoid ||
print "
<INPUT TYPE=\"submit\" VALUE=\"Commit\">
<INPUT TYPE=\"reset\" VALUE=\"Reset\">
<INPUT TYPE=hidden name=form_name VALUE=process_bug>
<INPUT TYPE=\"hidden\" name=\"form_name\" VALUE=\"process_bug\">
<P>
<FONT size=\"+1\"><B>
<A HREF=\"show_activity.cgi?id=$id\">View Bug Activity</A>
&nbsp; | &nbsp;
<A HREF=\"long_list.cgi?buglist=$id\">Format For Printing</A>
</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>
<td align=right width=100%>Opened: $bug{'creation_ts'}</td></tr></table>
<HR>
......
......@@ -1277,7 +1277,6 @@ document.write(\" <input type=button value=\\\"Uncheck All\\\" onclick=\\\"SetCh
value_quote($::dontchange) . "\"></TD>
</TR>";
}
if (@::legal_keywords) {
print qq{
......@@ -1394,8 +1393,21 @@ To make changes to a bunch of bugs at once:
comment explaining what you're doing.)
<li> Click the below \"Commit\" button.
</ol></font>
<INPUT TYPE=SUBMIT VALUE=Commit>
</FORM><hr>\n";
<INPUT TYPE=SUBMIT VALUE=Commit>";
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) {
}
print qq{&nbsp;&nbsp;\n};
print qq{<NOBR><A HREF="query.cgi?$::buffer">Edit this query</A></NOBR>\n};
print "</FORM>\n";
}
PutFooter();
if ($serverpush) {
......
......@@ -560,5 +560,41 @@ DefParam("supportwatchers",
" about) another's bugs. Useful for people going on vacation, and" .
" QA folks watching particular developers' bugs",
"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;
......@@ -27,6 +27,12 @@ use Bug;
require "CGI.pl";
$::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();
sub Log {
......@@ -65,14 +71,22 @@ sub Unlock {
}
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 "If you don't see the move button, then you either aren't ";
print "logged in or aren't permitted to.";
PutFooter();
exit;
}
confirm_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";
PutHeader("Move Bugs");
print "<P>You do not have permission to move bugs<P>\n";
......@@ -88,15 +102,32 @@ foreach my $id (split(/:/, $::FORM{'buglist'})) {
my $bug = new Bug($id, $::userid);
$xml .= $bug->emitXML;
if (!$bug->error) {
SendSQL("UPDATE bugs SET bug_status =\"MOVED\" where bug_id=\"$id\"");
SendSQL("UPDATE bugs SET resolution =\"\" where bug_id=\"$id\"");
my $exp = $exporter;
$exp =~ s/@/\@/;
my $comment = "Bug moved to http://bugscape.netscape.com/ by $exp.\n";
my $exporterid = DBNameToIdAndCheck($exporter);
my $fieldid = GetFieldID("bug_status");
my $cur_status= $bug->bug_status;
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 " .
"($id, " . DBNameToIdAndCheck($exporter)
. ", now(), " . SqlQuote($comment) . ")");
print "Bug $id moved to http://bugscape.netscape.com/.<BR>\n";
"($id, $exporterid, now(), " . SqlQuote($comment) . ")");
print "<P>Bug $id moved to " . Param("move-to-url") . ".<BR>\n";
system("./processmail", $id, $exporter);
}
}
print "<P>\n";
......@@ -106,9 +137,12 @@ my $buglist = $::FORM{'buglist'};
$buglist =~ s/:/,/g;
my $host = Param("urlbase");
$host =~ s#http://([^/]+)/.*#$1#;
my $to = "endico\@localhost";
my $to = Param("move-to-address");
$to =~ s/@/\@/;
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 .= $xml . "\n";
......@@ -120,4 +154,3 @@ close SENDMAIL;
my $logstr = "XML: bugs $buglist sent to $to";
Log($logstr);
......@@ -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'}) {
$::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