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
a3ae4ab4
Commit
a3ae4ab4
authored
Nov 13, 2006
by
mkanat%bugzilla.org
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bug 355839: The WebService should provide lists of legal field values
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> r=mbd, a=myk
parent
790e8bbb
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
115 additions
and
0 deletions
+115
-0
Bug.pm
Bugzilla/WebService/Bug.pm
+109
-0
Constants.pm
Bugzilla/WebService/Constants.pm
+2
-0
user-error.html.tmpl
template/en/default/global/user-error.html.tmpl
+4
-0
No files found.
Bugzilla/WebService/Bug.pm
View file @
a3ae4ab4
...
...
@@ -21,6 +21,9 @@ use strict;
use
base
qw(Bugzilla::WebService)
;
import
SOAP::
Data
qw(type)
;
use
Bugzilla::
Constants
;
use
Bugzilla::
Error
;
use
Bugzilla::
Field
;
use
Bugzilla::WebService::
Constants
;
use
Bugzilla::
Util
qw(detaint_natural)
;
use
Bugzilla::
Bug
;
...
...
@@ -42,6 +45,17 @@ use constant FIELD_MAP => {
platform
=>
'rep_platform'
,
};
use
constant
GLOBAL_SELECT_FIELDS
=>
qw(
bug_severity
bug_status
op_sys
priority
rep_platform
resolution
)
;
use
constant
PRODUCT_SPECIFIC_FIELDS
=>
qw(version target_milestone component)
;
###########
# Methods #
###########
...
...
@@ -83,6 +97,50 @@ sub create {
return
{
id
=>
type
(
'int'
)
->
value
(
$bug
->
bug_id
)
};
}
sub
legal_values
{
my
(
$self
,
$params
)
=
@_
;
my
$field
=
FIELD_MAP
->
{
$params
->
{
field
}}
||
$params
->
{
field
};
my
@custom_select
=
Bugzilla
->
get_fields
({
type
=>
FIELD_TYPE_SINGLE_SELECT
});
my
$values
;
if
(
grep
(
$_
eq
$field
,
GLOBAL_SELECT_FIELDS
,
@custom_select
))
{
$values
=
get_legal_field_values
(
$field
);
}
elsif
(
grep
(
$_
eq
$field
,
PRODUCT_SPECIFIC_FIELDS
))
{
my
$id
=
$params
->
{
product_id
};
defined
$id
||
ThrowCodeError
(
'param_required'
,
{
function
=>
'Bug.legal_values'
,
param
=>
'product_id'
});
grep
(
$_
->
id
eq
$id
,
@
{
Bugzilla
->
user
->
get_accessible_products
})
||
ThrowUserError
(
'product_access_denied'
,
{
product
=>
$id
});
my
$product
=
new
Bugzilla::
Product
(
$id
);
my
@objects
;
if
(
$field
eq
'version'
)
{
@objects
=
@
{
$product
->
versions
};
}
elsif
(
$field
eq
'target_milestone'
)
{
@objects
=
@
{
$product
->
milestones
};
}
elsif
(
$field
eq
'component'
)
{
@objects
=
@
{
$product
->
components
};
}
$values
=
[
map
{
$_
->
name
}
@objects
];
}
else
{
ThrowCodeError
(
'invalid_field_name'
,
{
field
=>
$params
->
{
field
}
});
}
my
@result
;
foreach
my
$val
(
@$values
)
{
push
(
@result
,
type
(
'string'
)
->
value
(
$val
));
}
return
{
values
=>
\
@result
};
}
1
;
__END__
...
...
@@ -101,6 +159,57 @@ This part of the Bugzilla API allows you to file a new bug in Bugzilla.
See L<Bugzilla::WebService> for a description of B<STABLE>, B<UNSTABLE>,
and B<EXPERIMENTAL>.
=head2 Utility Functions
=over
=item C<legal_values> B<EXPERIMENTAL>
=over
=item B<Description>
Tells you what values are allowed for a particular field.
=item B<Params>
=over
=item C<field> - The name of the field you want information about.
This should be the same as the name you would use in L</create>, below.
=item C<product_id> - If you're picking a product-specific field, you have
to specify the id of the product you want the values for.
=back
=item B<Returns>
C<values> - An array of strings: the legal values for this field.
The values will be sorted as they normally would be in Bugzilla.
=item B<Errors>
=over
=item 106 (Invalid Product)
You were required to specify a product, and either you didn't, or you
specified an invalid product (or a product that you can't access).
=item 108 (Invalid Field Name)
You specified a field that doesn't exist or isn't a drop-down field.
=back
=back
=back
=head2 Bug Creation and Modification
=over
=item C<create> B<EXPERIMENTAL>
...
...
Bugzilla/WebService/Constants.pm
View file @
a3ae4ab4
...
...
@@ -52,6 +52,7 @@ use constant WS_ERROR_CODE => {
invalid_bug_id_or_alias
=>
100
,
invalid_bug_id_non_existent
=>
101
,
bug_access_denied
=>
102
,
invalid_field_name
=>
108
,
# These all mean "invalid alias"
alias_not_defined
=>
103
,
alias_too_long
=>
103
,
...
...
@@ -67,6 +68,7 @@ use constant WS_ERROR_CODE => {
# Invalid Product
no_products
=>
106
,
entry_access_denied
=>
106
,
product_access_denied
=>
106
,
product_disabled
=>
106
,
# Invalid Summary
require_summary
=>
107
,
...
...
template/en/default/global/user-error.html.tmpl
View file @
a3ae4ab4
...
...
@@ -1138,6 +1138,10 @@
Patches cannot be more than [% Param('maxpatchsize') %] KB in size.
Try breaking your patch into several pieces.
[% ELSIF error == "product_access_denied" %]
Either the product '[% product FILTER html %]' does not exist or
you don't have access to it.
[% ELSIF error == "product_doesnt_exist" %]
[% title = "Specified Product Does Not Exist" %]
The product '[% product FILTER html %]' does not exist.
...
...
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