diff options
author | Dave Lawrence <dlawrence@mozilla.com> | 2013-11-01 15:51:32 +0100 |
---|---|---|
committer | Dave Lawrence <dlawrence@mozilla.com> | 2013-11-01 15:51:32 +0100 |
commit | c373d57e5911436cb15006ea88e685abda0a6b6f (patch) | |
tree | 22f9a16e174504f723f3bfc493c319e2e616a658 /extensions/Ember | |
parent | bd1256280cdd82347188a00d2b203ff5202ecc86 (diff) | |
download | bugzilla-c373d57e5911436cb15006ea88e685abda0a6b6f.tar.gz bugzilla-c373d57e5911436cb15006ea88e685abda0a6b6f.tar.xz |
Bug 921219 - Include status and summary for bugs listed in `depends_on` and `blocks` fields
r=glob
Diffstat (limited to 'extensions/Ember')
-rw-r--r-- | extensions/Ember/lib/WebService.pm | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/extensions/Ember/lib/WebService.pm b/extensions/Ember/lib/WebService.pm index 854a94689..0e9505fb8 100644 --- a/extensions/Ember/lib/WebService.pm +++ b/extensions/Ember/lib/WebService.pm @@ -113,12 +113,13 @@ sub show { my ($self, $params) = @_; my (@fields, $attachments, $comments, $data); my $dbh = Bugzilla->dbh; + my $user = Bugzilla->user; Bugzilla->switch_to_shadow_db(); # Throw error if token was provided and user is not logged # in meaning token was invalid/expired. - if (exists $params->{token} && !Bugzilla->user->id) { + if (exists $params->{token} && !$user->id) { ThrowUserError('invalid_token'); } @@ -177,7 +178,34 @@ sub show { # Place the fields current value along with the field definition foreach my $field (@fields) { - $field->{current_value} = delete $bug_hash->{$field->{name}} || ''; + if (($field->{name} eq 'depends_on' + || $field->{name} eq 'blocks') + && scalar @{ $bug_hash->{$field->{name}} }) + { + my $bug_ids = $bug_hash->{$field->{name}}; + $user->visible_bugs($bug_ids); + my $bug_objs = Bugzilla::Bug->new_from_list($bug_ids); + + my @new_list; + foreach my $bug (@$bug_objs) { + my $data; + if ($user->can_see_bug($bug)) { + $data = { + id => $bug->id, + status => $bug->bug_status, + summary => $bug->short_desc + }; + } + else { + $data = { id => $bug->id }; + } + push(@new_list, $data); + } + $field->{current_value} = \@new_list; + } + else { + $field->{current_value} = delete $bug_hash->{$field->{name}} || ''; + } } # Any left over bug values will be added to the field list |