]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 556422: Move the existing bug-moving functionality into an extension
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Fri, 18 Jun 2010 20:48:21 +0000 (13:48 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Fri, 18 Jun 2010 20:48:21 +0000 (13:48 -0700)
called OldBugMove.
r=dkl, a=mkanat

25 files changed:
Bugzilla/Bug.pm
Bugzilla/Comment.pm
Bugzilla/Constants.pm
Bugzilla/DB.pm
Bugzilla/Field/ChoiceInterface.pm
Bugzilla/User.pm
extensions/OldBugMove/Config.pm [new file with mode: 0644]
extensions/OldBugMove/Extension.pm [new file with mode: 0644]
extensions/OldBugMove/disabled [new file with mode: 0644]
extensions/OldBugMove/lib/Params.pm [moved from Bugzilla/Config/BugMove.pm with 75% similarity]
extensions/OldBugMove/template/en/default/admin/params/oldbugmove.html.tmpl [new file with mode: 0644]
extensions/OldBugMove/template/en/default/hook/bug/edit-after_comment_textarea.html.tmpl [new file with mode: 0644]
extensions/OldBugMove/template/en/default/hook/bug/format_comment-type.txt.tmpl [new file with mode: 0644]
extensions/OldBugMove/template/en/default/hook/global/user-error-auth_failure_action.html.tmpl [new file with mode: 0644]
extensions/OldBugMove/template/en/default/hook/global/user-error-errors.html.tmpl [new file with mode: 0644]
importxml.pl
process_bug.cgi
template/en/default/admin/params/bugmove.html.tmpl [deleted file]
template/en/default/bug/edit.html.tmpl
template/en/default/bug/format_comment.txt.tmpl
template/en/default/global/code-error.html.tmpl
template/en/default/global/field-descs.none.tmpl
template/en/default/global/user-error.html.tmpl
template/en/default/list/edit-multiple.html.tmpl
template/en/default/pages/fields.html.tmpl

index 3fb1dcf9817ece438662ead7171ad77479476285..6df7363d5c497f8a7022a0ef6d992090f4de9d0f 100644 (file)
@@ -2410,10 +2410,6 @@ sub set_resolution {
     my $new_res = $self->resolution;
 
     if ($new_res ne $old_res) {
-        # MOVED has a special meaning and can only be used when
-        # really moving bugs to another installation.
-        ThrowCodeError('no_manual_moved') if ($new_res eq 'MOVED' && !$params->{moving});
-
         # Clear the dup_id if we're leaving the dup resolution.
         if ($old_res eq 'DUPLICATE') {
             $self->_clear_dup_id();
@@ -3278,7 +3274,6 @@ sub user {
     return {} if $self->{'error'};
 
     my $user = Bugzilla->user;
-    my $canmove = Bugzilla->params->{'move-enabled'} && $user->is_mover;
 
     my $prod_id = $self->{'product_id'};
 
@@ -3293,8 +3288,7 @@ sub user {
     my $isreporter = $user->id
                      && $user->id == $self->{reporter_id};
 
-    $self->{'user'} = {canmove    => $canmove,
-                       canconfirm => $canconfirm,
+    $self->{'user'} = {canconfirm => $canconfirm,
                        canedit    => $canedit,
                        isreporter => $isreporter};
     return $self->{'user'};
@@ -3326,10 +3320,6 @@ sub choices {
     my $resolution_field = new Bugzilla::Field({ name => 'resolution' });
     # Don't include the empty resolution in drop-downs.
     my @resolutions = grep($_->name, @{ $resolution_field->legal_values });
-    # And don't include MOVED in the list unless the bug is already MOVED.
-    if ($self->resolution ne 'MOVED') {
-        @resolutions= grep { $_->name ne 'MOVED' } @resolutions;
-    }
     $choices{'resolution'} = \@resolutions;
 
     $self->{'choices'} = \%choices;
index be10329d9d3c1ff1fc76cbe13cec9520b83bf385..074f28dd67f93ada6e40d56ca3cdb71e09c9d205 100644 (file)
@@ -179,9 +179,6 @@ sub _check_extra_data {
         if (!defined $extra_data) {
             ThrowCodeError('comment_extra_data_required', { type => $type });
         }
-        if ($type == CMT_MOVED_TO) {
-            $extra_data = Bugzilla::User->check($extra_data)->login;
-        }
         elsif ($type == CMT_ATTACHMENT_CREATED 
                or $type == CMT_ATTACHMENT_UPDATED) 
         {
index d4e8782c6db59f50a4d888567a3ea066b4fa21e3..55ef4a0e375a0e2edd8aa662ea3dfe97cef4f0ad 100644 (file)
@@ -92,7 +92,6 @@ use File::Basename;
     CMT_NORMAL
     CMT_DUPE_OF
     CMT_HAS_DUPE
-    CMT_MOVED_TO
     CMT_ATTACHMENT_CREATED
     CMT_ATTACHMENT_UPDATED
 
@@ -299,7 +298,7 @@ use constant CMT_NORMAL => 0;
 use constant CMT_DUPE_OF => 1;
 use constant CMT_HAS_DUPE => 2;
 # Type 3 was CMT_POPULAR_VOTES, which moved to the Voting extension.
-use constant CMT_MOVED_TO => 4;
+# Type 4 was CMT_MOVED_TO, which moved to the OldBugMove extension.
 use constant CMT_ATTACHMENT_CREATED => 5;
 use constant CMT_ATTACHMENT_UPDATED => 6;
 
index 79a5639ddd20a9703a3cdfa18f0d6da2c56836e3..8b8d74c90d5dc145fbfe85a3ba7dc7c2d0f7a123 100644 (file)
@@ -70,8 +70,7 @@ use constant ENUM_DEFAULTS => {
     rep_platform => ["All","PC","Macintosh","Other"],
     bug_status   => ["UNCONFIRMED","NEW","ASSIGNED","REOPENED","RESOLVED",
                      "VERIFIED","CLOSED"],
-    resolution   => ["","FIXED","INVALID","WONTFIX", "DUPLICATE","WORKSFORME",
-                     "MOVED"],
+    resolution   => ["","FIXED","INVALID","WONTFIX", "DUPLICATE","WORKSFORME"],
 };
 
 #####################################################################
index 5b796270b826e082e1ac6f38f36fa22800af876c..a718377c24bdd42097f616cca2a892a170a9fa80 100644 (file)
@@ -99,7 +99,7 @@ sub is_static {
     # If we need to special-case Resolution for *anything* else, it should
     # get its own subclass.
     if ($self->field->name eq 'resolution') {
-        return grep($_ eq $self->name, ('', 'FIXED', 'MOVED', 'DUPLICATE'))
+        return grep($_ eq $self->name, ('', 'FIXED', 'DUPLICATE'))
                ? 1 : 0;
     }
     elsif ($self->field->custom) {
index 815b435fd5d0fe0c308e00a77f6e1f560e17bba1..aa01d93a589b9058c85717906aa32ca2291bb8d4 100644 (file)
@@ -1639,17 +1639,6 @@ sub mail_settings {
     return $self->{'mail_settings'};
 }
 
-sub is_mover {
-    my $self = shift;
-
-    if (!defined $self->{'is_mover'}) {
-        my @movers = map { trim($_) } split(',', Bugzilla->params->{'movers'});
-        $self->{'is_mover'} = ($self->id
-                               && grep { $_ eq $self->login } @movers);
-    }
-    return $self->{'is_mover'};
-}
-
 sub is_insider {
     my $self = shift;
 
diff --git a/extensions/OldBugMove/Config.pm b/extensions/OldBugMove/Config.pm
new file mode 100644 (file)
index 0000000..e401260
--- /dev/null
@@ -0,0 +1,25 @@
+# -*- 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 OldBugMove Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Everything Solved, Inc.
+# Portions created by the Initial Developer is Copyright (C) 2010 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Max Kanat-Alexander <mkanat@bugzilla.org>
+
+package Bugzilla::Extension::OldBugMove;
+use strict;
+use constant NAME => 'OldBugMove';
+__PACKAGE__->NAME;
diff --git a/extensions/OldBugMove/Extension.pm b/extensions/OldBugMove/Extension.pm
new file mode 100644 (file)
index 0000000..c6b5659
--- /dev/null
@@ -0,0 +1,214 @@
+# -*- 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 OldBugMove Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Everything Solved, Inc.
+# Portions created by the Initial Developer are Copyright (C) 2010 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Max Kanat-Alexander <mkanat@bugzilla.org>
+
+package Bugzilla::Extension::OldBugMove;
+use strict;
+use base qw(Bugzilla::Extension);
+use Bugzilla::Constants;
+use Bugzilla::Error;
+use Bugzilla::Field::Choice;
+use Bugzilla::Mailer;
+use Bugzilla::User;
+use Bugzilla::Util qw(trim);
+
+use Scalar::Util qw(blessed);
+use Storable qw(dclone);
+
+# This is 4 because that's what it originally was when this code was
+# a part of Bugzilla.
+use constant CMT_MOVED_TO => 4;
+
+our $VERSION = BUGZILLA_VERSION;
+
+sub install_update_db {
+    my $reso_type = Bugzilla::Field::Choice->type('resolution');
+    my $moved_reso = $reso_type->new({ name => 'MOVED' });
+    # We make the MOVED resolution inactive, so that it doesn't show up
+    # as a valid drop-down option.
+    if ($moved_reso) {
+        $moved_reso->set_is_active(0);
+        $moved_reso->update();
+    }
+    else {
+        print "Creating the MOVED resolution...\n";
+        $reso_type->create(
+           { value   => 'MOVED', sortkey => '30000', isactive => 0 });
+    }
+}
+
+sub config_add_panels {
+    my ($self, $args) = @_;
+    my $modules = $args->{'panel_modules'};
+    $modules->{'OldBugMove'} = 'Bugzilla::Extension::OldBugMove::Params';
+}
+
+sub template_before_create {
+    my ($self, $args) = @_;
+    my $config = $args->{config};
+
+    my $constants = $config->{CONSTANTS};
+    $constants->{CMT_MOVED_TO} = CMT_MOVED_TO;
+
+    my $vars = $config->{VARIABLES};
+    $vars->{oldbugmove_user_is_mover} = \&_user_is_mover;
+}
+
+sub object_before_delete {
+    my ($self, $args) = @_;
+    my $object = $args->{'object'};
+    if ($object->isa('Bugzilla::Field::Choice::resolution')) {
+        if ($object->name eq 'MOVED') {
+            ThrowUserError('oldbugmove_no_delete_moved');
+        }
+    }
+}
+
+sub object_before_set {
+    my ($self, $args) = @_;
+    my ($object, $field) = @$args{qw(object field)};
+    if ($field eq 'resolution' and $object->isa('Bugzilla::Bug')) {
+        # Store the old value so that end_of_set can check it.
+        $object->{'_oldbugmove_old_resolution'} = $object->resolution;
+    }
+}
+
+sub object_end_of_set {
+    my ($self, $args) = @_;
+    my ($object, $field) = @$args{qw(object field)};
+    if ($field eq 'resolution' and $object->isa('Bugzilla::Bug')) {
+        my $old_value = delete $object->{'_oldbugmove_old_resolution'};
+        return if $old_value eq $object->resolution;
+        if ($object->resolution eq 'MOVED') {
+            $object->add_comment('', { type => CMT_MOVED_TO,
+                                       extra_data => Bugzilla->user->login });
+        }
+    }
+}
+
+sub object_end_of_set_all {
+    my ($self, $args) = @_;
+    my $object = $args->{'object'};
+
+    if ($object->isa('Bugzilla::Bug') and _bug_is_moving($object)) {
+        my $new_status = Bugzilla->params->{'duplicate_or_move_bug_status'};
+        $object->set_bug_status($new_status, { resolution => 'MOVED' });
+    }
+}
+
+sub object_validators {
+    my ($self, $args) = @_;
+    my ($class, $validators) = @$args{qw(class validators)};
+    if ($class->isa('Bugzilla::Comment')) {
+        my $extra_data_validator = $validators->{extra_data};
+        $validators->{extra_data} = 
+            sub { _check_comment_extra_data($extra_data_validator, @_) };
+    }
+    elsif ($class->isa('Bugzilla::Bug')) {
+        my $reso_validator = $validators->{resolution};
+        $validators->{resolution} =
+            sub { _check_bug_resolution($reso_validator, @_) };
+    }
+}
+
+sub _check_bug_resolution {
+    my $original_validator = shift;
+    my ($invocant, $resolution) = @_;
+
+    if ($resolution eq 'MOVED' and !_bug_is_moving($invocant)) {
+        # MOVED has a special meaning and can only be used when
+        # really moving bugs to another installation.
+        ThrowUserError('oldbugmove_no_manual_move');
+    }
+
+    return $original_validator->(@_);
+}
+
+sub _check_comment_extra_data {
+    my $original_validator = shift;
+    my ($invocant, $extra_data, undef, $params) = @_;
+    my $type = blessed($invocant) ? $invocant->type : $params->{type};
+
+    if ($type == CMT_MOVED_TO) {
+        return Bugzilla::User->check($extra_data)->login;
+    }
+    return $original_validator->(@_);
+}
+
+sub bug_end_of_update {
+    my ($self, $args) = @_;
+    my ($bug, $old_bug, $changes) = @$args{qw(bug old_bug changes)};
+    if (defined $changes->{'resolution'}
+        and $changes->{'resolution'}->[1] eq 'MOVED')
+    {
+        $self->_move_bug($bug, $old_bug);
+    }
+}
+
+sub _move_bug {
+    my ($self, $bug, $old_bug) = @_;
+
+    my $dbh = Bugzilla->dbh;
+    my $template = Bugzilla->template;
+
+    _user_is_mover(Bugzilla->user) 
+        or ThrowUserError("auth_failure", { action => 'move',
+                                            object => 'bugs' });
+
+    # Don't export the new status and resolution. We want the current
+    # ones.
+    local $Storable::forgive_me = 1;
+    my $export_me = dclone($bug);
+    $export_me->{bug_status} = $old_bug->bug_status;
+    delete $export_me->{status};
+    $export_me->{resolution} = $old_bug->resolution;
+
+    # Prepare and send all data about these bugs to the new database
+    my $to = Bugzilla->params->{'move-to-address'};
+    $to =~ s/@/\@/;
+    my $from = Bugzilla->params->{'mailfrom'};
+    $from =~ s/@/\@/;
+    my $msg = "To: $to\n";
+    $msg .= "From: Bugzilla <" . $from . ">\n";
+    $msg .= "Subject: Moving bug " . $bug->id . "\n\n";
+    my @fieldlist = (Bugzilla::Bug->fields, 'group', 'long_desc',
+                     'attachment', 'attachmentdata');
+    my %displayfields = map { $_ => 1 } @fieldlist;
+    my $vars = { bugs => [$export_me], displayfields => \%displayfields };
+    $template->process("bug/show.xml.tmpl", $vars, \$msg)
+      || ThrowTemplateError($template->error());
+    $msg .= "\n";
+    MessageToMTA($msg);
+}
+
+sub _bug_is_moving {
+    my $bug = shift;
+    my $oldbugmove = Bugzilla->input_params->{"oldbugmove_" . $bug->id};
+    return $oldbugmove ? 1 : 0;
+}
+
+sub _user_is_mover {
+    my $user = shift;
+
+    my @movers = map { trim($_) } split(',', Bugzilla->params->{'movers'});
+    return ($user->id and grep($_ eq $user->login, @movers)) ? 1 : 0;
+}
+
+__PACKAGE__->NAME;
diff --git a/extensions/OldBugMove/disabled b/extensions/OldBugMove/disabled
new file mode 100644 (file)
index 0000000..e69de29
similarity index 75%
rename from Bugzilla/Config/BugMove.pm
rename to extensions/OldBugMove/lib/Params.pm
index 2d973d8cab141bbbe125b81026ba63cbe0d21f0e..a8617e347ce8376261f838e9ebfa147d79964fca 100644 (file)
@@ -29,7 +29,7 @@
 #                 Frédéric Buclin <LpSolit@gmail.com>
 #
 
-package Bugzilla::Config::BugMove;
+package Bugzilla::Extension::OldBugMove::Params;
 
 use strict;
 
@@ -37,21 +37,7 @@ use Bugzilla::Config::Common;
 
 our $sortkey = 700;
 
-sub get_param_list {
-  my $class = shift;
-  my @param_list = (
-  {
-   name => 'move-enabled',
-   type => 'b',
-   default => 0
-  },
-
-  {
-   name => 'move-button-text',
-   type => 't',
-   default => 'Move To Bugscape'
-  },
-
+use constant get_param_list => (
   {
    name => 'move-to-url',
    type => 't',
@@ -64,30 +50,11 @@ sub get_param_list {
    default => 'bugzilla-import'
   },
 
-  {
-   name => 'moved-from-address',
-   type => 't',
-   default => 'bugzilla-admin'
-  },
-
   {
    name => 'movers',
    type => 't',
    default => ''
   },
-
-  {
-   name => 'moved-default-product',
-   type => 't',
-   default => ''
-  },
-
-  {
-   name => 'moved-default-component',
-   type => 't',
-   default => ''
-  } );
-  return @param_list;
-}
+);
 
 1;
diff --git a/extensions/OldBugMove/template/en/default/admin/params/oldbugmove.html.tmpl b/extensions/OldBugMove/template/en/default/admin/params/oldbugmove.html.tmpl
new file mode 100644 (file)
index 0000000..ce588b1
--- /dev/null
@@ -0,0 +1,40 @@
+[%# 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): Dave Miller <justdave@bugzilla.org>
+  #                 Frédéric Buclin <LpSolit@gmail.com>
+  #%]
+[%
+   title = "$terms.Bug Moving"
+   desc = "Set up parameters to move $terms.bugs to/from another installation"
+%]
+
+[% param_descs = {
+
+  "move-to-url" => 
+    "The URL of the database we allow some of our $terms.bugs to"
+    _ " be moved to.",
+
+  "move-to-address" => 
+    "To move ${terms.bugs}, an email is sent to the target database."
+    _ " This is the email address that that database uses to listen"
+    _ " for incoming ${terms.bugs}.",
+
+  movers => 
+    "A list of people with permission to move $terms.bugs ",
+
+} %]
diff --git a/extensions/OldBugMove/template/en/default/hook/bug/edit-after_comment_textarea.html.tmpl b/extensions/OldBugMove/template/en/default/hook/bug/edit-after_comment_textarea.html.tmpl
new file mode 100644 (file)
index 0000000..71fe065
--- /dev/null
@@ -0,0 +1,27 @@
+[%# 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 Everything Solved, Inc.
+  # Portions created by the Initial Developer are Copyright (C) 2010
+  # the Initial Developer. All Rights Reserved.
+  #
+  # Contributor(s):
+  #   Max Kanat-Alexander <mkanat@bugzilla.org>
+  #%]
+
+[% IF oldbugmove_user_is_mover(user) AND bug.resolution != 'MOVED' %]
+  <br>
+  <input type="submit" name="oldbugmove_[% bug.id FILTER html %]"
+         id="oldbugmove" 
+         value="Move [% terms.Bug FILTER html %] to 
+                [%= Param('move-to-url') FILTER html %]">
+[% END %]
diff --git a/extensions/OldBugMove/template/en/default/hook/bug/format_comment-type.txt.tmpl b/extensions/OldBugMove/template/en/default/hook/bug/format_comment-type.txt.tmpl
new file mode 100644 (file)
index 0000000..1ce8e36
--- /dev/null
@@ -0,0 +1,29 @@
+[%# 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 Everything Solved, Inc.
+  # Portions created by the Initial Developer are Copyright (C) 2010
+  # the Initial Developer. All Rights Reserved.
+  #
+  # Contributor(s):
+  #   Max Kanat-Alexander <mkanat@bugzilla.org>
+  #%]
+
+[% IF comment.type == constants.CMT_MOVED_TO %]
+[% comment.body %]
+
+[%+ terms.Bug %] moved to [% Param("move-to-url") %].
+If the move succeeded, [% comment.extra_data FILTER email %] will receive a mail
+containing the number of the new [% terms.bug %] in the other database.
+If all went well, please paste in a link to the new [% terms.bug %]. 
+Otherwise, reopen this [% terms.bug %].
+[% END %]
diff --git a/extensions/OldBugMove/template/en/default/hook/global/user-error-auth_failure_action.html.tmpl b/extensions/OldBugMove/template/en/default/hook/global/user-error-auth_failure_action.html.tmpl
new file mode 100644 (file)
index 0000000..5850097
--- /dev/null
@@ -0,0 +1,23 @@
+[%# 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 Everything Solved, Inc.
+  # Portions created by the Initial Developer are Copyright (C) 2010
+  # the Initial Developer. All Rights Reserved.
+  #
+  # Contributor(s):
+  #   Max Kanat-Alexander <mkanat@bugzilla.org>
+  #%]
+
+[% IF action == "move" %]
+  move
+[% END %]
diff --git a/extensions/OldBugMove/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/OldBugMove/template/en/default/hook/global/user-error-errors.html.tmpl
new file mode 100644 (file)
index 0000000..9351177
--- /dev/null
@@ -0,0 +1,29 @@
+[%# 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 Everything Solved, Inc.
+  # Portions created by the Initial Developer are Copyright (C) 2010
+  # the Initial Developer. All Rights Reserved.
+  #
+  # Contributor(s):
+  #   Max Kanat-Alexander <mkanat@bugzilla.org>
+  #%]
+
+[% IF error == "oldbugmove_no_delete_moved" %]
+    As long as the OldBugMove extension is active, you cannot
+    delete the [%+ display_value("resolution", "MOVED") FILTER html %]
+    resolution.
+[% ELSIF error == "oldbugmove_no_manual_move" %]
+    You cannot set the resolution of [% terms.abug %] to 
+    [%+ display_value("resolution", "MOVED") FILTER html %] without
+    moving the [% terms.bug %].
+[% END %]
index 33d3857910b8b4b53ff8af7b26bb74b7e0b5a994..142470906d39b1a9380a6dc128b13aede8859cba 100755 (executable)
@@ -95,12 +95,15 @@ my $debug = 0;
 my $mail  = '';
 my $attach_path = '';
 my $help  = 0;
+my ($default_product_name, $default_component_name);
 
 my $result = GetOptions(
     "verbose|debug+" => \$debug,
     "mail|sendmail!" => \$mail,
     "attach_path=s"  => \$attach_path,
-    "help|?"         => \$help
+    "help|?"         => \$help,
+    "product=s"      => \$default_product_name,
+    "component=s"    => \$default_component_name,
 );
 
 pod2usage(0) if $help;
@@ -117,6 +120,9 @@ my $dbh = Bugzilla->dbh;
 my $params = Bugzilla->params;
 my ($timestamp) = $dbh->selectrow_array("SELECT NOW()");
 
+$default_product_name = '' if !defined $default_product_name;
+$default_component_name = '' if !defined $default_component_name;
+
 ###############################################################################
 # Helper sub routines                                                         #
 ###############################################################################
@@ -126,7 +132,7 @@ sub MailMessage {
     my $subject    = shift;
     my $message    = shift;
     my @recipients = @_;
-    my $from   = $params->{"moved-from-address"};
+    my $from   = $params->{"mailfrom"};
     $from =~ s/@/\@/g;
 
     foreach my $to (@recipients){
@@ -316,22 +322,8 @@ sub init() {
     }
     Error( "no maintainer", "REOPEN", $exporter ) unless ($maintainer);
     Error( "no exporter",   "REOPEN", $exporter ) unless ($exporter);
-    Error( "bug importing is disabled here", undef, $exporter ) unless ( $params->{"move-enabled"} );
     Error( "invalid exporter: $exporter", "REOPEN", $exporter ) if ( !login_to_id($exporter) );
     Error( "no urlbase set", "REOPEN", $exporter ) unless ($urlbase);
-    my $def_product =
-        new Bugzilla::Product( { name => $params->{"moved-default-product"} } )
-        || Error("an invalid default product was defined for the target DB. " .
-                  $params->{"maintainer"} . " needs to fix the definitions of " .
-                 "moved-default-product. \n", "REOPEN", $exporter);
-    my $def_component = new Bugzilla::Component(
-        {
-            product => $def_product,
-            name    => $params->{"moved-default-component"}
-        })
-    || Error("an invalid default component was defined for the target DB. " .
-             $params->{"maintainer"} . " needs to fix the definitions of " .
-             "moved-default-component.\n", "REOPEN", $exporter);
 }
     
 
@@ -634,49 +626,34 @@ sub process_bug {
     push( @query,  "reporter_accessible" );
     push( @values, $bug_fields{'reporter_accessible'} ? 1 : 0 );
 
-    # Product and Component if there is no valid default product and
-    # component defined in the parameters, we wouldn't be here
-    my $def_product =
-      new Bugzilla::Product( { name => $params->{"moved-default-product"} } );
-    my $def_component = new Bugzilla::Component(
-        {
-            product => $def_product,
-            name    => $params->{"moved-default-component"}
-        }
-    );
-    my $product;
-    my $component;
-
-    if ( defined $bug_fields{'product'} ) {
-        $product = new Bugzilla::Product( { name => $bug_fields{'product'} } );
-        unless ($product) {
-            $product = $def_product;
-            $err .= "Unknown Product " . $bug_fields{'product'} . "\n";
-            $err .= "   Using default product set in Parameters \n";
-        }
-    }
-    else {
-        $product = $def_product;
+    my $product = new Bugzilla::Product(
+        { name => $bug_fields{'product'} || '' });
+    if (!$product) {
+        $err .= "Unknown Product " . $bug_fields{'product'} . "\n";
+        $err .= "   Using default product set at the command line.\n";
+        $product = new Bugzilla::Product({ name => $default_product_name })
+            or Error("an invalid default product was defined for the target"
+                     . " DB. " . $params->{"maintainer"} . " needs to specify "
+                     . "--product when calling importxml.pl", "REOPEN", 
+                     $exporter);
     }
-    if ( defined $bug_fields{'component'} ) {
-        $component = new Bugzilla::Component(
-            {
-                product => $product,
-                name    => $bug_fields{'component'}
-            }
-        );
-        unless ($component) {
-            $component = $def_component;
-            $product   = $def_product;
-            $err .= "Unknown Component " . $bug_fields{'component'} . "\n";
-            $err .= "   Using default product and component set ";
-            $err .= "in Parameters \n";
+    my $component = new Bugzilla::Component({
+        product => $product, name => $bug_fields{'component'} || '' });
+    if (!$component) {
+        $err .= "Unknown Component " . $bug_fields{'component'} . "\n";
+        $err .= "   Using default product and component set ";
+        $err .= "at the command line.\n";
+
+        $product = new Bugzilla::Product({ name => $default_product_name });
+        $component = new Bugzilla::Component({
+           name => $default_component_name, product => $product });
+        if (!$component) {
+            Error("an invalid default component was defined for the target" 
+                  . " DB. ".  $params->{"maintainer"} . " needs to specify " 
+                  . "--component when calling importxml.pl", "REOPEN", 
+                  $exporter);
         }
     }
-    else {
-        $component = $def_component;
-        $product   = $def_product;
-    }
 
     my $prod_id = $product->id;
     my $comp_id = $component->id;
@@ -927,9 +904,9 @@ sub process_bug {
     # that might not yet be in the database we have no way of populating
     # this table. Change the resolution instead.
     if ( $valid_res  && ( $bug_fields{'resolution'} eq "DUPLICATE" ) ) {
-        $resolution = "MOVED";
+        $resolution = "INVALID";
         $err .= "This bug was marked DUPLICATE in the database ";
-        $err .= "it was moved from.\n    Changing resolution to \"MOVED\"\n";
+        $err .= "it was moved from.\n    Changing resolution to \"INVALID\"\n";
     } 
 
     # If there is at least 1 initial bug status different from UNCO, use it,
@@ -1005,8 +982,8 @@ sub process_bug {
                }
                if(!$valid_res){
                    $err .= "Unknown resolution \"$resolution\".\n";
-                   $err .= "   Setting resolution to MOVED\n";
-                   $resolution = "MOVED";
+                   $err .= "   Setting resolution to INVALID\n";
+                   $resolution = "INVALID";
                }
             }   
         }
@@ -1346,31 +1323,38 @@ importxml - Import bugzilla bug data from xml.
 
 =head1 SYNOPSIS
 
-    importxml.pl [options] [file ...]
-
- Options:
-       -? --help        brief help message
-       -v --verbose     print error and debug information. 
-                        Multiple -v increases verbosity
-       -m --sendmail    send mail to recipients with log of bugs imported
-       --attach_path    The path to the attachment files.
-                        (Required if encoding="filename" is used for attachments.)
+ importxml.pl [options] [file ...]
 
 =head1 OPTIONS
 
-=over 8
+=over
 
 =item B<-?>
 
-    Print a brief help message and exits.
+Print a brief help message and exit.
 
 =item B<-v>
 
-    Print error and debug information. Mulltiple -v increases verbosity
+Print error and debug information. Mulltiple -v increases verbosity
+
+=item B<-m> B<--sendmail>
+
+Send mail to exporter with a log of bugs imported and any errors.
+
+=item B<--attach_path>
+
+The path to the attachment files. (Required if encoding="filename"
+is used for attachments.)
+
+=item B<--product=name>
+
+The product to put the bug in if the product specified in the
+XML doesn't exist.
 
-=item B<-m>
+=item B<--component=name>
 
-    Send mail to exporter with a log of bugs imported and any errors.
+The component to put the bug in if the component specified in the
+XML doesn't exist.
 
 =back
 
index f915a08933f7b83370258fd103bd6d39400c3e0d..5e6657939cbf521797b141c15e1c782468cc81e3 100755 (executable)
@@ -376,72 +376,6 @@ if (defined $cgi->param('id')) {
     $first_bug->set_flags($flags, $new_flags);
 }
 
-my $move_action = $cgi->param('action') || '';
-if ($move_action eq Bugzilla->params->{'move-button-text'}) {
-    Bugzilla->params->{'move-enabled'} || ThrowUserError("move_bugs_disabled");
-
-    $user->is_mover || ThrowUserError("auth_failure", {action => 'move',
-                                                       object => 'bugs'});
-
-    $dbh->bz_start_transaction();
-
-    # First update all moved bugs.
-    foreach my $bug (@bug_objects) {
-        $bug->add_comment('', { type => CMT_MOVED_TO, extra_data => $user->login });
-    }
-    # Don't export the new status and resolution. We want the current ones.
-    local $Storable::forgive_me = 1;
-    my $bugs = dclone(\@bug_objects);
-
-    my $new_status = Bugzilla->params->{'duplicate_or_move_bug_status'};
-    foreach my $bug (@bug_objects) {
-        $bug->set_bug_status($new_status, {resolution => 'MOVED', moving => 1});
-    }
-    $_->update() foreach @bug_objects;
-    $dbh->bz_commit_transaction();
-
-    # Now send emails.
-    foreach my $bug (@bug_objects) {
-        $vars->{'mailrecipients'} = { 'changer' => $user };
-        $vars->{'id'} = $bug->id;
-        $vars->{'type'} = "move";
-        send_results($bug->id, $vars);
-    }
-    # Prepare and send all data about these bugs to the new database
-    my $to = Bugzilla->params->{'move-to-address'};
-    $to =~ s/@/\@/;
-    my $from = Bugzilla->params->{'moved-from-address'};
-    $from =~ s/@/\@/;
-    my $msg = "To: $to\n";
-    $msg .= "From: Bugzilla <" . $from . ">\n";
-    $msg .= "Subject: Moving bug(s) " . join(', ', map($_->id, @bug_objects))
-            . "\n\n";
-
-    my @fieldlist = (Bugzilla::Bug->fields, 'group', 'long_desc',
-                     'attachment', 'attachmentdata');
-    my %displayfields;
-    foreach (@fieldlist) {
-        $displayfields{$_} = 1;
-    }
-
-    $template->process("bug/show.xml.tmpl", { bugs => $bugs,
-                                              displayfields => \%displayfields,
-                                            }, \$msg)
-      || ThrowTemplateError($template->error());
-
-    $msg .= "\n";
-    MessageToMTA($msg);
-
-    # End the response page.
-    unless (Bugzilla->usage_mode == USAGE_MODE_EMAIL) {
-        $template->process("bug/navigate.html.tmpl", $vars)
-            || ThrowTemplateError($template->error());
-        $template->process("global/footer.html.tmpl", $vars)
-            || ThrowTemplateError($template->error());
-    }
-    exit;
-}
-
 ##############################
 # Do Actual Database Updates #
 ##############################
diff --git a/template/en/default/admin/params/bugmove.html.tmpl b/template/en/default/admin/params/bugmove.html.tmpl
deleted file mode 100644 (file)
index 911bc33..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-[%# 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): Dave Miller <justdave@bugzilla.org>
-  #                 Frédéric Buclin <LpSolit@gmail.com>
-  #%]
-[%
-   title = "$terms.Bug Moving"
-   desc = "Set up parameters to move $terms.bugs to/from another installation"
-%]
-
-[% param_descs = {
-  "move-enabled" => "If this is on, $terms.Bugzilla will allow certain people " _
-                    "to move $terms.bugs to the defined database.",
-
-  "move-button-text" => "The text written on the Move button. Explain where the $terms.bug is " _
-                        "being moved to.",
-
-  "move-to-url" => "The URL of the database we allow some of our $terms.bugs to be moved to.",
-
-  "move-to-address" => "To move ${terms.bugs}, an email is sent to the target database. This is " _
-                       "the email address that database uses to listen for incoming ${terms.bugs}.",
-
-  "moved-from-address" => "To move ${terms.bugs}, an email is sent to the target database. This is " _
-                          "the email address from which this mail, and error messages are sent.",
-
-  movers => "A list of people with permission to move $terms.bugs and reopen moved " _
-            "${terms.bugs} (in case the move operation fails).",
-
-  "moved-default-product" => "$terms.Bugs moved from other databases to here are assigned " _
-                             "to this product.",
-
-  "moved-default-component" => "$terms.Bugs moved from other databases to here are assigned " _
-                               "to this component." }
-%]
index e3255ec1efbe48a252598f6bcd16a67138b5c311..d9342a93c2761ee5356b68a68c89d7d1b35f7845 100644 (file)
     <div class="knob-buttons">
       <input type="submit" value="Save Changes" 
              id="commit[% id FILTER css_class_quote %]">
-      [% IF bug.user.canmove %]
-        <input type="submit" name="action" id="action[% id FILTER css_class_quote %]" value="[% Param("move-button-text") %]">
-      [% END %]
     </div>
   [% END %]
 [% END %]
index 7a65aed244be563c6c2f6f1a5cd90adef9d31442..ed89188a623f6298dc7f1047a0d1758cd11bedd4 100644 (file)
@@ -39,14 +39,6 @@ X[% comment_body %]
 *** This [% terms.bug %] has been marked as a duplicate of [% terms.bug %] [%+ comment.extra_data %] ***
 [% ELSIF comment.type == constants.CMT_HAS_DUPE %]
 *** [% terms.Bug %] [%+ comment.extra_data %] has been marked as a duplicate of this [% terms.bug %]. ***
-[% ELSIF comment.type == constants.CMT_MOVED_TO %]
-X[% comment_body %]
-
-[%+ terms.Bug %] moved to [% Param("move-to-url") %].
-If the move succeeded, [% comment.extra_data %] will receive a mail containing
-the number of the new [% terms.bug %] in the other database.
-If all went well, please paste in a link to the new [% terms.bug %].
-Otherwise, reopen this [% terms.bug %].
 [% ELSIF comment.type == constants.CMT_ATTACHMENT_CREATED %]
 Created attachment [% comment.extra_data %]
 [% IF is_bugmail %]
index f36199bef1cfc0e04189dfb8365e99f9571cad07..177d47621de51e892f9f3ad17dc3c35b7409d095 100644 (file)
   [% ELSIF error == "need_quipid" %]
     A valid quipid is needed.
 
-  [% ELSIF error == "no_manual_moved" %]
-    You cannot set the resolution of [% terms.abug %] to [% display_value("resolution", "MOVED") FILTER html %] without
-    moving the [% terms.bug %].
-
   [% ELSIF error == "object_dep_sort_loop" %]
     There is a loop in VALIDATOR_DEPENDENCIES involving
     '[%+ field FILTER html %]'. Here are the fields we considered:
index bbe1aba7b48a0fab1aa6dc2d7791cca3d102919b..6b406431e40b980884752dce5fa869c3004536bf 100644 (file)
@@ -73,8 +73,8 @@
 
   "resolution" => {
     ""        => "---",
-    # "FIXED" => "NO LONGER AN ISSUE",
-    # "MOVED" => "BYE-BYE",
+    # "FIXED"      => "NO LONGER AN ISSUE",
+    # "WORKSFORME" => "NOTMYPROBLEM!",
   },
 } %]
 
index 669d6adb30d4c42e80e072deea066ad71c6d7327..0d053cb745fb6826a98c3aa331c7045067f98bc0 100644 (file)
       delete
     [% ELSIF action == "edit" %]
       add, modify or delete
-    [% ELSIF action == "move" %]
-      move
     [% ELSIF action == "run" %]
       run
     [% ELSIF action == "schedule" %]
       use
     [% ELSIF action == "approve" %]
       approve
+    [% ELSE %]
+      [% Hook.process('auth_failure_action') %]
     [% END %]
 
     [% IF object == "administrative_pages" %]
     A valid resolution is required to mark [% terms.bugs %] as
     [%+ status FILTER upper FILTER html %].
 
-  [% ELSIF error == "move_bugs_disabled" %]
-    [% title = BLOCK %][% terms.Bug %] Moving Disabled[% END %]
-    Sorry, [% terms.bug %] moving has been disabled. If you need
-    to move [% terms.abug %], please contact [% Param("maintainer") %].
-
   [% ELSIF error == "missing_subcategory" %]
     [% title = "Missing Subcategory" %]
     You did not specify a subcategory for this series.
index 5f16dae69e65fb7db8306e67838052bdc63fcf88..c6bfbd336f53eb53ed252316b22fed3dae75d1e3 100644 (file)
 [% END %]
 <input type="submit" id="commit" value="Commit">
 
-[% IF Param('move-enabled') && user.is_mover %]
-  <input type="submit" name="action" id="action" value="[% Param('move-button-text') %]">
-[% END %]
-
 [%############################################################################%]
 [%# Select Menu Block                                                        #%]
 [%############################################################################%]
index b3583b5686090906fad9dda055c690d4148e124d..de089ec11db84b2bb08b7465577c9e54c300871a 100644 (file)
           behavior would occur. If more information appears later,
           the [% terms.bug %] can be reopened.
         </dd>
-
-        [% IF Param('move-enabled') %]
-          <dt>
-            [% display_value("resolution", "MOVED") FILTER html %]
-          </dt>
-          <dd>
-            The problem was specific to a related product 
-            whose [% terms.bugs %] are tracked in
-            another [% terms.bug %] database.
-            The [% terms.bug %] has been moved to that database.
-          </dd>
-        [% END %]
       </dl>
     </td>
   </tr>