diff options
Diffstat (limited to 'extensions')
38 files changed, 450 insertions, 57 deletions
diff --git a/extensions/BmpConvert/Config.pm b/extensions/BmpConvert/Config.pm index 42fb3ceab..4984f19a9 100644 --- a/extensions/BmpConvert/Config.pm +++ b/extensions/BmpConvert/Config.pm @@ -6,7 +6,11 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::BmpConvert; + +use 5.10.1; use strict; +use warnings; + use constant NAME => 'BmpConvert'; use constant REQUIRED_MODULES => [ { diff --git a/extensions/BmpConvert/Extension.pm b/extensions/BmpConvert/Extension.pm index 87ec5f5fd..b8201f106 100644 --- a/extensions/BmpConvert/Extension.pm +++ b/extensions/BmpConvert/Extension.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::BmpConvert; + +use 5.10.1; use strict; -use base qw(Bugzilla::Extension); +use warnings; + +use parent qw(Bugzilla::Extension); use Image::Magick; diff --git a/extensions/Example/Config.pm b/extensions/Example/Config.pm index b40ed9906..e7782ef6c 100644 --- a/extensions/Example/Config.pm +++ b/extensions/Example/Config.pm @@ -6,7 +6,11 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example; + +use 5.10.1; use strict; +use warnings; + use constant NAME => 'Example'; use constant REQUIRED_MODULES => [ { diff --git a/extensions/Example/Extension.pm b/extensions/Example/Extension.pm index 08a5144f4..dbc84df72 100644 --- a/extensions/Example/Extension.pm +++ b/extensions/Example/Extension.pm @@ -6,17 +6,22 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example; + +use 5.10.1; use strict; -use base qw(Bugzilla::Extension); +use warnings; + +use parent qw(Bugzilla::Extension); use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Group; use Bugzilla::User; use Bugzilla::User::Setting; -use Bugzilla::Util qw(diff_arrays html_quote); +use Bugzilla::Util qw(diff_arrays html_quote remote_ip); use Bugzilla::Status qw(is_open_state); use Bugzilla::Install::Filesystem; +use Bugzilla::WebService::Constants; # This is extensions/Example/lib/Util.pm. I can load this here in my # Extension.pm only because I have a Config.pm. @@ -29,6 +34,18 @@ use constant REL_EXAMPLE => -127; our $VERSION = '1.0'; +sub user_can_administer { + my ($self, $args) = @_; + my $can_administer = $args->{can_administer}; + + # If you add an option to the admin pages (e.g. by using the Hooks in + # template/en/default/admin/admin.html.tmpl), you may want to allow + # users in another group view admin.cgi + #if (Bugzilla->user->in_group('other_group')) { + # $$can_administer = 1; + #} +} + sub admin_editusers_action { my ($self, $args) = @_; my ($vars, $action, $user) = @$args{qw(vars action user)}; @@ -322,8 +339,8 @@ sub bugmail_recipients { # were on the CC list. #$recipients->{$user->id}->{+REL_CC} = 1; - # And this line adds the maintainer as though he had the "REL_EXAMPLE" - # relationship from the bugmail_relationships hook below. + # And this line adds the maintainer as though they had the + # "REL_EXAMPLE" relationship from the bugmail_relationships hook below. #$recipients->{$user->id}->{+REL_EXAMPLE} = 1; } } @@ -334,6 +351,13 @@ sub bugmail_relationships { $relationships->{+REL_EXAMPLE} = 'Example'; } +sub cgi_headers { + my ($self, $args) = @_; + my $headers = $args->{'headers'}; + + $headers->{'-x_test_header'} = "Test header from Example extension"; +} + sub config_add_panels { my ($self, $args) = @_; @@ -397,8 +421,8 @@ sub email_in_after_parse { # No other check needed if this is a valid regular user. return if login_to_id($reporter); - # The reporter is not a regular user. We create an account for him, - # but he can only comment on existing bugs. + # The reporter is not a regular user. We create an account for them, + # but they can only comment on existing bugs. # This is useful for people who reply by email to bugmails received # in mailing-lists. if ($args->{fields}->{bug_id}) { @@ -906,6 +930,26 @@ sub template_before_process { } } +sub user_check_account_creation { + my ($self, $args) = @_; + + my $login = $args->{login}; + my $ip = remote_ip(); + + # Log all requests. + warn "USER ACCOUNT CREATION REQUEST FOR $login ($ip)"; + + # Reject requests based on their email address. + if ($login =~ /\@evil\.com$/) { + ThrowUserError('account_creation_restricted'); + } + + # Reject requests based on their IP address. + if ($ip =~ /^192\.168\./) { + ThrowUserError('account_creation_restricted'); + } +} + sub user_preferences { my ($self, $args) = @_; my $tab = $args->{current_tab}; @@ -935,10 +979,85 @@ sub webservice { sub webservice_error_codes { my ($self, $args) = @_; - + my $error_map = $args->{error_map}; $error_map->{'example_my_error'} = 10001; } +sub webservice_status_code_map { + my ($self, $args) = @_; + + my $status_code_map = $args->{status_code_map}; + # Uncomment this line to override the status code for the + # error 'object_does_not_exist' to STATUS_BAD_REQUEST + #$status_code_map->{51} = STATUS_BAD_REQUEST; +} + +sub webservice_before_call { + my ($self, $args) = @_; + + # This code doesn't actually *do* anything, it's just here to show you + # how to use this hook. + my $method = $args->{method}; + my $full_method = $args->{full_method}; + + # Uncomment this line to see a line in your webserver's error log whenever + # a webservice call is made + #warn "RPC call $full_method made by ", + # Bugzilla->user->login || 'an anonymous user', "\n"; +} + +sub webservice_fix_credentials { + my ($self, $args) = @_; + my $rpc = $args->{'rpc'}; + my $params = $args->{'params'}; + # Allow user to pass in username=foo&password=bar + if (exists $params->{'username'} && exists $params->{'password'}) { + $params->{'Bugzilla_login'} = $params->{'username'}; + $params->{'Bugzilla_password'} = $params->{'password'}; + } +} + +sub webservice_rest_request { + my ($self, $args) = @_; + my $rpc = $args->{'rpc'}; + my $params = $args->{'params'}; + # Internally we may have a field called 'cf_test_field' but we allow users + # to use the shorter 'test_field' name. + if (exists $params->{'test_field'}) { + $params->{'test_field'} = delete $params->{'cf_test_field'}; + } +} + +sub webservice_rest_resources { + my ($self, $args) = @_; + my $rpc = $args->{'rpc'}; + my $resources = $args->{'resources'}; + # Add a new resource that allows for /rest/example/hello + # to call Example.hello + $resources->{'Bugzilla::Extension::Example::WebService'} = [ + qr{^/example/hello$}, { + GET => { + method => 'hello', + } + } + ]; +} + +sub webservice_rest_response { + my ($self, $args) = @_; + my $rpc = $args->{'rpc'}; + my $result = $args->{'result'}; + my $response = $args->{'response'}; + # Convert a list of bug hashes to a single bug hash if only one is + # being returned. + if (ref $$result eq 'HASH' + && exists $$result->{'bugs'} + && scalar @{ $$result->{'bugs'} } == 1) + { + $$result = $$result->{'bugs'}->[0]; + } +} + # This must be the last line of your extension. __PACKAGE__->NAME; diff --git a/extensions/Example/docs/en/rst/api/v1/index.rst b/extensions/Example/docs/en/rst/api/v1/index.rst new file mode 100644 index 000000000..02186bb0b --- /dev/null +++ b/extensions/Example/docs/en/rst/api/v1/index.rst @@ -0,0 +1,4 @@ +Example API v1 +============== + +Here is where you place your API docs for the Example extension. diff --git a/extensions/Example/docs/en/rst/index-admin.rst b/extensions/Example/docs/en/rst/index-admin.rst new file mode 100644 index 000000000..220319f99 --- /dev/null +++ b/extensions/Example/docs/en/rst/index-admin.rst @@ -0,0 +1,12 @@ +Example +####### + +This is a sample Adminstration documentation file for the Example extension. +Like all of the Bugzilla docs, it's written in +`reStructured Text (reST) format <http://sphinx-doc.org/latest/rest.html>`_ +and will be compiled by `Sphinx <http://sphinx-doc.org/>`_. + +If you build the docs yourself using :file:`makedocs.pl`, this file will get +incorporated into the Administration Guide. If you need more than one file's +worth of admin documentation, include others using the Sphinx `toctree +directive <http://sphinx-doc.org/markup/toctree.html>`_. diff --git a/extensions/Example/docs/en/rst/index-user.rst b/extensions/Example/docs/en/rst/index-user.rst new file mode 100644 index 000000000..192075d10 --- /dev/null +++ b/extensions/Example/docs/en/rst/index-user.rst @@ -0,0 +1,11 @@ +Example +####### + +This is a sample User documentation file for the Example extension. +Like all of the Bugzilla docs, it's written in +`reStructured Text (reST) format <http://sphinx-doc.org/latest/rest.html>`_ +and will be compiled by `Sphinx <http://sphinx-doc.org/>`_. + +If you build the docs yourself using :file:`makedocs.pl`, this file will get +incorporated into the User Guide. If you need more than one file's worth of +user documentation, include others using the Sphinx `toctree directive <http://sphinx-doc.org/markup/toctree.html>`_. diff --git a/extensions/Example/lib/Auth/Login.pm b/extensions/Example/lib/Auth/Login.pm index f87831157..15c58a881 100644 --- a/extensions/Example/lib/Auth/Login.pm +++ b/extensions/Example/lib/Auth/Login.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example::Auth::Login; + +use 5.10.1; use strict; -use base qw(Bugzilla::Auth::Login); +use warnings; + +use parent qw(Bugzilla::Auth::Login); use constant user_can_create_account => 0; use Bugzilla::Constants; diff --git a/extensions/Example/lib/Auth/Verify.pm b/extensions/Example/lib/Auth/Verify.pm index 0d068b2e1..49fd9fbb7 100644 --- a/extensions/Example/lib/Auth/Verify.pm +++ b/extensions/Example/lib/Auth/Verify.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example::Auth::Verify; + +use 5.10.1; use strict; -use base qw(Bugzilla::Auth::Verify); +use warnings; + +use parent qw(Bugzilla::Auth::Verify); use Bugzilla::Constants; # A verifier that always fails. diff --git a/extensions/Example/lib/Config.pm b/extensions/Example/lib/Config.pm index b0497a783..fac0046af 100644 --- a/extensions/Example/lib/Config.pm +++ b/extensions/Example/lib/Config.pm @@ -6,6 +6,8 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example::Config; + +use 5.10.1; use strict; use warnings; diff --git a/extensions/Example/lib/Util.pm b/extensions/Example/lib/Util.pm index b4ed3e0a4..ccc349c9c 100644 --- a/extensions/Example/lib/Util.pm +++ b/extensions/Example/lib/Util.pm @@ -6,6 +6,8 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example::Util; + +use 5.10.1; use strict; use warnings; diff --git a/extensions/Example/lib/WebService.pm b/extensions/Example/lib/WebService.pm index 56adc8cb8..d8a96b5f5 100644 --- a/extensions/Example/lib/WebService.pm +++ b/extensions/Example/lib/WebService.pm @@ -6,9 +6,11 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Example::WebService; + +use 5.10.1; use strict; use warnings; -use base qw(Bugzilla::WebService); +use parent qw(Bugzilla::WebService); use Bugzilla::Error; use constant PUBLIC_METHODS => qw( diff --git a/extensions/Example/template/en/default/hook/global/footer-end.html.tmpl b/extensions/Example/template/en/default/hook/global/footer-end.html.tmpl index f4cb1e006..fd4ec8639 100644 --- a/extensions/Example/template/en/default/hook/global/footer-end.html.tmpl +++ b/extensions/Example/template/en/default/hook/global/footer-end.html.tmpl @@ -8,7 +8,7 @@ [% USE date %] -<p align="center"> +<p class="center"> <em>[% component.callers.first FILTER html %]</em> processed on [% date.format(date.now, '%b %d, %Y at %H:%M:%S') FILTER html %]. <br> diff --git a/extensions/Example/template/en/default/hook/search/tabs-search_tabs.html.tmpl b/extensions/Example/template/en/default/hook/search/tabs-search_tabs.html.tmpl new file mode 100644 index 000000000..bf522f7dd --- /dev/null +++ b/extensions/Example/template/en/default/hook/search/tabs-search_tabs.html.tmpl @@ -0,0 +1,13 @@ +[%# 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. + #%] + +[% + tabs.push({ name => 'newsearch', label => "New Search", + link => "query.cgi?format=newsearch" }) +%] + diff --git a/extensions/Gentoo/Extension.pm b/extensions/Gentoo/Extension.pm index cc80a1007..93301cbdd 100644 --- a/extensions/Gentoo/Extension.pm +++ b/extensions/Gentoo/Extension.pm @@ -59,4 +59,12 @@ sub template_before_create { $constants->{GENTOO_APPEND_VERSION} = "+"; } +sub user_check_account_creation { + my ($self, $args) = @_; + + my $login = $args->{login}; + + ThrowUserError('restricted_email_address', {addr => $login}) if $login =~ m/.+\@gentoo\.org$/; +} + __PACKAGE__->NAME; diff --git a/extensions/MoreBugUrl/Config.pm b/extensions/MoreBugUrl/Config.pm index b5af9c00e..e0eac5f8a 100644 --- a/extensions/MoreBugUrl/Config.pm +++ b/extensions/MoreBugUrl/Config.pm @@ -6,7 +6,10 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl; + +use 5.10.1; use strict; +use warnings; use constant NAME => 'MoreBugUrl'; diff --git a/extensions/MoreBugUrl/Extension.pm b/extensions/MoreBugUrl/Extension.pm index 52b6e61c3..18507f8d1 100644 --- a/extensions/MoreBugUrl/Extension.pm +++ b/extensions/MoreBugUrl/Extension.pm @@ -6,15 +6,22 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl; + +use 5.10.1; use strict; -use base qw(Bugzilla::Extension); +use warnings; + +use parent qw(Bugzilla::Extension); use constant MORE_SUB_CLASSES => qw( + Bugzilla::Extension::MoreBugUrl::BitBucket Bugzilla::Extension::MoreBugUrl::ReviewBoard Bugzilla::Extension::MoreBugUrl::Rietveld Bugzilla::Extension::MoreBugUrl::RT Bugzilla::Extension::MoreBugUrl::GetSatisfaction Bugzilla::Extension::MoreBugUrl::PHP + Bugzilla::Extension::MoreBugUrl::Redmine + Bugzilla::Extension::MoreBugUrl::Savane ); # We need to update bug_see_also table because both diff --git a/extensions/MoreBugUrl/lib/BitBucket.pm b/extensions/MoreBugUrl/lib/BitBucket.pm new file mode 100644 index 000000000..dcc85992d --- /dev/null +++ b/extensions/MoreBugUrl/lib/BitBucket.pm @@ -0,0 +1,41 @@ +# 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::BitBucket; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + + # BitBucket issues have the form of + # bitbucket.org/user/project/issue/1234 + return (lc($uri->authority) eq "bitbucket.org" + && $uri->path =~ m|[^/]+/[^/]+/issue/\d+|i) ? 1 : 0; +} + +sub _check_value { + my $class = shift; + + my $uri = $class->SUPER::_check_value(@_); + + my ($path) = $uri->path =~ m|([^/]+/[^/]+/issue/\d+)|i; + $uri = new URI("https://bitbucket.org/$path"); + + return $uri; +} + +1; + diff --git a/extensions/MoreBugUrl/lib/GetSatisfaction.pm b/extensions/MoreBugUrl/lib/GetSatisfaction.pm index e4548563f..74951735b 100644 --- a/extensions/MoreBugUrl/lib/GetSatisfaction.pm +++ b/extensions/MoreBugUrl/lib/GetSatisfaction.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl::GetSatisfaction; + +use 5.10.1; use strict; -use base qw(Bugzilla::BugUrl); +use warnings; + +use parent qw(Bugzilla::BugUrl); ############################### #### Methods #### diff --git a/extensions/MoreBugUrl/lib/PHP.pm b/extensions/MoreBugUrl/lib/PHP.pm index c17a49998..6f201d7b1 100644 --- a/extensions/MoreBugUrl/lib/PHP.pm +++ b/extensions/MoreBugUrl/lib/PHP.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl::PHP; + +use 5.10.1; use strict; -use base qw(Bugzilla::BugUrl); +use warnings; + +use parent qw(Bugzilla::BugUrl); ############################### #### Methods #### diff --git a/extensions/MoreBugUrl/lib/RT.pm b/extensions/MoreBugUrl/lib/RT.pm index 724c773a2..acb90cf39 100644 --- a/extensions/MoreBugUrl/lib/RT.pm +++ b/extensions/MoreBugUrl/lib/RT.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl::RT; + +use 5.10.1; use strict; -use base qw(Bugzilla::BugUrl); +use warnings; + +use parent qw(Bugzilla::BugUrl); ############################### #### Methods #### diff --git a/extensions/MoreBugUrl/lib/Redmine.pm b/extensions/MoreBugUrl/lib/Redmine.pm new file mode 100644 index 000000000..57a071239 --- /dev/null +++ b/extensions/MoreBugUrl/lib/Redmine.pm @@ -0,0 +1,41 @@ +# 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::Redmine; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + return ($uri->path =~ m|/issues/\d+$|) ? 1 : 0; +} + +sub _check_value { + my $class = shift; + + my $uri = $class->SUPER::_check_value(@_); + + # Redmine URLs have only one form: + # http://demo.redmine.com/issues/111 + + # Make sure there are no query parameters. + $uri->query(undef); + # And remove any # part if there is one. + $uri->fragment(undef); + + return $uri; +} + +1; diff --git a/extensions/MoreBugUrl/lib/ReviewBoard.pm b/extensions/MoreBugUrl/lib/ReviewBoard.pm index 7628dd314..af5ff0684 100644 --- a/extensions/MoreBugUrl/lib/ReviewBoard.pm +++ b/extensions/MoreBugUrl/lib/ReviewBoard.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl::ReviewBoard; + +use 5.10.1; use strict; -use base qw(Bugzilla::BugUrl); +use warnings; + +use parent qw(Bugzilla::BugUrl); ############################### #### Methods #### diff --git a/extensions/MoreBugUrl/lib/Rietveld.pm b/extensions/MoreBugUrl/lib/Rietveld.pm index 0c52892e2..a4bf08492 100644 --- a/extensions/MoreBugUrl/lib/Rietveld.pm +++ b/extensions/MoreBugUrl/lib/Rietveld.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::MoreBugUrl::Rietveld; + +use 5.10.1; use strict; -use base qw(Bugzilla::BugUrl); +use warnings; + +use parent qw(Bugzilla::BugUrl); ############################### #### Methods #### diff --git a/extensions/MoreBugUrl/lib/Savane.pm b/extensions/MoreBugUrl/lib/Savane.pm new file mode 100644 index 000000000..efda1fa4f --- /dev/null +++ b/extensions/MoreBugUrl/lib/Savane.pm @@ -0,0 +1,40 @@ +# 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::Savane; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Bugzilla::BugUrl); + +############################### +#### Methods #### +############################### + +sub should_handle { + my ($class, $uri) = @_; + return ($uri->as_string =~ m|/bugs/(index\.php)?\?\d+$|) ? 1 : 0; +} + +sub _check_value { + my $class = shift; + + my $uri = $class->SUPER::_check_value(@_); + + # Savane URLs have only two forms: + # http://gna.org/bugs/index.php?12345 + # http://gna.org/bugs/?12345 + + # And remove any # part if there is one. + $uri->fragment(undef); + + return $uri; +} + +1; 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 index 7683e4299..7e544ef21 100644 --- 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 @@ -6,8 +6,11 @@ # defined by the Mozilla Public License, v. 2.0. #%] +<li>An issue on bitbucket.org.</li> <li>A Review Board review request.</li> <li>An issue in a Rietveld installation.</li> <li>A ticket in an RT installation.</li> <li>A topic on getsatisfaction.com.</li> <li>A b[% %]ug on b[% %]ugs.php.net.</li> +<li>An issue in a Redmine installation.</li> +<li>A b[% %]ug in a Savane installation.</li> diff --git a/extensions/OldBugMove/Config.pm b/extensions/OldBugMove/Config.pm index 95648610e..681cbae2d 100644 --- a/extensions/OldBugMove/Config.pm +++ b/extensions/OldBugMove/Config.pm @@ -6,6 +6,10 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::OldBugMove; + +use 5.10.1; use strict; +use warnings; + use constant NAME => 'OldBugMove'; __PACKAGE__->NAME; diff --git a/extensions/OldBugMove/Extension.pm b/extensions/OldBugMove/Extension.pm index 9a499d5d0..375707fd2 100644 --- a/extensions/OldBugMove/Extension.pm +++ b/extensions/OldBugMove/Extension.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::OldBugMove; + +use 5.10.1; use strict; -use base qw(Bugzilla::Extension); +use warnings; + +use parent qw(Bugzilla::Extension); use Bugzilla::Constants; use Bugzilla::Error; use Bugzilla::Field::Choice; diff --git a/extensions/OldBugMove/lib/Params.pm b/extensions/OldBugMove/lib/Params.pm index dbb1eb21d..05e3ed277 100644 --- a/extensions/OldBugMove/lib/Params.pm +++ b/extensions/OldBugMove/lib/Params.pm @@ -7,7 +7,9 @@ package Bugzilla::Extension::OldBugMove::Params; +use 5.10.1; use strict; +use warnings; use Bugzilla::Config::Common; diff --git a/extensions/Voting/Config.pm b/extensions/Voting/Config.pm index 4fefe957a..97c44933e 100644 --- a/extensions/Voting/Config.pm +++ b/extensions/Voting/Config.pm @@ -6,7 +6,10 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Voting; + +use 5.10.1; use strict; +use warnings; use constant NAME => 'Voting'; diff --git a/extensions/Voting/Extension.pm b/extensions/Voting/Extension.pm index d186e442a..8009f16bb 100644 --- a/extensions/Voting/Extension.pm +++ b/extensions/Voting/Extension.pm @@ -6,8 +6,12 @@ # defined by the Mozilla Public License, v. 2.0. package Bugzilla::Extension::Voting; + +use 5.10.1; use strict; -use base qw(Bugzilla::Extension); +use warnings; + +use parent qw(Bugzilla::Extension); use Bugzilla::Bug; use Bugzilla::BugMail; @@ -389,7 +393,7 @@ sub _page_user { # If a bug_id is given, and we're editing, we'll add it to the votes list. my $bug_id = $input->{bug_id}; - my $bug = Bugzilla::Bug->check($bug_id) if $bug_id; + my $bug = Bugzilla::Bug->check({ id => $bug_id, cache => 1 }) if $bug_id; my $who_id = $input->{user_id} || $user->id; # Logged-out users must specify a user_id. @@ -626,7 +630,7 @@ sub _update_votes { # Set header_done to 1 only after the first bug. $vars->{'header_done'} = 1; } - $vars->{'votes_recorded'} = 1; + $vars->{'message'} = 'votes_recorded'; } ###################### @@ -654,8 +658,8 @@ sub _modify_bug_votes { # If some votes are removed, _remove_votes() returns a list # of messages to send to voters. push(@msgs, _remove_votes($id, $who, 'votes_too_many_per_bug')); - my $name = user_id_to_login($who); - + my $name = Bugzilla::User->new($who)->login; + push(@toomanyvotes_list, {id => $id, name => $name}); } } @@ -695,12 +699,12 @@ sub _modify_bug_votes { AND votes.who = ?', undef, $product->id, $who); + my $name = Bugzilla::User->new($who)->login; foreach my $bug_id (@$bug_ids) { # _remove_votes returns a list of messages to send # in case some voters had too many votes. push(@msgs, _remove_votes($bug_id, $who, 'votes_too_many_per_user')); - my $name = user_id_to_login($who); push(@toomanytotalvotes_list, {id => $bug_id, name => $name}); } @@ -824,7 +828,7 @@ sub _remove_votes { # confirm a bug has been reduced, check if the bug is now confirmed. sub _confirm_if_vote_confirmed { my $id = shift; - my $bug = ref $id ? $id : new Bugzilla::Bug($id); + my $bug = ref $id ? $id : new Bugzilla::Bug({ id => $id, cache => 1 }); my $ret = 0; if (!$bug->everconfirmed diff --git a/extensions/Voting/template/en/default/hook/admin/products/edit-common-rows.html.tmpl b/extensions/Voting/template/en/default/hook/admin/products/edit-common-rows.html.tmpl index 9a8373bac..c46da75ae 100644 --- a/extensions/Voting/template/en/default/hook/admin/products/edit-common-rows.html.tmpl +++ b/extensions/Voting/template/en/default/hook/admin/products/edit-common-rows.html.tmpl @@ -11,16 +11,16 @@ product.votesperuser = 0 product.votestoconfirm = 0 %] - + <tr> - <th align="right">Maximum votes per person:</th> + <th>Maximum votes per person:</th> <td><input size="5" maxlength="5" name="votesperuser" id="votesperuser" value="[% product.votesperuser FILTER html %]"> </td> </tr> <tr> - <th align="right"> + <th> Maximum votes a person can put on a single [% terms.bug %]: </th> <td><input size="5" maxlength="5" name="maxvotesperbug" id="maxvotesperbug" @@ -30,7 +30,7 @@ <tr id="votes_to_confirm_container" [%- ' class="bz_default_hidden"' IF !product.allows_unconfirmed %]> - <th align="right"> + <th> Confirm [% terms.abug %] if it gets this many votes: </th> <td> diff --git a/extensions/Voting/template/en/default/hook/global/messages-messages.html.tmpl b/extensions/Voting/template/en/default/hook/global/messages-messages.html.tmpl new file mode 100644 index 000000000..e6e5f22c7 --- /dev/null +++ b/extensions/Voting/template/en/default/hook/global/messages-messages.html.tmpl @@ -0,0 +1,16 @@ +[%# This Source Code Form is subject to th e 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. + #%] + +[%# This is a list of all the possible messages. Please keep them in + # alphabetical order by message tag, and leave a blank line between messages. + #%] + +[% IF message_tag == "votes_recorded" %] + The changes to your votes have been saved. +[% END %] + diff --git a/extensions/Voting/template/en/default/hook/global/user-error-errors.html.tmpl b/extensions/Voting/template/en/default/hook/global/user-error-errors.html.tmpl index 55c32d460..644c827a6 100644 --- a/extensions/Voting/template/en/default/hook/global/user-error-errors.html.tmpl +++ b/extensions/Voting/template/en/default/hook/global/user-error-errors.html.tmpl @@ -30,14 +30,14 @@ [% admindocslinks = {'voting.html' => 'Setting up the voting feature'} %] You may only use at most [% max FILTER html %] votes for a single [%+ terms.bug %] in the - <tt>[% product FILTER html %]</tt> product, but you are trying to + <em>[% product FILTER html %]</em> product, but you are trying to use [% votes FILTER html %]. [% ELSIF error == "voting_too_many_votes_for_product" %] [% title = "Illegal Vote" %] [% admindocslinks = {'voting.html' => 'Setting up the voting feature'} %] You tried to use [% votes FILTER html %] votes in the - <tt>[% product FILTER html %]</tt> product, which exceeds the maximum of + <em>[% product FILTER html %]</em> product, which exceeds the maximum of [%+ max FILTER html %] votes for this product. [% END %] diff --git a/extensions/Voting/template/en/default/pages/voting/bug.html.tmpl b/extensions/Voting/template/en/default/pages/voting/bug.html.tmpl index 2ba784f77..cb1d2380e 100644 --- a/extensions/Voting/template/en/default/pages/voting/bug.html.tmpl +++ b/extensions/Voting/template/en/default/pages/voting/bug.html.tmpl @@ -20,10 +20,11 @@ [% PROCESS global/header.html.tmpl title = "Show Votes" subheader = subheader + style_urls = [ "extensions/Voting/web/style.css" ] %] [% total = 0 %] -<table cellspacing="4"> +<table id="bug_votes"> <tr> <th>Who</th> <th>Number of votes</th> @@ -38,7 +39,7 @@ [% voter.login_name FILTER email FILTER html %] </a> </td> - <td align="right"> + <td class="right"> [% voter.vote_count FILTER html %] </td> </tr> diff --git a/extensions/Voting/template/en/default/pages/voting/user.html.tmpl b/extensions/Voting/template/en/default/pages/voting/user.html.tmpl index 8777e036b..b5e8fc9bc 100644 --- a/extensions/Voting/template/en/default/pages/voting/user.html.tmpl +++ b/extensions/Voting/template/en/default/pages/voting/user.html.tmpl @@ -47,25 +47,15 @@ <hr> [% END %] -[% IF votes_recorded %] - <p> - <font color="red"> - The changes to your votes have been saved. - </font> - </p> -[% ELSE %] - <br> -[% END %] - [% IF products.size %] <form name="voting_form" method="post" action="page.cgi?id=voting/user.html"> <input type="hidden" name="action" value="vote"> <input type="hidden" name="token" value="[% issue_hash_token(['vote']) FILTER html %]"> - <table cellspacing="4"> + <table id="user_votes"> <tr> - <td></td> + <th></th> <th>Votes</th> - <th>[% terms.Bug %] #</th> + <th>[% terms.Bug %] #</th> <th>Summary</th> </tr> @@ -105,7 +95,8 @@ [% END %] [%- END %] </td> - <td align="right"><a name="vote_[% bug.id FILTER none %]"> + <td> + <a name="vote_[% bug.id FILTER none %]"> [% IF canedit %] [% IF product.onevoteonly %] <input type="checkbox" name="[% bug.id FILTER none %]" value="1" @@ -117,8 +108,9 @@ [% ELSE %] [% bug.count FILTER html %] [% END %] - </a></td> - <td align="center"> + </a> + </td> + <td class="right"> [% PROCESS bug/link.html.tmpl bug = bug, link_text = bug.id %] </td> <td> diff --git a/extensions/Voting/web/style.css b/extensions/Voting/web/style.css index 3f06200ca..22458fd90 100644 --- a/extensions/Voting/web/style.css +++ b/extensions/Voting/web/style.css @@ -19,3 +19,12 @@ tr.bz_bug_being_voted_on td { #votes_container { white-space: nowrap; } + +#user_votes th { + text-align: center; +} + +#user_votes th, #user_votes td, +#bug_votes th, #bug_votes td { + padding: 0.2em; +} diff --git a/extensions/create.pl b/extensions/create.pl index 7bcf10373..7c8693e28 100755 --- a/extensions/create.pl +++ b/extensions/create.pl @@ -1,4 +1,4 @@ -#!/usr/bin/perl -w +#!/usr/bin/perl # 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/. @@ -6,8 +6,15 @@ # This Source Code Form is "Incompatible With Secondary Licenses", as # defined by the Mozilla Public License, v. 2.0. +use 5.10.1; use strict; -use lib qw(. lib); +use warnings; + +use File::Basename; +BEGIN { chdir dirname($0); } + +use lib qw(.. ../lib); + use Bugzilla; use Bugzilla::Constants; use Bugzilla::Error; @@ -28,7 +35,7 @@ mkpath($extension_dir) || die "$extension_dir already exists or cannot be created.\n"; my $lcname = lc($name); -foreach my $path (qw(lib web template/en/default/hook), +foreach my $path (qw(lib docs/en/rst web template/en/default/hook), "template/en/default/$lcname") { mkpath("$extension_dir/$path") || die "$extension_dir/$path: $!"; @@ -43,6 +50,8 @@ my %create_files = ( 'web-readme.txt.tmpl' => 'web/README', 'hook-readme.txt.tmpl' => 'template/en/default/hook/README', 'name-readme.txt.tmpl' => "template/en/default/$lcname/README", + 'index-admin.rst.tmpl' => "docs/en/rst/index-admin.rst", + 'index-user.rst.tmpl' => "docs/en/rst/index-user.rst", ); foreach my $template_file (keys %create_files) { @@ -50,12 +59,13 @@ foreach my $template_file (keys %create_files) { my $output; $template->process("extensions/$template_file", $vars, \$output) or ThrowTemplateError($template->error()); - open(my $fh, '>', "$extension_dir/$target"); - print $fh $output; - close($fh); + open(my $fh, '>', "$extension_dir/$target") + or die "extension_dir/$target: $!"; + print $fh $output; + close($fh); } -print get_text('extension_created', $vars), "\n"; +say get_text('extension_created', $vars); __END__ |