aboutsummaryrefslogtreecommitdiffstats
path: root/Bugzilla/WebService
diff options
context:
space:
mode:
authorFrédéric Buclin <LpSolit@gmail.com>2012-01-07 14:13:16 +0100
committerFrédéric Buclin <LpSolit@gmail.com>2012-01-07 14:13:16 +0100
commite50fc49676a9dfdc958b17b2c4d0bf3fa72e8b69 (patch)
tree1ee668e9bfa4778d6c2108e9e1214aaa2f0f6148 /Bugzilla/WebService
parent9ba84d123111207b2d2f9eefe68a5bd6134de220 (diff)
downloadbugs-e50fc49676a9dfdc958b17b2c4d0bf3fa72e8b69.tar
bugs-e50fc49676a9dfdc958b17b2c4d0bf3fa72e8b69.tar.gz
bugs-e50fc49676a9dfdc958b17b2c4d0bf3fa72e8b69.tar.bz2
bugs-e50fc49676a9dfdc958b17b2c4d0bf3fa72e8b69.tar.xz
bugs-e50fc49676a9dfdc958b17b2c4d0bf3fa72e8b69.zip
Bug 443210: Implement Bugzilla.parameters to access parameters used in Bugzilla
r/a=mkanat
Diffstat (limited to 'Bugzilla/WebService')
-rw-r--r--Bugzilla/WebService/Bugzilla.pm134
1 files changed, 134 insertions, 0 deletions
diff --git a/Bugzilla/WebService/Bugzilla.pm b/Bugzilla/WebService/Bugzilla.pm
index efc822311..865996efa 100644
--- a/Bugzilla/WebService/Bugzilla.pm
+++ b/Bugzilla/WebService/Bugzilla.pm
@@ -15,6 +15,7 @@
# Contributor(s): Marc Schumann <wurblzap@gmail.com>
# Max Kanat-Alexander <mkanat@bugzilla.org>
# Mads Bondo Dydensborg <mbd@dbc.dk>
+# Frédéric Buclin <LpSolit@gmail.com>
package Bugzilla::WebService::Bugzilla;
@@ -22,22 +23,66 @@ use strict;
use base qw(Bugzilla::WebService);
use Bugzilla::Constants;
use Bugzilla::Util qw(datetime_from);
+use Bugzilla::WebService::Util qw(filter_wants);
use DateTime;
# Basic info that is needed before logins
use constant LOGIN_EXEMPT => {
+ parameters => 1,
timezone => 1,
version => 1,
};
use constant READ_ONLY => qw(
extensions
+ parameters
timezone
time
version
);
+# Logged-out users do not need to know more than that.
+use constant PARAMETERS_LOGGED_OUT => qw(
+ maintainer
+ requirelogin
+);
+
+# These parameters are guessable from the web UI when the user
+# is logged in. So it's safe to access them.
+use constant PARAMETERS_LOGGED_IN => qw(
+ allowemailchange
+ attachment_base
+ commentonchange_resolution
+ commentonduplicate
+ cookiepath
+ defaultopsys
+ defaultplatform
+ defaultpriority
+ defaultseverity
+ duplicate_or_move_bug_status
+ emailregexpdesc
+ emailsuffix
+ letsubmitterchoosemilestone
+ letsubmitterchoosepriority
+ mailfrom
+ maintainer
+ maxattachmentsize
+ maxlocalattachment
+ musthavemilestoneonaccept
+ noresolveonopenblockers
+ password_complexity
+ rememberlogin
+ requirelogin
+ search_allow_no_criteria
+ urlbase
+ use_see_also
+ useclassification
+ useqacontact
+ usestatuswhiteboard
+ usetargetmilestone
+);
+
sub version {
my $self = shift;
return { version => $self->type('string', BUGZILLA_VERSION) };
@@ -81,6 +126,25 @@ sub time {
};
}
+sub parameters {
+ my ($self, $args) = @_;
+ my $user = Bugzilla->login();
+ my $params = Bugzilla->params;
+ $args ||= {};
+
+ my @params_list = $user->in_group('tweakparams')
+ ? keys(%$params)
+ : $user->id ? PARAMETERS_LOGGED_IN : PARAMETERS_LOGGED_OUT;
+
+ my %parameters;
+ foreach my $param (@params_list) {
+ next unless filter_wants($args, $param);
+ $parameters{$param} = $self->type('string', $params->{$param});
+ }
+
+ return { parameters => \%parameters };
+}
+
1;
__END__
@@ -268,3 +332,73 @@ local timezone.
=back
=back
+
+=head2 parameters
+
+B<UNSTABLE>
+
+=over
+
+=item B<Description>
+
+Returns parameter values currently used in this Bugzilla.
+
+=item B<Params> (none)
+
+=item B<Returns>
+
+A hash with a single item C<parameters> which contains a hash with
+the name of the parameters as keys and their value as values. All
+values are returned as strings.
+The list of parameters returned by this method depends on the user
+credentials:
+
+A logged-out user can only access the C<maintainer> and C<requirelogin> parameters.
+
+A logged-in user can access the following parameters (listed alphabetically):
+ C<allowemailchange>,
+ C<attachment_base>,
+ C<commentonchange_resolution>,
+ C<commentonduplicate>,
+ C<cookiepath>,
+ C<defaultopsys>,
+ C<defaultplatform>,
+ C<defaultpriority>,
+ C<defaultseverity>,
+ C<duplicate_or_move_bug_status>,
+ C<emailregexpdesc>,
+ C<emailsuffix>,
+ C<letsubmitterchoosemilestone>,
+ C<letsubmitterchoosepriority>,
+ C<mailfrom>,
+ C<maintainer>,
+ C<maxattachmentsize>,
+ C<maxlocalattachment>,
+ C<musthavemilestoneonaccept>,
+ C<noresolveonopenblockers>,
+ C<password_complexity>,
+ C<rememberlogin>,
+ C<requirelogin>,
+ C<search_allow_no_criteria>,
+ C<urlbase>,
+ C<use_see_also>,
+ C<useclassification>,
+ C<useqacontact>,
+ C<usestatuswhiteboard>,
+ C<usetargetmilestone>.
+
+A user in the tweakparams group can access all existing parameters.
+New parameters can appear or obsolete parameters can disappear depending
+on the version of Bugzilla and on extensions being installed.
+The list of parameters returned by this method is not stable and will
+never be stable.
+
+=item B<History>
+
+=over
+
+=item Added in Bugzilla B<5.0>.
+
+=back
+
+=back