diff options
-rw-r--r-- | Bugzilla/BugUrl.pm | 9 | ||||
-rw-r--r-- | Bugzilla/Hook.pm | 15 | ||||
-rw-r--r-- | extensions/MoreBugUrl/Config.pm | 19 | ||||
-rw-r--r-- | extensions/MoreBugUrl/Extension.pm | 43 | ||||
-rw-r--r-- | extensions/MoreBugUrl/disabled | 0 | ||||
-rw-r--r-- | extensions/MoreBugUrl/lib/ReviewBoard.pm (renamed from Bugzilla/BugUrl/ReviewBoard.pm) | 2 | ||||
-rw-r--r-- | extensions/MoreBugUrl/lib/Rietveld.pm (renamed from Bugzilla/BugUrl/Rietveld.pm) | 2 | ||||
-rw-r--r-- | extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl | 10 | ||||
-rw-r--r-- | template/en/default/global/user-error.html.tmpl | 3 |
9 files changed, 96 insertions, 7 deletions
diff --git a/Bugzilla/BugUrl.pm b/Bugzilla/BugUrl.pm index 99d46bd24..888b11398 100644 --- a/Bugzilla/BugUrl.pm +++ b/Bugzilla/BugUrl.pm @@ -12,6 +12,7 @@ use base qw(Bugzilla::Object); use Bugzilla::Util; use Bugzilla::Error; use Bugzilla::Constants; +use Bugzilla::Hook; use URI::QueryParam; @@ -56,8 +57,6 @@ use constant SUB_CLASSES => qw( Bugzilla::BugUrl::Trac Bugzilla::BugUrl::MantisBT Bugzilla::BugUrl::SourceForge - Bugzilla::BugUrl::ReviewBoard - Bugzilla::BugUrl::Rietveld ); ############################### @@ -121,8 +120,12 @@ sub should_handle { sub class_for { my ($class, $value) = @_; + my @sub_classes = $class->SUB_CLASSES; + Bugzilla::Hook::process("bug_url_sub_classes", + { sub_classes => \@sub_classes }); + my $uri = URI->new($value); - foreach my $subclass ($class->SUB_CLASSES) { + foreach my $subclass (@sub_classes) { eval "use $subclass"; die $@ if $@; return wantarray ? ($subclass, $uri) : $subclass diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm index fe4f0860e..17023f8f5 100644 --- a/Bugzilla/Hook.pm +++ b/Bugzilla/Hook.pm @@ -389,6 +389,21 @@ the summary line). =back +=head2 bug_url_sub_classes + +Allows you to add more L<Bugzilla::BugUrl> sub-classes. + +See the C<MoreBugUrl> extension to see how things work. + +Params: + +=over + +=item C<sub_classes> - An arrayref of strings which represent L<Bugzilla::BugUrl> +sub-classes. + +=back + =head2 buglist_columns This happens in L<Bugzilla::Search/COLUMNS>, which determines legal bug diff --git a/extensions/MoreBugUrl/Config.pm b/extensions/MoreBugUrl/Config.pm new file mode 100644 index 000000000..b5af9c00e --- /dev/null +++ b/extensions/MoreBugUrl/Config.pm @@ -0,0 +1,19 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::MoreBugUrl; +use strict; + +use constant NAME => 'MoreBugUrl'; + +use constant REQUIRED_MODULES => [ +]; + +use constant OPTIONAL_MODULES => [ +]; + +__PACKAGE__->NAME; diff --git a/extensions/MoreBugUrl/Extension.pm b/extensions/MoreBugUrl/Extension.pm new file mode 100644 index 000000000..715316585 --- /dev/null +++ b/extensions/MoreBugUrl/Extension.pm @@ -0,0 +1,43 @@ +# This Source Code Form is subject to the terms of the Mozilla Public +# License, v. 2.0. If a copy of the MPL was not distributed with this +# file, You can obtain one at http://mozilla.org/MPL/2.0/. +# +# This Source Code Form is "Incompatible With Secondary Licenses", as +# defined by the Mozilla Public License, v. 2.0. + +package Bugzilla::Extension::MoreBugUrl; +use strict; +use base qw(Bugzilla::Extension); + +use constant MORE_SUB_CLASSES => qw( + Bugzilla::Extension::MoreBugUrl::ReviewBoard + Bugzilla::Extension::MoreBugUrl::Rietveld +); + +# We need to update bug_see_also table because both +# Rietveld and ReviewBoard were originally under Bugzilla/BugUrl/. +sub install_update_db { + my $dbh = Bugzilla->dbh; + + my $should_rename = $dbh->selectrow_array( + q{SELECT 1 FROM bug_see_also + WHERE class IN ('Bugzilla::BugUrl::Rietveld', + 'Bugzilla::BugUrl::ReviewBoard')}); + + if ($should_rename) { + my $sth = $dbh->prepare('UPDATE bug_see_also SET class = ? + WHERE class = ?'); + $sth->execute('Bugzilla::Extension::MoreBugUrl::ReviewBoard', + 'Bugzilla::BugUrl::ReviewBoard'); + + $sth->execute('Bugzilla::Extension::MoreBugUrl::Rietveld', + 'Bugzilla::BugUrl::Rietveld'); + } +} + +sub bug_url_sub_classes { + my ($self, $args) = @_; + push @{ $args->{sub_classes} }, MORE_SUB_CLASSES; +} + +__PACKAGE__->NAME; diff --git a/extensions/MoreBugUrl/disabled b/extensions/MoreBugUrl/disabled new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/extensions/MoreBugUrl/disabled diff --git a/Bugzilla/BugUrl/ReviewBoard.pm b/extensions/MoreBugUrl/lib/ReviewBoard.pm index 3c1ed56ba..7628dd314 100644 --- a/Bugzilla/BugUrl/ReviewBoard.pm +++ b/extensions/MoreBugUrl/lib/ReviewBoard.pm @@ -5,7 +5,7 @@ # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. -package Bugzilla::BugUrl::ReviewBoard; +package Bugzilla::Extension::MoreBugUrl::ReviewBoard; use strict; use base qw(Bugzilla::BugUrl); diff --git a/Bugzilla/BugUrl/Rietveld.pm b/extensions/MoreBugUrl/lib/Rietveld.pm index 9baf85d8d..0c52892e2 100644 --- a/Bugzilla/BugUrl/Rietveld.pm +++ b/extensions/MoreBugUrl/lib/Rietveld.pm @@ -5,7 +5,7 @@ # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. -package Bugzilla::BugUrl::Rietveld; +package Bugzilla::Extension::MoreBugUrl::Rietveld; use strict; use base qw(Bugzilla::BugUrl); diff --git a/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl b/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl new file mode 100644 index 000000000..e0cf6be8e --- /dev/null +++ b/extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl @@ -0,0 +1,10 @@ +[%# This Source Code Form is subject to the terms of the Mozilla Public + # License, v. 2.0. If a copy of the MPL was not distributed with this + # file, You can obtain one at http://mozilla.org/MPL/2.0/. + # + # This Source Code Form is "Incompatible With Secondary Licenses", as + # defined by the Mozilla Public License, v. 2.0. + #%] + +<li>A Review Board review request.</li> +<li>An issue in a Rietveld installation.</li> diff --git a/template/en/default/global/user-error.html.tmpl b/template/en/default/global/user-error.html.tmpl index fdd2fb980..7408a1a05 100644 --- a/template/en/default/global/user-error.html.tmpl +++ b/template/en/default/global/user-error.html.tmpl @@ -254,8 +254,7 @@ <li>A ticket in a Trac installation.</li> <li>A b[% %]ug in a MantisBT installation.</li> <li>A b[% %]ug on sourceforge.net.</li> - <li>A Review Board review request.</li> - <li>An issue in a Rietveld installation.</li> + [% Hook.process('bug_url_invalid_tracker') %] </ul> [% ELSIF reason == 'id' %] There is no valid [% terms.bug %] id in that URL. |