From 66b1bdd314c25c3485eab86e976b2a05d5c724c1 Mon Sep 17 00:00:00 2001 From: Reed Loden Date: Mon, 3 Sep 2012 12:37:04 -0700 Subject: Bug 781075 - Add WebService support for accessing a user's saved reports [r=LpSolit a=LpSolit] --- Bugzilla/WebService/User.pm | 50 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 9 deletions(-) (limited to 'Bugzilla/WebService') diff --git a/Bugzilla/WebService/User.pm b/Bugzilla/WebService/User.pm index ee1442d72..5b54285c6 100644 --- a/Bugzilla/WebService/User.pm +++ b/Bugzilla/WebService/User.pm @@ -222,6 +222,7 @@ sub get { if (Bugzilla->user->id == $user->id) { $user_info->{saved_searches} = [map { $self->_query_to_hash($_) } @{ $user->queries }]; + $user_info->{saved_reports} = [map { $self->_report_to_hash($_) } @{ $user->reports }]; } push(@users, filter($params, $user_info)); @@ -349,11 +350,20 @@ sub _group_to_hash { sub _query_to_hash { my ($self, $query) = @_; my $item = { - id => $self->type('int', $query->id), - name => $self->type('string', $query->name), - url => $self->type('string', $query->url), + id => $self->type('int', $query->id), + name => $self->type('string', $query->name), + query => $self->type('string', $query->url), }; + return $item; +} +sub _report_to_hash { + my ($self, $report) = @_; + my $item = { + id => $self->type('int', $report->id), + name => $self->type('string', $report->name), + query => $self->type('string', $report->query), + }; return $item; } @@ -813,19 +823,40 @@ C An integer id uniquely identifying the saved search. C The name of the saved search. -=item url +=item query C The CGI parameters for the saved search. =back +=item saved_reports + +C An array of hashes, each of which represents a user's saved report and has +the following keys: + +=over + +=item id + +C An integer id uniquely identifying the saved report. + +=item name + +C The name of the saved report. + +=item query + +C The CGI parameters for the saved report. + +=back + B: If you are not logged in to Bugzilla when you call this function, you will only be returned the C, C, and C items. If you are logged in and not in editusers group, you will only be returned the C, C, C, C, C, and C items. The groups returned are filtered based on your permission to bless each group. -The C item is only returned if you are querying your own account, -even if you are in the editusers group. +The C and C items are only returned if you are +querying your own account, even if you are in the editusers group. =back @@ -858,10 +889,11 @@ function. =item C and C were added in Bugzilla B<4.0>. -=item C added in Bugzilla B<4.0>. Default behavior -for C has changed to only returning enabled accounts. +=item C was added in Bugzilla B<4.0>. Default +behavior for C was changed to only return enabled accounts. -=item C and C added in Bugzilla B<4.4>. +=item C, C, and C were added +in Bugzilla B<4.4>. =back -- cgit v1.2.3-24-g4f1b