]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 722580: Move 'ReviewBoard' and 'Rietveld' BugUrl sub-classes
authorTiago Mello <timello@gmail.com>
Sun, 19 Feb 2012 17:36:22 +0000 (15:36 -0200)
committerTiago Mello <timello@gmail.com>
Sun, 19 Feb 2012 17:36:22 +0000 (15:36 -0200)
to a new 'MoreBugUrl' extension.
r/a=LpSolit

Bugzilla/BugUrl.pm
Bugzilla/Hook.pm
extensions/MoreBugUrl/Config.pm [new file with mode: 0644]
extensions/MoreBugUrl/Extension.pm [new file with mode: 0644]
extensions/MoreBugUrl/disabled [new file with mode: 0644]
extensions/MoreBugUrl/lib/ReviewBoard.pm [moved from Bugzilla/BugUrl/ReviewBoard.pm with 95% similarity]
extensions/MoreBugUrl/lib/Rietveld.pm [moved from Bugzilla/BugUrl/Rietveld.pm with 96% similarity]
extensions/MoreBugUrl/template/en/default/hook/global/user-error-bug_url_invalid_tracker.html.tmpl [new file with mode: 0644]
template/en/default/global/user-error.html.tmpl

index 99d46bd247e7648e02d74571ffd0e00c5a726cb3..888b11398f29ddeb8b85a1d340c5599388da0980 100644 (file)
@@ -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
index fe4f0860e645fdc0d75c6f1626c7a033b59a622a..17023f8f5a0c5a34f62b1d8238860693a8846391 100644 (file)
@@ -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 (file)
index 0000000..b5af9c0
--- /dev/null
@@ -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 (file)
index 0000000..7153165
--- /dev/null
@@ -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 (file)
index 0000000..e69de29
similarity index 95%
rename from Bugzilla/BugUrl/ReviewBoard.pm
rename to extensions/MoreBugUrl/lib/ReviewBoard.pm
index 3c1ed56ba59f85f5e15b75de8fd5d55dff71c9b5..7628dd314180d2f37ed4349efab69184c3c96688 100644 (file)
@@ -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);
 
similarity index 96%
rename from Bugzilla/BugUrl/Rietveld.pm
rename to extensions/MoreBugUrl/lib/Rietveld.pm
index 9baf85d8d7e2ecab0eaff4e121d581e53d922b33..0c52892e2421be139315fac16918483cd92f796d 100644 (file)
@@ -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 (file)
index 0000000..e0cf6be
--- /dev/null
@@ -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>
index fdd2fb980d48e4c8a8301d827078a21cd39fa985..7408a1a05e51afe27b786d062397b7e652d2aff9 100644 (file)
         <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.