summaryrefslogtreecommitdiffstats
path: root/extensions/RequestWhiner
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/RequestWhiner')
-rw-r--r--extensions/RequestWhiner/Config.pm33
-rw-r--r--extensions/RequestWhiner/Extension.pm43
-rwxr-xr-xextensions/RequestWhiner/bin/whineatrequests.pl155
-rw-r--r--extensions/RequestWhiner/lib/Constants.pm31
-rw-r--r--extensions/RequestWhiner/template/en/default/requestwhiner/header.txt.tmpl6
-rw-r--r--extensions/RequestWhiner/template/en/default/requestwhiner/mail.html.tmpl62
-rw-r--r--extensions/RequestWhiner/template/en/default/requestwhiner/mail.txt.tmpl41
7 files changed, 371 insertions, 0 deletions
diff --git a/extensions/RequestWhiner/Config.pm b/extensions/RequestWhiner/Config.pm
new file mode 100644
index 000000000..fb08bd7af
--- /dev/null
+++ b/extensions/RequestWhiner/Config.pm
@@ -0,0 +1,33 @@
+# -*- 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 RequestWhiner Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is Gervase Markham
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Gervase Markham <written.to.the.glory.of.god@gerv.net>
+
+package Bugzilla::Extension::RequestWhiner;
+use strict;
+
+use constant NAME => 'RequestWhiner';
+
+use constant REQUIRED_MODULES => [
+];
+
+use constant OPTIONAL_MODULES => [
+];
+
+__PACKAGE__->NAME; \ No newline at end of file
diff --git a/extensions/RequestWhiner/Extension.pm b/extensions/RequestWhiner/Extension.pm
new file mode 100644
index 000000000..3f1ee1f27
--- /dev/null
+++ b/extensions/RequestWhiner/Extension.pm
@@ -0,0 +1,43 @@
+# -*- 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 RequestWhiner Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is the Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Gervase Markham <written.to.the.glory.of.god@gerv.net>
+
+package Bugzilla::Extension::RequestWhiner;
+use strict;
+use base qw(Bugzilla::Extension);
+
+use Bugzilla::Constants qw(bz_locations);
+use Bugzilla::Install::Filesystem;
+
+our $VERSION = '0.01';
+
+sub install_filesystem {
+ my ($self, $args) = @_;
+ my $files = $args->{'files'};
+
+ my $extensionsdir = bz_locations()->{'extensionsdir'};
+ my $scriptname = $extensionsdir . "/" . __PACKAGE__->NAME . "/bin/whineatrequests.pl";
+
+ $files->{$scriptname} = {
+ perms => Bugzilla::Install::Filesystem::WS_EXECUTE
+ };
+}
+
+__PACKAGE__->NAME;
diff --git a/extensions/RequestWhiner/bin/whineatrequests.pl b/extensions/RequestWhiner/bin/whineatrequests.pl
new file mode 100755
index 000000000..f7cb61dbb
--- /dev/null
+++ b/extensions/RequestWhiner/bin/whineatrequests.pl
@@ -0,0 +1,155 @@
+#!/usr/bin/perl -wT
+# -*- 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 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): Erik Stambaugh <erik@dasbistro.com>
+# Gervase Markham <gerv@gerv.net>
+
+use strict;
+
+BEGIN {
+ use lib qw(lib .);
+ use Bugzilla;
+ Bugzilla->extensions;
+}
+
+use lib qw(. lib);
+
+use Bugzilla;
+use Bugzilla::User;
+use Bugzilla::Mailer;
+use Email::MIME;
+
+use Bugzilla::Extension::RequestWhiner::Constants;
+
+my $dbh = Bugzilla->dbh;
+
+my $sth_get_requests =
+ $dbh->prepare("SELECT profiles.login_name,
+ flagtypes.name,
+ flags.attach_id,
+ bugs.bug_id,
+ bugs.short_desc, " .
+ $dbh->sql_to_days('NOW()') .
+ " - " .
+ $dbh->sql_to_days('flags.modification_date') . "
+ AS age_in_days
+ FROM flags
+ JOIN bugs ON bugs.bug_id = flags.bug_id,
+ flagtypes,
+ profiles
+ WHERE flags.status = '?'
+ AND flags.requestee_id = profiles.userid
+ AND flags.type_id = flagtypes.id
+ AND " . $dbh->sql_to_days('NOW()') .
+ " - " .
+ $dbh->sql_to_days('flags.modification_date') .
+ " > " .
+ WHINE_AFTER_DAYS . "
+ ORDER BY flags.modification_date");
+
+$sth_get_requests->execute();
+
+# Build data structure
+my $requests = {};
+
+while (my ($login_name,
+ $flag_name,
+ $attach_id,
+ $bug_id,
+ $short_desc,
+ $age_in_days) = $sth_get_requests->fetchrow_array())
+{
+ if (!defined($requests->{$login_name})) {
+ $requests->{$login_name} = {};
+ }
+
+ if (!defined($requests->{$login_name}->{$flag_name})) {
+ $requests->{$login_name}->{$flag_name} = [];
+ }
+
+ push(@{ $requests->{$login_name}->{$flag_name} }, {
+ bug_id => $bug_id,
+ attach_id => $attach_id,
+ summary => $short_desc,
+ age => $age_in_days
+ });
+}
+
+$sth_get_requests->finish();
+
+foreach my $recipient (keys %$requests) {
+ my $user = new Bugzilla::User({ name => $recipient });
+
+ next if $user->email_disabled;
+
+ mail({
+ from => Bugzilla->params->{'mailfrom'},
+ recipient => $user,
+ subject => "Your Outstanding Requests",
+ requests => $requests->{$recipient},
+ threshold => WHINE_AFTER_DAYS
+ });
+}
+
+exit;
+
+###############################################################################
+# Functions
+#
+# Note: this function is exactly the same as the one in whine.pl, just using
+# different templates for the messages themselves.
+###############################################################################
+sub mail {
+ my $args = shift;
+ my $addressee = $args->{recipient};
+ my $template = Bugzilla->template;
+ my ($content, @parts);
+
+ $template->process("requestwhiner/mail.txt.tmpl", $args, \$content)
+ || die($template->error());
+ push(@parts, Email::MIME->create(
+ attributes => {
+ content_type => "text/plain",
+ },
+ body => $content,
+ ));
+
+ $content = '';
+ $template->process("requestwhiner/mail.html.tmpl", $args, \$content)
+ || die($template->error());
+
+ push(@parts, Email::MIME->create(
+ attributes => {
+ content_type => "text/html",
+ },
+ body => $content,
+ ));
+
+ $content = '';
+ $template->process("requestwhiner/header.txt.tmpl", $args, \$content)
+ || die($template->error());
+
+ # TT trims the trailing newline
+ my $email = new Email::MIME("$content\n");
+ $email->content_type_set('multipart/alternative');
+ $email->parts_set(\@parts);
+
+ MessageToMTA($email);
+}
diff --git a/extensions/RequestWhiner/lib/Constants.pm b/extensions/RequestWhiner/lib/Constants.pm
new file mode 100644
index 000000000..0e24ae1f0
--- /dev/null
+++ b/extensions/RequestWhiner/lib/Constants.pm
@@ -0,0 +1,31 @@
+# -*- 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 RequestWhiner Bugzilla Extension.
+#
+# The Initial Developer of the Original Code is the Mozilla Foundation.
+# Portions created by the Initial Developer are Copyright (C) 2011 the
+# Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+# Gervase Markham <written.to.the.glory.of.god@gerv.net>
+
+package Bugzilla::Extension::RequestWhiner::Constants;
+use strict;
+use base qw(Exporter);
+our @EXPORT = qw(
+ WHINE_AFTER_DAYS
+);
+
+use constant WHINE_AFTER_DAYS => 7;
+
+1;
diff --git a/extensions/RequestWhiner/template/en/default/requestwhiner/header.txt.tmpl b/extensions/RequestWhiner/template/en/default/requestwhiner/header.txt.tmpl
new file mode 100644
index 000000000..390fd3e2f
--- /dev/null
+++ b/extensions/RequestWhiner/template/en/default/requestwhiner/header.txt.tmpl
@@ -0,0 +1,6 @@
+[% PROCESS global/variables.none.tmpl %]
+From: [% from %]
+To: [% recipient.email %]
+Subject: [[% terms.Bugzilla %]] [% subject %]
+X-Bugzilla-Type: whine
+
diff --git a/extensions/RequestWhiner/template/en/default/requestwhiner/mail.html.tmpl b/extensions/RequestWhiner/template/en/default/requestwhiner/mail.html.tmpl
new file mode 100644
index 000000000..07b2b31ee
--- /dev/null
+++ b/extensions/RequestWhiner/template/en/default/requestwhiner/mail.html.tmpl
@@ -0,0 +1,62 @@
+[%# 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 RequestWhiner Bugzilla Extension.
+ #
+ # The Initial Developer of the Original Code is Gervase Markham
+ # Portions created by the Initial Developer are Copyright (C) 2011 the
+ # Initial Developer. All Rights Reserved.
+ #
+ # Contributor(s): Gervase Markham <written.to.the.glory.of.god@gerv.net>
+ #%]
+
+[% PROCESS global/variables.none.tmpl %]
+[% PROCESS 'global/field-descs.none.tmpl' %]
+
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+ <head>
+ <title>
+ [[% terms.Bugzilla %]] [% subject FILTER html %]
+ </title>
+ </head>
+ <body bgcolor="#FFFFFF">
+
+<p>The following is a list of requests people have made of you, which have been
+outstanding more than [% threshold FILTER html %] days. To avoid disappointing
+others, please deal with them as quickly as possible.
+(<a href="https://wiki.mozilla.org/BMO/Handling_Requests">Here is some
+guidance on handling requests</a>.)
+</p>
+
+[% FOREACH request_type = requests.keys %]
+<h3>[% request_type FILTER html %]</h3>
+
+<ul>
+ [% FOREACH request = requests.$request_type %]
+ <li>
+ <a href="[% urlbase FILTER none %]show_bug.cgi?id=[% request.bug_id FILTER none %]">[% terms.Bug %]
+ [%+ request.bug_id FILTER none %]: [% request.summary FILTER html %]</a> ([% request.age FILTER none %] days old)
+ [% IF request.attach_id %]
+ <br>
+ <small>(<a href="[% urlbase FILTER none %]attachment.cgi?id=[% request.attach_id FILTER none %]&action=edit">Details</a> |
+ <a href="[% urlbase FILTER none %]attachment.cgi?id=[% request.attach_id FILTER none %]&action=diff">Diff</a> |
+ <a href="[% urlbase FILTER none %]page.cgi?id=splinter.html&bug=[% request.bug_id FILTER none %]&attachment=[% request.attach_id FILTER none %]">Splinter Review</a>)</small>
+ [% END %]
+ </li>
+ [% END %]
+</ul>
+
+[% END %]
+
+<p><a href="[% urlbase FILTER none %]request.cgi?action=queue&requestee=[% recipient.email FILTER uri %]&group=type">See all your outstanding requests</a>.</p>
+
+ </body>
+</html>
diff --git a/extensions/RequestWhiner/template/en/default/requestwhiner/mail.txt.tmpl b/extensions/RequestWhiner/template/en/default/requestwhiner/mail.txt.tmpl
new file mode 100644
index 000000000..ef21563c9
--- /dev/null
+++ b/extensions/RequestWhiner/template/en/default/requestwhiner/mail.txt.tmpl
@@ -0,0 +1,41 @@
+[%# 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 RequestWhiner Bugzilla Extension.
+ #
+ # The Initial Developer of the Original Code is Gervase Markham
+ # Portions created by the Initial Developer are Copyright (C) 2011 the
+ # Initial Developer. All Rights Reserved.
+ #
+ # Contributor(s): Gervase Markham <written.to.the.glory.of.god@gerv.net>
+ #%]
+
+[% PROCESS global/variables.none.tmpl %]
+[% PROCESS 'global/field-descs.none.tmpl' %]
+
+The following is a list of requests people have made of you, which have been
+outstanding more than [% threshold %] days. To avoid disappointing others, please deal with
+them as quickly as possible. Here is some guidance on handling requests:
+ https://wiki.mozilla.org/BMO/Handling_Requests
+
+[% FOREACH request_type = requests.keys %]
+[%+ request_type +%]
+[%+ "-" FILTER repeat(request_type.length) +%]
+
+ [% FOREACH request = requests.$request_type %]
+ [%+ terms.Bug +%] [%+ request.bug_id %]: [% request.summary +%] ([% request.age %] days old)
+ [%+ urlbase %]show_bug.cgi?id=[% request.bug_id +%]
+ [% IF request.attach_id %]
+ [%+ urlbase %]attachment.cgi?id=[% request.attach_id %]&action=edit
+ [% END %]
+ [%+ END +%]
+[% END %]
+To see all your outstanding requests, visit:
+[%+ urlbase %]request.cgi?action=queue&requestee=[% recipient.email FILTER url %]&group=type