From 9f4329cfd4ccf1e3030e131299a028df4a6c30df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Buclin?= Date: Wed, 24 Feb 2016 00:43:00 +0100 Subject: Import Mageia extension - version 5.0 --- extensions/Mageia/Config.pm | 22 ++ extensions/Mageia/Extension.pm | 111 +++++++ extensions/Mageia/lib/Util.pm | 24 ++ .../en/default/bug/create/comment-guided.txt.tmpl | 10 + .../en/default/bug/create/create-guided.html.tmpl | 321 +++++++++++++++++++++ .../template/en/default/global/banner.html.tmpl | 11 + extensions/Mageia/template/en/default/hook/README | 5 + .../auth/login-small-additional_methods.html.tmpl | 23 ++ .../en/default/hook/global/header-start.html.tmpl | 10 + .../en/default/hook/global/variables-end.none.tmpl | 9 + .../default/hook/index-additional_links.html.tmpl | 14 + .../Mageia/template/en/default/mageia/README | 16 + extensions/Mageia/web/README | 7 + extensions/Mageia/web/style.css | 31 ++ 14 files changed, 614 insertions(+) create mode 100644 extensions/Mageia/Config.pm create mode 100644 extensions/Mageia/Extension.pm create mode 100644 extensions/Mageia/lib/Util.pm create mode 100644 extensions/Mageia/template/en/default/bug/create/comment-guided.txt.tmpl create mode 100644 extensions/Mageia/template/en/default/bug/create/create-guided.html.tmpl create mode 100644 extensions/Mageia/template/en/default/global/banner.html.tmpl create mode 100644 extensions/Mageia/template/en/default/hook/README create mode 100644 extensions/Mageia/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl create mode 100644 extensions/Mageia/template/en/default/hook/global/header-start.html.tmpl create mode 100644 extensions/Mageia/template/en/default/hook/global/variables-end.none.tmpl create mode 100644 extensions/Mageia/template/en/default/hook/index-additional_links.html.tmpl create mode 100644 extensions/Mageia/template/en/default/mageia/README create mode 100644 extensions/Mageia/web/README create mode 100644 extensions/Mageia/web/style.css (limited to 'extensions') diff --git a/extensions/Mageia/Config.pm b/extensions/Mageia/Config.pm new file mode 100644 index 000000000..ce0eae39d --- /dev/null +++ b/extensions/Mageia/Config.pm @@ -0,0 +1,22 @@ +# 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::Mageia; + +use 5.10.1; +use strict; +use warnings; + +use constant NAME => 'Mageia'; + +use constant REQUIRED_MODULES => [ +]; + +use constant OPTIONAL_MODULES => [ +]; + +__PACKAGE__->NAME; diff --git a/extensions/Mageia/Extension.pm b/extensions/Mageia/Extension.pm new file mode 100644 index 000000000..5580e583a --- /dev/null +++ b/extensions/Mageia/Extension.pm @@ -0,0 +1,111 @@ +# 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::Mageia; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Bugzilla::Extension); + +use Bugzilla::Bug qw(LogActivityEntry); +use Bugzilla::Field qw(get_field_id); +use Bugzilla::User qw(); +use Bugzilla::Extension::Mageia::Util; + +use Email::Address; +use Encode qw(encode); + +# Let's match the Bugzilla version it's written for. +our $VERSION = '5.0'; + +# sysadmin-bugs@ml.mageia.org user ID = 175. +use constant SYSADMIN_USER_ID => 175; + +sub bug_end_of_create_validators { + my ($self, $args) = @_; + + # If a user enters 'validated_update' as keyword, + # automatically CC sysadmin-bugs@ml.mageia.org. + my $keywords = $args->{params}->{keywords}; + + if (grep { $_->name eq 'validated_update' } @$keywords) { + my $cc_list = $args->{params}->{cc}; + if (!grep { $_ == SYSADMIN_USER_ID } @$cc_list) { + push(@$cc_list, SYSADMIN_USER_ID); + } + } +} + +sub bug_end_of_update { + my ($self, $args) = @_; + my $bug = $args->{bug}; + my $dbh = Bugzilla->dbh; + my $user = Bugzilla->user; + + # If a user enters 'validated_update' as keyword, + # automatically CC sysadmin-bugs@ml.mageia.org. + my $new_keywords_str = $args->{changes}->{keywords}->[1]; + + if ($new_keywords_str) { + my @new_keywords = split(/[,\s]+/, $new_keywords_str); + if (grep { $_ eq 'validated_update' } @new_keywords + and !grep { $_->id == SYSADMIN_USER_ID } @{$bug->cc_users}) + { + # Safer to clear the cache and let Bugzilla regenerate them if needed. + delete $bug->{cc_users}; + delete $bug->{cc}; + $dbh->do('INSERT INTO cc (bug_id, who) VALUES (?, ?)', + undef, ($bug->id, SYSADMIN_USER_ID)); + + # We also have to update the bug history to reflect this change. + my $changed_cc = $args->{changes}->{cc}; + my $sysadmin_login = Bugzilla::User->new(SYSADMIN_USER_ID)->login; + + if ($changed_cc->[1]) { + $changed_cc->[1] .= ", $sysadmin_login"; + } + else { + $changed_cc->[1] = $sysadmin_login; + } + + my $field_id = get_field_id('cc'); + $dbh->do('DELETE FROM bugs_activity + WHERE bug_id = ? AND bug_when = ? AND fieldid = ?', + undef, ($bug->id, $args->{timestamp}, $field_id)); + + LogActivityEntry($bug->id, 'cc', $changed_cc->[0] // '', $changed_cc->[1], + $user->id, $args->{timestamp}); + } + } +} + +sub enter_bug_entrydefaultvars { + my ($self, $vars) = @_; + my $cgi = Bugzilla->cgi; + + # By default, users should get the guided form when reporting a new bug. + # Pass &normal=1 to the URL to get the official bug form. + my $format = $cgi->param('normal') ? '' : 'guided'; + $cgi->param('format', $format); +} + +sub mailer_before_send { + my ($self, $args) = @_; + my $email = $args->{email}; + + # Include the changer's name in the "From:" field. + if (my $changer = $email->header('X-Bugzilla-Who')) { + $changer = Bugzilla::User->new({ name => $changer }); + return unless $changer; + my $address = Email::Address->new($changer->name, $email->header('From')); + $email->header_set('From', encode('MIME-Header', $address->format)); + } +} + +__PACKAGE__->NAME; diff --git a/extensions/Mageia/lib/Util.pm b/extensions/Mageia/lib/Util.pm new file mode 100644 index 000000000..f13ee2091 --- /dev/null +++ b/extensions/Mageia/lib/Util.pm @@ -0,0 +1,24 @@ +# 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::Mageia::Util; + +use 5.10.1; +use strict; +use warnings; + +use parent qw(Exporter); + +our @EXPORT = qw( +); + +# This file can be loaded by your extension via +# "use Bugzilla::Extension::Mageia::Util". You can put functions +# used by your extension in here. (Make sure you also list them in +# @EXPORT.) + +1; diff --git a/extensions/Mageia/template/en/default/bug/create/comment-guided.txt.tmpl b/extensions/Mageia/template/en/default/bug/create/comment-guided.txt.tmpl new file mode 100644 index 000000000..7b5018e6d --- /dev/null +++ b/extensions/Mageia/template/en/default/bug/create/comment-guided.txt.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. + #%] + +[% USE Bugzilla %] +[% Bugzilla.cgi.param("comment") %] diff --git a/extensions/Mageia/template/en/default/bug/create/create-guided.html.tmpl b/extensions/Mageia/template/en/default/bug/create/create-guided.html.tmpl new file mode 100644 index 000000000..bc86513d1 --- /dev/null +++ b/extensions/Mageia/template/en/default/bug/create/create-guided.html.tmpl @@ -0,0 +1,321 @@ +[%# 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. + #%] + +[%# INTERFACE: + # This template has the same interface as create.html.tmpl + #%] + +[% USE Bugzilla %] +[% cgi = Bugzilla.cgi %] + +[% PROCESS global/header.html.tmpl + title = "Enter $terms.ABug" + onload = "PutDescription()" + style_urls = ['skins/standard/bug.css'] + javascript_urls = ['js/util.js', 'js/field.js'] + yui = ['autocomplete'] + %] + +[% defaultcontent = "Description of problem:\n\n\n" _ + "Version-Release number of selected component (if applicable):\n\n\n" _ + "How reproducible:\n\n\nSteps to Reproduce:\n1.\n2.\n3.\n" %] + +[%# This script displays the descriptions for selected components. %] + + +

+ Submit [% terms.abug %] using the + expert [% terms.bug %] form. +

+ +
+ + + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.product %] + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.component editable = 1 %] + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.version editable = 1 %] + + + + + [% INCLUDE bug/field.html.tmpl + bug = default, field = bug_fields.rep_platform, editable = 1, + value = default.rep_platform %] + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.cf_rpmpkg editable = 1 %] + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.bug_file_loc editable = 1 %] + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.short_desc editable = 1 %] + + + + + + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.bug_severity editable = 1 %] + + + + + [% INCLUDE "bug/field-label.html.tmpl" field = bug_fields.assigned_to editable = 1 %] + + + + [% Hook.process('form') %] +
+ + [% product.name FILTER html %] +
+ + +
+ Select a component to see its description here. +
+ +

+ The area where the problem occurs. + To pick the right component, you could use the same one as + similar [% terms.bugs %] you found in your search, or read the full list of + component descriptions (opens in new window) if + you need more help. +

+
+ + +

+ The version in which the problem occurs. +

+
+ +

+ This is where you can identify exactly which RPM package is involved in + this [% terms.bug %] report. For instance, if you know the problem you + are having is with the program mysqld, then execute + rpm -qif /usr/sbin/mysqld. This will tell you the name and version + of the RPM package (i.e. mariadb-core-10.0.23-1.mga5) as well as other + information. In particular, you are looking for the "Source RPM" field + (i.e. mariadb-10.0.23-1.mga5.src.rpm) -- this is the information you should + provide here. Alternatively, you may use + rpm -qf /usr/sbin/mysqld --qf '%{SOURCERPM}\n' to obtain the + information. If you do not know the location of the program in question, + use rpm -qf `which mysqld` to obtain it. Please enter that + information above. +

+
+ +

+ URL that demonstrates the problem you are submitting (optional). +

+
+ +

+ A sentence which summarizes the problem. + Please be descriptive and use lots of keywords. +

+

+ + Bad example: mail crashed + +
+ + Good example: + crash in Evolution while checking for new POP mail + +

+
Details + [% INCLUDE global/textarea.html.tmpl + id = 'comment' + name = 'comment' + minrows = 13 + cols = constants.COMMENT_COLS + mandatory = 1 + defaultcontent = defaultcontent + %] + + [% IF user.is_insider %] +
+ + + + [% END %] +

+ Expand on the Summary. Please be as specific as possible about what is wrong. +

+

+ + Bad example: I can't seem to login to the system. Please help! + +
+ + Good example: Description of problem: +

+ I'm unable to login to the system via ssh. The /var/log/messages log + indicates there is a problem with the pam module pam_ldap, but the + /etc/pam.d/system-auth file doesn't contain that module and I'm not + using LDAP. I looked at /etc/pam.d/sshd and it does contain that module + but I'm not sure how it got there, unless it was due to the super-spiffy + super-ldap-mojo package I installed yesterday. +

+ Version-Release number of selected component (if applicable): +

+ openldap-2.4.40-3.1.mga5, pam-1.1.8-10.1.mga5 +

+ How reproducible: +

+ Every time I attempt to login. +

+ Steps to Reproduce:
+ 1. ssh user@host
+ 2. see the rejection +
+

+
+ +

+ Indicate how serious the problem is, or if your [% terms.bug %] is a + request for a new feature. +

+
+ [% INCLUDE global/userselect.html.tmpl + id => "assigned_to" + name => "assigned_to" + value => assigned_to + disabled => assigned_to_disabled + size => 30 + emptyok => 1 + %] +

Leave blank to assign to the default component owner.

+
+ +

+ +

+ +

+ That's it! Thanks very much. You'll be notified by email about any progress + that is made on fixing your [% terms.bug %]. Thank you for choosing Mageia! +

+ +
+ +[% PROCESS global/footer.html.tmpl %] + +[%############################################################################%] +[%# Block for SELECT fields #%] +[%############################################################################%] + +[% BLOCK select %] + +[% END %] diff --git a/extensions/Mageia/template/en/default/global/banner.html.tmpl b/extensions/Mageia/template/en/default/global/banner.html.tmpl new file mode 100644 index 000000000..76f1d123e --- /dev/null +++ b/extensions/Mageia/template/en/default/global/banner.html.tmpl @@ -0,0 +1,11 @@ +[%# 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. + #%] + + + + diff --git a/extensions/Mageia/template/en/default/hook/README b/extensions/Mageia/template/en/default/hook/README new file mode 100644 index 000000000..e6c4add58 --- /dev/null +++ b/extensions/Mageia/template/en/default/hook/README @@ -0,0 +1,5 @@ +Template hooks go in this directory. Template hooks are called in normal +Bugzilla templates like [% Hook.process('some-hook') %]. +More information about them can be found in the documentation of +Bugzilla::Extension. (Do "perldoc Bugzilla::Extension" from the main +Bugzilla directory to see that documentation.) \ No newline at end of file diff --git a/extensions/Mageia/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl b/extensions/Mageia/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl new file mode 100644 index 000000000..675af49f1 --- /dev/null +++ b/extensions/Mageia/template/en/default/hook/account/auth/login-small-additional_methods.html.tmpl @@ -0,0 +1,23 @@ +[%# 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. + #%] + +[% UNLESS user.id %] + [% UNLESS Param('createemailregexp') AND user.authorizer.user_can_create_account %] +
  • + | + New Account +
  • + [% END %] + + [% UNLESS user.authorizer.can_change_password %] +
  • + | + Forgot Password +
  • + [% END %] +[% END %] diff --git a/extensions/Mageia/template/en/default/hook/global/header-start.html.tmpl b/extensions/Mageia/template/en/default/hook/global/header-start.html.tmpl new file mode 100644 index 000000000..01fab7fab --- /dev/null +++ b/extensions/Mageia/template/en/default/hook/global/header-start.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. + #%] + +[% favicon_url = "https://www.mageia.org/g/favicon.png" %] +[% style_urls.push("extensions/Mageia/web/style.css") %] diff --git a/extensions/Mageia/template/en/default/hook/global/variables-end.none.tmpl b/extensions/Mageia/template/en/default/hook/global/variables-end.none.tmpl new file mode 100644 index 000000000..4f651a5ae --- /dev/null +++ b/extensions/Mageia/template/en/default/hook/global/variables-end.none.tmpl @@ -0,0 +1,9 @@ +[%# 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. + #%] + +[% terms.Bugzilla = "Mageia Bugzilla" %] diff --git a/extensions/Mageia/template/en/default/hook/index-additional_links.html.tmpl b/extensions/Mageia/template/en/default/hook/index-additional_links.html.tmpl new file mode 100644 index 000000000..3c2585887 --- /dev/null +++ b/extensions/Mageia/template/en/default/hook/index-additional_links.html.tmpl @@ -0,0 +1,14 @@ +[%# 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. + #%] + +[% UNLESS user.id %] +

    + Don't have an account on [% terms.Bugzilla %]? + Create one. +

    +[% END %] diff --git a/extensions/Mageia/template/en/default/mageia/README b/extensions/Mageia/template/en/default/mageia/README new file mode 100644 index 000000000..099d1a41a --- /dev/null +++ b/extensions/Mageia/template/en/default/mageia/README @@ -0,0 +1,16 @@ +Normal templates go in this directory. You can load them in your +code like this: + +use Bugzilla::Error; +my $template = Bugzilla->template; +$template->process('mageia/some-template.html.tmpl') + or ThrowTemplateError($template->error()); + +That would be how to load a file called some-template.html.tmpl that +was in this directory. + +Note that you have to be careful that the full path of your template +never conflicts with a template that exists in Bugzilla or in +another extension, or your template might override that template. That's why +we created this directory called 'mageia' for you, so you +can put your templates in here to help avoid conflicts. \ No newline at end of file diff --git a/extensions/Mageia/web/README b/extensions/Mageia/web/README new file mode 100644 index 000000000..c3c41862f --- /dev/null +++ b/extensions/Mageia/web/README @@ -0,0 +1,7 @@ +Web-accessible files, like JavaScript, CSS, and images go in this +directory. You can reference them directly in your HTML. For example, +if you have a file called "style.css" and your extension is called +"Mageia", you would put it in "extensions/Mageia/web/style.css", and then +you could link to it in HTML like: + + diff --git a/extensions/Mageia/web/style.css b/extensions/Mageia/web/style.css new file mode 100644 index 000000000..b43d174d8 --- /dev/null +++ b/extensions/Mageia/web/style.css @@ -0,0 +1,31 @@ +/* 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. + */ + +body { + margin: 0; + padding-top: 0; + background-color: #fff !important; +} + +#create_account { + border: solid 1px; + background-color: #ffd386; + color: #9b1a1a; + padding: 1em; + text-align: center; + max-width: 30em; + margin: 1em auto; +} + +#guided_form { + padding: 1em; +} + +#guided_form .field_label { + white-space: nowrap; +} -- cgit v1.2.1