~ubuntu-branches/debian/sid/bugzilla/sid

« back to all changes in this revision

Viewing changes to Bugzilla/Config/Common.pm

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Patrick Davies
  • Date: 2008-05-29 17:20:32 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20080529172032-tddh964ztksxayjm
Tags: 3.0.4-0ubuntu1
* New upstream release (LP: #138886, #235701).
* Removed "CVS" directories and ".cvsignore" files from upstream tarball.
* Added patches/ubuntu_01_bugzilla_libpath.dpatch - newly updated as necessary
  version of old 01_libpath.dpatch patch.
* Added patches/01_debian_package_version.dpatch - replaces old patch
  01_VERSION.dpatch, simply changes the version of Bugzilla to show the
  Debian packaging's versioning.
* Added patches/ubuntu_05_makefile_install.dpatch - Use a Makefile to
  install Bugzilla to the correct locations. Based on Makefile in old
  package but in patch form.
* Removed 02_checksetup.dpatch - fixed upstream.
* Removed 101_Config.diff - upstream has changed codebase.
* Renamed 06_contrib.dpatch to ubuntu_02_contrib_shebang_fixes.dpatch -
  corrects 'shebangs' which point to /usr/local/bin/ to /usr/bin/.
* Renamed 08_showdependencygraph.dpatch to
  ubuntu_03_showdependencygraph_url_fixes.dpatch and updated code as
  necessary - fixes graph URL to make the webdot generation possible.
* Removed CVE-2007-0791.dpatch - applied to upstream code.
* Removed CVE-2007-4543.dpatch - applied to upstream code.
* Renamed 09_homelink.dpatch to ubuntu_04_fixed_homepage_linked.dpatch -
  upstream now has links in
  'template/en/default/global/common-links.html.tmpl' instead of
  'useful-links.html.tmpl'.
* Removed 03_webpath.dpatch - upstream has changed stylesheet layout.
* Updated 10_perl_scripts_shebang.dpatch and removed part on "globals.pl" -
  no longer in source.
* Removed Debian vhost support patches (see docs/html/multiple-bz-dbs.html
  for how to run multiple Bugzilla instances):
  - Removed 04_Config.pm.dpatch - duplicate patch and unable to adapt it to
    new upstream code.
  - Removed 07_virtualhosting.dpatch - duplicate patch of
    04_Config.pm.dpatch.
  - Removed 'debian/examples' - contained Apache VHost example setup files
    for Bugzilla.
  - Removed section about vhosts from README.Debian.
* debian/rules:
  - Removed rules for "vhost conf dir", "examples" and "101_Config.diff"
    installation rules.
  - Removed part about bugzilla-fr package.
  - Remved part about "whine.pl" - now in Makefile.
  - Added rules to check the setup with upstream's "checksetup.pl" script.
* debian/control:
  - Updated Standards-Version to 3.7.3.
  - Updated compatibity level and debhelper build dependency version to 6.
  - Added Homepage field to source package stanza.
  - Added part about seeing 'bugzilla' package for more info to
    'bugzilla-docs'.
  - Added libapache2-mod-perl2, libtemplate-perl, libmime-perl,
    libappconfig-perl, libdbd-mysql-perl, libtimedate-perl, libgd-gd2-perl,
    libgd-text-perl, libxml-twig-perl, perlmagick, libemail-send-perl,
    libemail-mime-modifier-perl, libchart-perl, libgd-graph-perl,
    libhtml-scrubber-perl, libdbi-perl, libfile-spec-perl, libgd-graph-perl,
    libgd-text-perl, libnet-ldap-perl, libxml-parser-perl: to build
    dependencies with the necessary versions as stated by upstream in
    docs/html/installation.html - in order to check packaging correctly with
    'checksetup.pl' in rules. Also updated the 'bugzilla' dependencies with
    the above (LP: #235461).
  - Removed dependencies on old "apache" packages as they are no longer in
    the archives.
  - Moved mail transport agents on 'bugzilla' from Depends to
    Suggests (LP: #156405).
* debian/copyright: Updated the downloaded from link.
* debian/bugzilla.docs: Added "QUICKSTART", "rel_notes.txt" and "UPGRADING"
  documentation from source tarball for inclusion in package.
* debian/bugzilla-doc.doc-base: Corrected some spelling mistakes.
* debian/bugzilla.postinst: Removed sections about 101_Config.diff.
* Changed 'X_BUGZILLA_SITE' in bugzilla.cron.daily and bugzilla.postinst to
  'PROJECT'.

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#                 Frédéric Buclin <LpSolit@gmail.com>
30
30
#
31
31
 
32
 
# This file defines all the parameters that we have a GUI to edit within
33
 
# Bugzilla.
34
 
 
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.
39
 
 
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.
43
 
 
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
46
 
# to other code
47
 
 
48
 
# (Note that these aren't just added directly to Bugzilla::Config, because
49
 
# the backend prefs code is separate to this...)
50
 
 
51
32
package Bugzilla::Config::Common;
52
33
 
53
34
use strict;
54
35
 
55
36
use Socket;
 
37
use Time::Zone;
56
38
 
57
 
use Bugzilla::Config qw(:DEFAULT $templatedir $webdotdir);
58
39
use Bugzilla::Util;
59
40
use Bugzilla::Constants;
 
41
use Bugzilla::Field;
 
42
use Bugzilla::Group;
60
43
 
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
68
52
);
69
53
 
70
54
# Checking functions for the various values
130
114
    return "";
131
115
}
132
116
 
 
117
sub check_utf8 {
 
118
    my $utf8 = shift;
 
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";
 
125
    }
 
126
    return "";
 
127
}
 
128
 
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);
139
135
    }
140
136
    return "";
141
137
}
142
138
 
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);
149
145
    }
150
146
    return "";
151
147
}
152
148
 
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);
159
155
    }
160
156
    return "";
161
157
}
162
158
 
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);
 
165
    }
 
166
    return "";
 
167
}
 
168
 
 
169
sub check_group {
 
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";
169
175
    }
170
176
    return "";
171
177
}
177
183
        return "";
178
184
    }
179
185
 
180
 
    if (!Param('shadowdbhost')) {
 
186
    if (!Bugzilla->params->{'shadowdbhost'}) {
181
187
        return "You need to specify a host when using a shadow database";
182
188
    }
183
189
 
195
201
    return "";
196
202
}
197
203
 
 
204
sub check_url {
 
205
    my ($url) = (@_);
 
206
    return '' if $url eq ''; # Allow empty URLs
 
207
    if ($url !~ m:/$:) {
 
208
        return 'must be a legal URL, absolute or relative, ending with a slash.';
 
209
    }
 
210
    return '';
 
211
}
 
212
 
198
213
sub check_webdotbase {
199
214
    my ($value) = (@_);
200
215
    $value = trim($value);
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.";
207
222
        }
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"};
255
271
        } else {
256
272
                return "Unknown user_verify_class '$class' in check_user_verify_class";
257
273
        }
269
285
}
270
286
 
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."
275
292
    }
 
293
    if (scalar(@languages) > 1 && $param && $param->{'name'} eq 'defaultlanguage') {
 
294
        return "You can only specify one language tag";
 
295
    }
 
296
    my $templatedir = bz_locations()->{'templatedir'};
 
297
    my %lang_seen;
 
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";
280
303
       }
 
304
       push(@validated_languages, $language) unless $lang_seen{$language}++;
281
305
    }
 
306
    # Rebuild the list of language tags, avoiding duplicates.
 
307
    $_[0] = join(', ', @validated_languages);
282
308
    return "";
283
309
}
284
310
 
294
320
    return "";
295
321
}
296
322
 
 
323
sub check_notification {
 
324
    my $option = shift;
 
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";
 
332
    }
 
333
    return "";
 
334
}
 
335
 
 
336
sub check_timezone {
 
337
    my $tz = shift;
 
338
    unless (defined(tz_offset($tz))) {
 
339
        return "must be empty or a legal timezone name, such as PDT or JST";
 
340
    }
 
341
    return "";
 
342
}
 
343
 
 
344
 
297
345
# OK, here are the parameter definitions themselves.
298
346
#
299
347
# Each definition is a hash with keys: