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
2ac2b7ec
Commit
2ac2b7ec
authored
Dec 13, 2009
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 502683: Ability to get attachments by ID in the WebService
Patch by Tiago Mello <timello@gmail.com> r=mkanat, a=mkanat
parent
9d11a0d5
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
94 additions
and
11 deletions
+94
-11
Bug.pm
Bugzilla/WebService/Bug.pm
+89
-10
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+5
-1
No files found.
Bugzilla/WebService/Bug.pm
View file @
2ac2b7ec
...
...
@@ -411,21 +411,47 @@ sub update_see_also {
}
sub
attachments
{
my
(
$self
,
$params
)
=
validate
(
@_
,
'ids'
);
my
(
$self
,
$params
)
=
validate
(
@_
,
'ids'
,
'attachment_ids'
);
my
$ids
=
$params
->
{
ids
};
defined
$ids
||
ThrowCodeError
(
'param_required'
,
{
param
=>
'ids'
});
my
%
attachments
;
if
(
!
(
defined
$params
->
{
ids
}
||
defined
$params
->
{
attachment_ids
}))
{
ThrowCodeError
(
'param_required'
,
{
function
=>
'Bug.attachments'
,
params
=>
[
'ids'
,
'attachment_ids'
]
});
}
my
$ids
=
$params
->
{
ids
}
||
[]
;
my
$attach_ids
=
$params
->
{
attachment_ids
}
||
[]
;
my
%
bugs
;
foreach
my
$bug_id
(
@$ids
)
{
my
$bug
=
Bugzilla::
Bug
->
check
(
$bug_id
);
$
attachment
s
{
$bug
->
id
}
=
[]
;
$
bug
s
{
$bug
->
id
}
=
[]
;
foreach
my
$attach
(
@
{
$bug
->
attachments
})
{
push
@
{
$
attachment
s
{
$bug
->
id
}},
push
@
{
$
bug
s
{
$bug
->
id
}},
$self
->
_attachment_to_hash
(
$attach
,
$params
);
}
}
return
{
bugs
=>
\%
attachments
};
my
%
attachments
;
foreach
my
$attach
(
@
{
Bugzilla::
Attachment
->
new_from_list
(
$attach_ids
)})
{
Bugzilla::
Bug
->
check
(
$attach
->
bug_id
);
if
(
$attach
->
isprivate
&&
!
Bugzilla
->
user
->
is_insider
)
{
ThrowUserError
(
'auth_failure'
,
{
action
=>
'access'
,
object
=>
'attachment'
,
attach_id
=>
$attach
->
id
});
}
$attachments
{
$attach
->
id
}
=
$self
->
_attachment_to_hash
(
$attach
,
$params
);
}
$bugs
{
attachments
}
=
\%
attachments
;
return
{
bugs
=>
\%
bugs
};
}
##############################
...
...
@@ -586,26 +612,68 @@ B<EXPERIMENTAL>
=item B<Description>
Gets information about all attachments from a bug.
It allows you to get data about attachments, given a list of bugs
and/or attachment ids.
B<Note>: Private attachments will only be returned if you are in the
insidergroup or if you are the submitter of the attachment.
=item B<Params>
B<Note>: At least one of C<ids> or C<attachment_ids> is required.
=over
=item C<ids>
See the description of the C<ids> parameter in the L</get> method.
=item C<attachment_ids>
C<array> An array of integer attachment ids.
=back
=item B<Returns>
A hash containing a single element, C<bugs>. This is a hash of hashes.
Each hash has the numeric bug id as a key, and contains the following
items:
A hash containing two elements: C<bugs> and C<attachments>. The return
value looks like this:
{
bugs => {
1345 => {
attachments => [
{ (attachment) },
{ (attachment) }
]
},
9874 => {
attachments => [
{ (attachment) },
{ (attachment) }
]
},
},
attachments => {
234 => { (attachment) },
123 => { (attachment) },
}
}
The attachments of any bugs that you specified in the C<ids> argument in
input are returned in C<bugs> on output. C<bugs> is a hash that has integer
bug IDs for keys and contains a single key, C<attachments>. That key points
to an arrayref that contains attachments as a hash. (Fields for attachments
are described below.)
For any attachments that you specified directly in C<attachment_ids>, they
are returned in C<attachments> on output. This is a hash where the attachment
ids point directly to hashes describing the individual attachment.
The fields for each attachment (where it says C<(attachment)> in the
diagram above) are:
=over
...
...
@@ -665,7 +733,18 @@ C<string> The login name of the user that created the attachment.
=item B<Errors>
This method can throw all the same errors as L</get>.
This method can throw all the same errors as L</get>. In addition,
it can also throw the following error:
=over
=item 304 (Auth Failure, Attachment is Private)
You specified the id of a private attachment in the C<attachment_ids>
argument, and you are not in the "insider group" that can see
private attachments.
=back
=item B<History>
...
...
template/en/default/global/user-error.html.tmpl
View file @
2ac2b7ec
...
...
@@ -160,7 +160,11 @@
[% IF object == "administrative_pages" %]
administrative pages
[% ELSIF object == "attachment" %]
this attachment
[% IF attach_id %]
attachment #[% attach_id FILTER html %]
[% ELSE %]
this attachment
[% END %]
[% ELSIF object == "bugs" %]
[%+ terms.bugs %]
[% ELSIF object == "charts" %]
...
...
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