summaryrefslogtreecommitdiffstats
path: root/Bugzilla
diff options
context:
space:
mode:
authorMax Kanat-Alexander <mkanat@bugzilla.org>2010-02-11 21:32:08 +0100
committerMax Kanat-Alexander <mkanat@bugzilla.org>2010-02-11 21:32:08 +0100
commita7196a73cec5af3aa91f0af93d6316df1db7f433 (patch)
tree626dbd7866fb497f063767868d8c428a30d8b8f6 /Bugzilla
parent5721ab05a01ea3dacfc6f07669469b3868a4df06 (diff)
downloadbugzilla-a7196a73cec5af3aa91f0af93d6316df1db7f433.tar.gz
bugzilla-a7196a73cec5af3aa91f0af93d6316df1db7f433.tar.xz
Bug 545715: New Hook: bugmail_relationships
r=mkanat, a=mkanat (module owner)
Diffstat (limited to 'Bugzilla')
-rw-r--r--Bugzilla/BugMail.pm25
-rw-r--r--Bugzilla/Constants.pm14
-rw-r--r--Bugzilla/Hook.pm27
-rw-r--r--Bugzilla/User.pm4
4 files changed, 54 insertions, 16 deletions
diff --git a/Bugzilla/BugMail.pm b/Bugzilla/BugMail.pm
index b718f4199..204c4ba9a 100644
--- a/Bugzilla/BugMail.pm
+++ b/Bugzilla/BugMail.pm
@@ -55,17 +55,6 @@ use constant FORMAT_2_SIZE => [19,55];
use constant BIT_DIRECT => 1;
use constant BIT_WATCHING => 2;
-# We need these strings for the X-Bugzilla-Reasons header
-# Note: this hash uses "," rather than "=>" to avoid auto-quoting of the LHS.
-use constant REL_NAMES => {
- REL_ASSIGNEE , "AssignedTo",
- REL_REPORTER , "Reporter",
- REL_QA , "QAcontact",
- REL_CC , "CC",
- REL_VOTER , "Voter",
- REL_GLOBAL_WATCHER, "GlobalWatcher"
-};
-
# We use this instead of format because format doesn't deal well with
# multi-byte languages.
sub multiline_sprintf {
@@ -100,6 +89,15 @@ sub three_columns {
return multiline_sprintf(FORMAT_TRIPLE, \@_, FORMAT_3_SIZE);
}
+sub relationships {
+ my $ref = RELATIONSHIPS;
+ # Clone it so that we don't modify the constant;
+ my %relationships = %$ref;
+ Bugzilla::Hook::process('bugmail_relationships',
+ { relationships => \%relationships });
+ return %relationships;
+}
+
# This is a bit of a hack, basically keeping the old system()
# cmd line interface. Should clean this up at some point.
#
@@ -615,8 +613,9 @@ sub sendMail {
push(@reasons_watch, $relationship) if ($bits & BIT_WATCHING);
}
- my @headerrel = map { REL_NAMES->{$_} } @reasons;
- my @watchingrel = map { REL_NAMES->{$_} } @reasons_watch;
+ my %relationships = relationships();
+ my @headerrel = map { $relationships{$_} } @reasons;
+ my @watchingrel = map { $relationships{$_} } @reasons_watch;
push(@headerrel, 'None') unless @headerrel;
push(@watchingrel, 'None') unless @watchingrel;
push @watchingrel, map { user_id_to_login($_) } @$watchingRef;
diff --git a/Bugzilla/Constants.pm b/Bugzilla/Constants.pm
index 948ff5337..8ab7455ff 100644
--- a/Bugzilla/Constants.pm
+++ b/Bugzilla/Constants.pm
@@ -298,8 +298,18 @@ use constant REL_CC => 3;
use constant REL_VOTER => 4;
use constant REL_GLOBAL_WATCHER => 5;
-use constant RELATIONSHIPS => REL_ASSIGNEE, REL_QA, REL_REPORTER, REL_CC,
- REL_VOTER, REL_GLOBAL_WATCHER;
+# We need these strings for the X-Bugzilla-Reasons header
+# Note: this hash uses "," rather than "=>" to avoid auto-quoting of the LHS.
+# This should be accessed through Bugzilla::BugMail::relationships() instead
+# of being accessed directly.
+use constant RELATIONSHIPS => {
+ REL_ASSIGNEE , "AssignedTo",
+ REL_REPORTER , "Reporter",
+ REL_QA , "QAcontact",
+ REL_CC , "CC",
+ REL_VOTER , "Voter",
+ REL_GLOBAL_WATCHER, "GlobalWatcher"
+};
# Used for global events like EVT_FLAG_REQUESTED
use constant REL_ANY => 100;
diff --git a/Bugzilla/Hook.pm b/Bugzilla/Hook.pm
index cf718c94f..a02a04921 100644
--- a/Bugzilla/Hook.pm
+++ b/Bugzilla/Hook.pm
@@ -398,6 +398,33 @@ instead of as a string.)
=back
+=head2 bugmail_relationships
+
+There are various sorts of "relationships" that a user can have to a bug,
+such as Assignee, CC, etc. If you want to add a new type of relationship,
+you should use this hook.
+
+Params:
+
+=over
+
+=item C<relationships>
+
+A hashref, where the keys are numbers and the values are strings.
+
+The keys represent a numeric identifier for the relationship. The
+numeric identifier should be a negative number between -1 and -127.
+The number must be unique across all extensions. (Negative numbers
+are used so as not to conflict with relationship identifiers in Bugzilla
+itself.)
+
+The value is the "name" of this relationship that will show up in email
+headers in bugmails. The "name" should be short and should contain no
+spaces.
+
+=back
+
+
=head2 colchange_columns
This happens in F<colchange.cgi> right after the list of possible display
diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm
index e0c5b132f..240fcfcdb 100644
--- a/Bugzilla/User.pm
+++ b/Bugzilla/User.pm
@@ -1568,7 +1568,9 @@ sub create {
my $user = $class->SUPER::create(@_);
# Turn on all email for the new user
- foreach my $rel (RELATIONSHIPS) {
+ require Bugzilla::BugMail;
+ my %relationships = Bugzilla::BugMail::relationships();
+ foreach my $rel (keys %relationships) {
foreach my $event (POS_EVENTS, NEG_EVENTS) {
# These "exceptions" define the default email preferences.
#