29
29
# Frédéric Buclin <LpSolit@gmail.com>
32
# This file defines all the parameters that we have a GUI to edit within
35
# ATTENTION!!!! THIS FILE ONLY CONTAINS THE DEFAULTS.
36
# You cannot change your live settings by editing this file.
37
# Only adding new parameters is done here. Once the parameter exists, you
38
# must use %baseurl%/editparams.cgi from the web to edit the settings.
40
# This file is included via |do|, mainly because of circular dependency issues
41
# (such as globals.pl -> Bugzilla::Config -> this -> Bugzilla::Config)
42
# which preclude compile time loading.
44
# Those issues may go away at some point, and the contents of this file
45
# moved somewhere else. Please try to avoid more dependencies from here
48
# (Note that these aren't just added directly to Bugzilla::Config, because
49
# the backend prefs code is separate to this...)
51
32
package Bugzilla::Config::Common;
57
use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
58
39
use Bugzilla::Util;
59
40
use Bugzilla::Constants;
61
44
use base qw(Exporter);
62
45
@Bugzilla::Config::Common::EXPORT =
63
qw(check_multi check_numeric check_regexp
46
qw(check_multi check_numeric check_regexp check_url check_group
64
47
check_sslbase check_priority check_severity check_platform
65
48
check_opsys check_shadowdb check_urlbase check_webdotbase
66
49
check_netmask check_user_verify_class check_image_converter
67
check_languages check_mail_delivery_method
50
check_languages check_mail_delivery_method check_notification
51
check_timezone check_utf8
70
54
# Checking functions for the various values
119
# You cannot turn off the UTF-8 parameter if you've already converted
120
# your tables to utf-8.
121
my $dbh = Bugzilla->dbh;
122
if ($dbh->isa('Bugzilla::DB::Mysql') && $dbh->bz_db_is_utf8 && !$utf8) {
123
return "You cannot disable UTF-8 support, because your MySQL database"
124
. " is encoded in UTF-8";
133
129
sub check_priority {
134
130
my ($value) = (@_);
135
&::GetVersionTable();
136
if (lsearch(\@::legal_priority, $value) < 0) {
131
my $legal_priorities = get_legal_field_values('priority');
132
if (lsearch($legal_priorities, $value) < 0) {
137
133
return "Must be a legal priority value: one of " .
138
join(", ", @::legal_priority);
134
join(", ", @$legal_priorities);
143
139
sub check_severity {
144
140
my ($value) = (@_);
145
&::GetVersionTable();
146
if (lsearch(\@::legal_severity, $value) < 0) {
141
my $legal_severities = get_legal_field_values('bug_severity');
142
if (lsearch($legal_severities, $value) < 0) {
147
143
return "Must be a legal severity value: one of " .
148
join(", ", @::legal_severity);
144
join(", ", @$legal_severities);
153
149
sub check_platform {
154
150
my ($value) = (@_);
155
&::GetVersionTable();
156
if (lsearch(['', @::legal_platform], $value) < 0) {
151
my $legal_platforms = get_legal_field_values('rep_platform');
152
if (lsearch(['', @$legal_platforms], $value) < 0) {
157
153
return "Must be empty or a legal platform value: one of " .
158
join(", ", @::legal_platform);
154
join(", ", @$legal_platforms);
163
159
sub check_opsys {
164
160
my ($value) = (@_);
165
&::GetVersionTable();
166
if (lsearch(['', @::legal_opsys], $value) < 0) {
161
my $legal_OS = get_legal_field_values('op_sys');
162
if (lsearch(['', @$legal_OS], $value) < 0) {
167
163
return "Must be empty or a legal operating system value: one of " .
168
join(", ", @::legal_opsys);
164
join(", ", @$legal_OS);
170
my $group_name = shift;
171
return "" unless $group_name;
172
my $group = new Bugzilla::Group({'name' => $group_name});
173
unless (defined $group) {
174
return "Must be an existing group name";
206
221
return "The file path \"$value\" is not a valid executable. Please specify the complete file path to 'dot' if you intend to generate graphs locally.";
208
223
# Check .htaccess allows access to generated images
224
my $webdotdir = bz_locations()->{'webdotdir'};
209
225
if(-e "$webdotdir/.htaccess") {
210
226
open HTACCESS, "$webdotdir/.htaccess";
211
227
if(! grep(/ \\\.png\$/,<HTACCESS>)) {
250
266
} elsif ($class eq 'LDAP') {
251
267
eval "require Net::LDAP";
252
268
return "Error requiring Net::LDAP: '$@'" if $@;
253
return "LDAP servername is missing" unless Param("LDAPserver");
254
return "LDAPBaseDN is empty" unless Param("LDAPBaseDN");
269
return "LDAP servername is missing" unless Bugzilla->params->{"LDAPserver"};
270
return "LDAPBaseDN is empty" unless Bugzilla->params->{"LDAPBaseDN"};
256
272
return "Unknown user_verify_class '$class' in check_user_verify_class";
271
287
sub check_languages {
272
my @languages = split /[,\s]+/, trim($_[0]);
288
my ($lang, $param) = @_;
289
my @languages = split(/[,\s]+/, trim($lang));
273
290
if(!scalar(@languages)) {
274
291
return "You need to specify a language tag."
293
if (scalar(@languages) > 1 && $param && $param->{'name'} eq 'defaultlanguage') {
294
return "You can only specify one language tag";
296
my $templatedir = bz_locations()->{'templatedir'};
298
my @validated_languages;
276
299
foreach my $language (@languages) {
277
300
if( ! -d "$templatedir/$language/custom"
278
301
&& ! -d "$templatedir/$language/default") {
279
302
return "The template directory for $language does not exist";
304
push(@validated_languages, $language) unless $lang_seen{$language}++;
306
# Rebuild the list of language tags, avoiding duplicates.
307
$_[0] = join(', ', @validated_languages);
323
sub check_notification {
325
my @current_version =
326
(BUGZILLA_VERSION =~ m/^(\d+)\.(\d+)(?:(rc|\.)(\d+))?\+?$/);
327
if ($current_version[1] % 2 && $option eq 'stable_branch_release') {
328
return "You are currently running a development snapshot, and so your " .
329
"installation is not based on a branch. If you want to be notified " .
330
"about the next stable release, you should select " .
331
"'latest_stable_release' instead";
338
unless (defined(tz_offset($tz))) {
339
return "must be empty or a legal timezone name, such as PDT or JST";
297
345
# OK, here are the parameter definitions themselves.
299
347
# Each definition is a hash with keys: