From 7118a8392a67ea5e28034ed77ee0b80e34f42d49 Mon Sep 17 00:00:00 2001 From: Dave Lawrence Date: Tue, 14 Feb 2012 17:42:32 -0500 Subject: Bug 714343 - Add ability to get flag information for bugs and attachments via the web service r=glob, r=LpSolit --- Bugzilla/WebService/Bug.pm | 120 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 116 insertions(+), 4 deletions(-) diff --git a/Bugzilla/WebService/Bug.pm b/Bugzilla/WebService/Bug.pm index ca9ee1014..c83ed5b5f 100644 --- a/Bugzilla/WebService/Bug.pm +++ b/Bugzilla/WebService/Bug.pm @@ -922,6 +922,9 @@ sub _bug_to_hash { @{ $bug->see_also }; $item{'see_also'} = \@see_also; } + if (filter_wants $params, 'flags') { + $item{'flags'} = [ map { $self->_flag_to_hash($_) } @{$bug->flags} ]; + } # And now custom fields my @custom_fields = Bugzilla->active_custom_fields; @@ -970,9 +973,6 @@ sub _bug_to_hash { sub _attachment_to_hash { my ($self, $attach, $filters) = @_; - # Skipping attachment flags for now. - delete $attach->{flags}; - my $item = filter $filters, { creation_time => $self->type('dateTime', $attach->attached), last_change_time => $self->type('dateTime', $attach->modification_time), @@ -999,6 +999,31 @@ sub _attachment_to_hash { $item->{'data'} = $self->type('base64', $attach->data); } + if (filter_wants $filters, 'flags') { + $item->{'flags'} = [ map { $self->_flag_to_hash($_) } @{$attach->flags} ]; + } + + return $item; +} + +sub _flag_to_hash { + my ($self, $flag) = @_; + + my $item = { + id => $self->type('int', $flag->id), + name => $self->type('string', $flag->name), + type_id => $self->type('int', $flag->type_id), + creation_date => $self->type('dateTime', $flag->creation_date), + modification_date => $self->type('dateTime', $flag->modification_date), + status => $self->type('string', $flag->status) + }; + + foreach my $field (qw(setter requestee)) { + my $field_id = $field . "_id"; + $item->{$field} = $self->type('string', $flag->$field->login) + if $flag->$field_id; + } + return $item; } @@ -1405,6 +1430,48 @@ Also returned as C, for backwards-compatibility with older Bugzillas. (However, this backwards-compatibility will go away in Bugzilla 5.0.) +=item C + +An array of hashes containing the information about flags currently set +for each attachment. Each flag hash contains the following items: + +=over + +=item C + +C The id of the flag. + +=item C + +C The name of the flag. + +=item C + +C The type id of the flag. + +=item C + +C The timestamp when this flag was originally created. + +=item C + +C The timestamp when the flag was last modified. + +=item C + +C The current status of the flag. + +=item C + +C The login name of the user who created or last modified the flag. + +=item C + +C The login name of the user this flag has been requested to be granted or denied. +Note, this field is only returned if a requestee is set. + +=back + =back =item B @@ -1441,6 +1508,8 @@ C. =back +=item The C array was added in Bugzilla B<4.4>. + =back @@ -1703,6 +1772,48 @@ take. If you are not in the time-tracking group, this field will not be included in the return value. +=item C + +An array of hashes containing the information about flags currently set +for the bug. Each flag hash contains the following items: + +=over + +=item C + +C The id of the flag. + +=item C + +C The name of the flag. + +=item C + +C The type id of the flag. + +=item C + +C The timestamp when this flag was originally created. + +=item C + +C The timestamp when the flag was last modified. + +=item C + +C The current status of the flag. + +=item C + +C The login name of the user who created or last modified the flag. + +=item C + +C The login name of the user this flag has been requested to be granted or denied. +Note, this field is only returned if a requestee is set. + +=back + =item C C of Cs. The names of all the groups that this bug is in. @@ -1930,8 +2041,9 @@ C, C, C, C, C, C, C, C, C, C, and all custom fields. -=back +=item The C array was added in Bugzilla B<4.4>. +=back =back -- cgit v1.2.3-24-g4f1b