Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
bugzilla
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
etersoft
bugzilla
Commits
a7196a73
Commit
a7196a73
authored
Feb 11, 2010
by
Max Kanat-Alexander
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 545715: New Hook: bugmail_relationships
r=mkanat, a=mkanat (module owner)
parent
5721ab05
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
21 deletions
+78
-21
BugMail.pm
Bugzilla/BugMail.pm
+12
-13
Constants.pm
Bugzilla/Constants.pm
+12
-2
Hook.pm
Bugzilla/Hook.pm
+27
-0
User.pm
Bugzilla/User.pm
+3
-1
Extension.pm
extensions/Example/Extension.pm
+21
-4
userprefs.cgi
userprefs.cgi
+3
-1
No files found.
Bugzilla/BugMail.pm
View file @
a7196a73
...
...
@@ -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
;
...
...
Bugzilla/Constants.pm
View file @
a7196a73
...
...
@@ -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
;
...
...
Bugzilla/Hook.pm
View file @
a7196a73
...
...
@@ -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
...
...
Bugzilla/User.pm
View file @
a7196a73
...
...
@@ -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.
#
...
...
extensions/Example/Extension.pm
View file @
a7196a73
...
...
@@ -36,6 +36,9 @@ use Bugzilla::Extension::Example::Util;
use
Data::
Dumper
;
# See bugmail_relationships.
use
constant
REL_EXAMPLE
=>
-
127
;
our
$VERSION
=
'1.0'
;
sub
attachment_process_data
{
...
...
@@ -193,14 +196,28 @@ sub bugmail_recipients {
my
(
$self
,
$args
)
=
@_
;
my
$recipients
=
$args
->
{
recipients
};
my
$bug
=
$args
->
{
bug
};
my
$user
=
new
Bugzilla::
User
({
name
=>
Bugzilla
->
params
->
{
'maintainer'
}
});
if
(
$bug
->
id
==
1
)
{
# Uncomment the line below to add the second user in the Bugzilla
# database to the recipients list of every bugmail sent out about
# bug 1 as though that user were on the CC list.
#$recipients->{2}->{+REL_CC} = 1;
# Uncomment the line below to add the maintainer to the recipients
# list of every bugmail from bug 1 as though that the maintainer
# 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.
#$recipients->{$user->id}->{+REL_EXAMPLE} = 1;
}
}
sub
bugmail_relationships
{
my
(
$self
,
$args
)
=
@_
;
my
$relationships
=
$args
->
{
relationships
};
$relationships
->
{
+
REL_EXAMPLE
}
=
'Example'
;
}
sub
colchange_columns
{
my
(
$self
,
$args
)
=
@_
;
...
...
userprefs.cgi
View file @
a7196a73
...
...
@@ -27,6 +27,7 @@ use strict;
use
lib
qw(. lib)
;
use
Bugzilla
;
use
Bugzilla::
BugMail
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Search
;
use
Bugzilla::
Util
;
...
...
@@ -261,7 +262,8 @@ sub SaveEmail {
# relationship/event matrix.
# Note: the database holds only "off" email preferences, as can be implied
# from the name of the table - profiles_nomail.
foreach
my
$rel
(
RELATIONSHIPS
)
{
my
%
relationships
=
Bugzilla::BugMail::
relationships
();
foreach
my
$rel
(
keys
%
relationships
)
{
# Positive events: a ticked box means "send me mail."
foreach
my
$event
(
POS_EVENTS
)
{
if
(
defined
(
$cgi
->
param
(
"email-$rel-$event"
))
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment