2002-01-20 04:44:52 +03:00
|
|
|
#!/usr/bonsaitools/bin/perl -wT
|
2000-06-20 21:14:00 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
|
|
|
#
|
|
|
|
# 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 the Bugzilla Bug Tracking System.
|
|
|
|
#
|
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
|
|
|
# Contributor(s): Dawn Endico <endico@mozilla.org>
|
|
|
|
# Terry Weissman <terry@mozilla.org>
|
|
|
|
|
|
|
|
use strict;
|
2002-01-20 04:44:52 +03:00
|
|
|
|
|
|
|
use lib qw(.);
|
|
|
|
|
2000-06-20 21:14:00 +04:00
|
|
|
require "CGI.pl";
|
2002-09-05 02:43:38 +04:00
|
|
|
|
|
|
|
use vars qw($userid %COOKIE);
|
|
|
|
|
|
|
|
use Bug;
|
|
|
|
|
2000-06-20 21:14:00 +04:00
|
|
|
$::lockcount = 0;
|
|
|
|
|
2000-07-14 03:12:52 +04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2000-06-20 21:14:00 +04:00
|
|
|
ConnectToDatabase();
|
2002-06-17 13:39:00 +04:00
|
|
|
confirm_login();
|
2000-06-20 21:14:00 +04:00
|
|
|
|
|
|
|
sub Log {
|
|
|
|
my ($str) = (@_);
|
|
|
|
Lock();
|
|
|
|
open(FID, ">>data/maillog") || die "Can't write to data/maillog";
|
|
|
|
print FID time2str("%D %H:%M", time()) . ": $str\n";
|
|
|
|
close FID;
|
|
|
|
Unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
sub Lock {
|
|
|
|
if ($::lockcount <= 0) {
|
|
|
|
$::lockcount = 0;
|
2002-04-07 07:56:46 +04:00
|
|
|
open(LOCKFID, ">>data/maillock") || die "Can't open data/maillock: $!";
|
2000-06-20 21:14:00 +04:00
|
|
|
my $val = flock(LOCKFID,2);
|
|
|
|
if (!$val) { # '2' is magic 'exclusive lock' const.
|
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
print "Lock failed: $val\n";
|
|
|
|
}
|
|
|
|
chmod 0666, "data/maillock";
|
|
|
|
}
|
|
|
|
$::lockcount++;
|
|
|
|
}
|
|
|
|
|
|
|
|
sub Unlock {
|
|
|
|
$::lockcount--;
|
|
|
|
if ($::lockcount <= 0) {
|
|
|
|
flock(LOCKFID,8); # '8' is magic 'unlock' const.
|
|
|
|
close LOCKFID;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( !defined $::FORM{'buglist'} ) {
|
2000-07-14 03:12:52 +04:00
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("Move Bugs");
|
|
|
|
print "Move bugs either from the bug display page or perform a ";
|
2000-06-20 21:14:00 +04:00
|
|
|
print "<A HREF=\"query.cgi\">query</A> and change several bugs at once.\n";
|
2000-07-14 03:12:52 +04:00
|
|
|
print "If you don't see the move button, then you either aren't ";
|
|
|
|
print "logged in or aren't permitted to.";
|
|
|
|
PutFooter();
|
2000-06-20 21:14:00 +04:00
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $exporter = $::COOKIE{"Bugzilla_login"};
|
2000-07-14 03:12:52 +04:00
|
|
|
my $movers = Param("movers");
|
|
|
|
$movers =~ s/\w?,\w?/|/g;
|
|
|
|
$movers =~ s/@/\@/g;
|
|
|
|
unless ($exporter =~ /($movers)/) {
|
2000-06-20 21:14:00 +04:00
|
|
|
print "Content-type: text/html\n\n";
|
|
|
|
PutHeader("Move Bugs");
|
|
|
|
print "<P>You do not have permission to move bugs<P>\n";
|
|
|
|
PutFooter();
|
|
|
|
exit;
|
|
|
|
}
|
|
|
|
|
|
|
|
my $xml = "";
|
2002-08-29 13:25:54 +04:00
|
|
|
$xml .= Bug::XML_Header( Param("urlbase"), $Bugzilla::Config::VERSION,
|
2000-06-20 21:14:00 +04:00
|
|
|
Param("maintainer"), $exporter );
|
|
|
|
print "<P>\n";
|
|
|
|
foreach my $id (split(/:/, $::FORM{'buglist'})) {
|
|
|
|
my $bug = new Bug($id, $::userid);
|
|
|
|
$xml .= $bug->emitXML;
|
|
|
|
if (!$bug->error) {
|
2000-07-14 03:12:52 +04:00
|
|
|
my $exporterid = DBNameToIdAndCheck($exporter);
|
|
|
|
|
|
|
|
my $fieldid = GetFieldID("bug_status");
|
|
|
|
my $cur_status= $bug->bug_status;
|
|
|
|
SendSQL("INSERT INTO bugs_activity " .
|
2001-07-20 19:18:30 +04:00
|
|
|
"(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
|
2000-07-14 03:12:52 +04:00
|
|
|
"($id,$exporterid,now(),$fieldid,'$cur_status','RESOLVED')");
|
2001-06-01 06:07:28 +04:00
|
|
|
$fieldid = GetFieldID("resolution");
|
2000-07-14 03:12:52 +04:00
|
|
|
my $cur_res= $bug->resolution;
|
|
|
|
SendSQL("INSERT INTO bugs_activity " .
|
2001-07-20 19:18:30 +04:00
|
|
|
"(bug_id,who,bug_when,fieldid,removed,added) VALUES " .
|
2000-07-14 03:12:52 +04:00
|
|
|
"($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\"");
|
|
|
|
|
2002-02-06 07:34:10 +03:00
|
|
|
my $comment = "";
|
|
|
|
if (defined $::FORM{'comment'} && $::FORM{'comment'} !~ /^\s*$/) {
|
|
|
|
$comment .= $::FORM{'comment'} . "\n\n";
|
|
|
|
}
|
|
|
|
$comment .= "Bug moved to " . Param("move-to-url") . ".\n\n";
|
2001-05-09 22:32:35 +04:00
|
|
|
$comment .= "If the move succeeded, $exporter will receive a mail\n";
|
2000-07-14 03:12:52 +04:00
|
|
|
$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";
|
2000-06-20 21:14:00 +04:00
|
|
|
SendSQL("INSERT INTO longdescs (bug_id, who, bug_when, thetext) VALUES " .
|
2000-07-14 03:12:52 +04:00
|
|
|
"($id, $exporterid, now(), " . SqlQuote($comment) . ")");
|
|
|
|
|
|
|
|
print "<P>Bug $id moved to " . Param("move-to-url") . ".<BR>\n";
|
|
|
|
system("./processmail", $id, $exporter);
|
2000-06-20 21:14:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
print "<P>\n";
|
|
|
|
$xml .= Bug::XML_Footer;
|
|
|
|
|
|
|
|
my $buglist = $::FORM{'buglist'};
|
|
|
|
$buglist =~ s/:/,/g;
|
|
|
|
my $host = Param("urlbase");
|
|
|
|
$host =~ s#http://([^/]+)/.*#$1#;
|
2000-07-14 03:12:52 +04:00
|
|
|
my $to = Param("move-to-address");
|
|
|
|
$to =~ s/@/\@/;
|
2000-06-20 21:14:00 +04:00
|
|
|
my $msg = "To: $to\n";
|
2000-07-14 03:12:52 +04:00
|
|
|
my $from = Param("moved-from-address");
|
|
|
|
$from =~ s/@/\@/;
|
|
|
|
$msg .= "From: Bugzilla <" . $from . ">\n";
|
2000-06-27 00:29:10 +04:00
|
|
|
$msg .= "Subject: Moving bug(s) $buglist\n\n";
|
2000-06-20 21:14:00 +04:00
|
|
|
$msg .= $xml . "\n";
|
|
|
|
|
|
|
|
open(SENDMAIL,
|
2002-02-17 11:22:31 +03:00
|
|
|
"|/usr/lib/sendmail -ODeliveryMode=background -t -i") ||
|
2000-06-20 21:14:00 +04:00
|
|
|
die "Can't open sendmail";
|
|
|
|
print SENDMAIL $msg;
|
|
|
|
close SENDMAIL;
|
|
|
|
|
|
|
|
my $logstr = "XML: bugs $buglist sent to $to";
|
|
|
|
Log($logstr);
|