From 464be059d311db4a1bc15933ba007f45f76c11a0 Mon Sep 17 00:00:00 2001 From: "David Lawrence [:dkl]" Date: Tue, 17 Jun 2014 15:52:16 +0800 Subject: Bug 649691: Add a "mentor" and "mentored bug type" field to b.m.o --- Bugzilla/Search.pm | 10 +++++++++- Bugzilla/User.pm | 3 +++ Bugzilla/WebService/Bug.pm | 8 ++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 519ebe69f..356af1870 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -384,6 +384,9 @@ sub SPECIAL_PARSING { # last_visit field that accept both a 1d, 1w, 1m, 1y format and the # %last_changed% pronoun. last_visit_ts => \&_last_visit_datetime, + + # BMO - Add ability to use pronoun for bug mentors field + bug_mentor => \&_commenter_pronoun, }; foreach my $field (Bugzilla->active_custom_fields) { if ($field->type == FIELD_TYPE_DATETIME) { @@ -425,6 +428,11 @@ use constant USER_FIELDS => { field => 'setter_id', join => { table => 'flags' }, }, + # BMO - Ability to search for bugs with specific mentors + 'bug_mentor' => { + field => 'user_id', + join => { table => 'bug_mentors' }, + } }; # Backwards compatibility for times that we changed the names of fields @@ -1701,7 +1709,7 @@ sub _special_parse_email { $type = "anyexact" if $type eq "exact"; my $or_clause = new Bugzilla::Search::Clause('OR'); - foreach my $field (qw(assigned_to reporter cc qa_contact)) { + foreach my $field (qw(assigned_to reporter cc qa_contact bug_mentor)) { if ($params->{"email$field$id"}) { $or_clause->add($field, $type, $email); } diff --git a/Bugzilla/User.pm b/Bugzilla/User.pm index f707a8e80..8526c42d7 100644 --- a/Bugzilla/User.pm +++ b/Bugzilla/User.pm @@ -775,6 +775,9 @@ sub is_involved_in_bug { return 1 if $user_id == $bug->qa_contact->id; } + # BMO - Bug mentors are considered involved with the bug + return 1 if $bug->is_mentor($self); + return unless $bug->cc; return any { $user_login eq $_ } @{ $bug->cc }; } diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index a82f55d3b..0a8145d37 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -1376,6 +1376,14 @@ sub _bug_to_hash { $item{'is_creator_accessible'} = $self->type('boolean', $bug->reporter_accessible); } + # BMO - support for special mentors field + if (filter_wants $params, 'mentors') { + $item{'mentors'} + = [ map { $self->type('email', $_->login) } @{ $bug->mentors || [] } ]; + $item{'mentors_detail'} + = [ map { $self->_user_to_hash($_, $params, undef, 'mentors') } @{ $bug->mentors } ]; + } + return \%item; } -- cgit v1.2.3-24-g4f1b