2004-05-23 11:22:32 +04:00
|
|
|
#!/usr/bin/perl -wT
|
1998-09-16 01:49:26 +04:00
|
|
|
# -*- Mode: perl; indent-tabs-mode: nil -*-
|
1998-09-01 08:21:45 +04:00
|
|
|
#
|
1999-11-02 02:33:56 +03:00
|
|
|
# The contents of this file are subject to the Mozilla Public
|
|
|
|
# License Version 1.1 (the "License"); you may not use this file
|
|
|
|
# except in compliance with the License. You may obtain a copy of
|
|
|
|
# the License at http://www.mozilla.org/MPL/
|
|
|
|
#
|
|
|
|
# Software distributed under the License is distributed on an "AS
|
|
|
|
# IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
# implied. See the License for the specific language governing
|
|
|
|
# rights and limitations under the License.
|
|
|
|
#
|
1998-09-01 08:21:45 +04:00
|
|
|
# The Original Code is the Bugzilla Bug Tracking System.
|
1999-11-02 02:33:56 +03:00
|
|
|
#
|
1998-09-01 08:21:45 +04:00
|
|
|
# The Initial Developer of the Original Code is Netscape Communications
|
1999-11-02 02:33:56 +03:00
|
|
|
# Corporation. Portions created by Netscape are
|
|
|
|
# Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
# Rights Reserved.
|
|
|
|
#
|
1998-09-01 08:21:45 +04:00
|
|
|
# Contributor(s): Terry Weissman <terry@mozilla.org>
|
2002-08-11 18:12:33 +04:00
|
|
|
# J. Paul Reed <preed@sigkill.com>
|
2005-10-12 12:51:55 +04:00
|
|
|
# Frédéric Buclin <LpSolit@gmail.com>
|
1998-09-01 08:21:45 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
use strict;
|
2002-04-29 23:32:29 +04:00
|
|
|
use lib ".";
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2006-06-20 11:55:39 +04:00
|
|
|
use Bugzilla;
|
2004-03-27 06:51:44 +03:00
|
|
|
use Bugzilla::Constants;
|
2006-07-04 01:42:47 +04:00
|
|
|
use Bugzilla::Config qw(:admin);
|
2005-10-12 19:15:06 +04:00
|
|
|
use Bugzilla::Config::Common;
|
2006-06-21 04:44:48 +04:00
|
|
|
use Bugzilla::Util;
|
|
|
|
use Bugzilla::Error;
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2005-09-16 02:01:56 +04:00
|
|
|
my $user = Bugzilla->login(LOGIN_REQUIRED);
|
2005-10-12 12:51:55 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
2005-07-22 09:13:36 +04:00
|
|
|
my $template = Bugzilla->template;
|
2005-10-25 03:11:56 +04:00
|
|
|
my $vars = {};
|
2005-07-22 09:13:36 +04:00
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
print $cgi->header();
|
1998-09-16 01:49:26 +04:00
|
|
|
|
2005-09-16 02:01:56 +04:00
|
|
|
$user->in_group('tweakparams')
|
2005-01-16 17:07:31 +03:00
|
|
|
|| ThrowUserError("auth_failure", {group => "tweakparams",
|
2006-03-07 01:16:23 +03:00
|
|
|
action => "access",
|
2005-01-16 17:07:31 +03:00
|
|
|
object => "parameters"});
|
2000-01-12 21:55:24 +03:00
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
my $action = trim($cgi->param('action') || '');
|
|
|
|
my $current_panel = $cgi->param('section') || 'core';
|
|
|
|
$current_panel =~ /^([A-Za-z0-9_-]+)$/;
|
|
|
|
$current_panel = $1;
|
|
|
|
|
|
|
|
my $current_module;
|
|
|
|
my @panels = ();
|
2006-07-04 01:23:26 +04:00
|
|
|
foreach my $panel (Bugzilla::Config::param_panels()) {
|
|
|
|
eval("require Bugzilla::Config::$panel") || die $@;
|
2006-06-20 00:15:18 +04:00
|
|
|
my @module_param_list = "Bugzilla::Config::${panel}"->get_param_list(1);
|
2005-10-12 12:51:55 +04:00
|
|
|
my $item = { name => lc($panel),
|
|
|
|
current => ($current_panel eq lc($panel)) ? 1 : 0,
|
|
|
|
param_list => \@module_param_list,
|
|
|
|
sortkey => eval "\$Bugzilla::Config::${panel}::sortkey;"
|
|
|
|
};
|
|
|
|
push(@panels, $item);
|
|
|
|
$current_module = $panel if ($current_panel eq lc($panel));
|
|
|
|
}
|
2002-08-11 18:12:33 +04:00
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
$vars->{panels} = \@panels;
|
2002-08-11 18:12:33 +04:00
|
|
|
|
2005-10-13 13:18:24 +04:00
|
|
|
if ($action eq 'save' && $current_module) {
|
2005-10-12 12:51:55 +04:00
|
|
|
my @changes = ();
|
2006-06-20 00:15:18 +04:00
|
|
|
my @module_param_list = "Bugzilla::Config::${current_module}"->get_param_list(1);
|
2002-08-11 18:12:33 +04:00
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
foreach my $i (@module_param_list) {
|
|
|
|
my $name = $i->{'name'};
|
|
|
|
my $value = $cgi->param($name);
|
2002-08-29 13:25:54 +04:00
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
if (defined $cgi->param("reset-$name")) {
|
|
|
|
$value = $i->{'default'};
|
|
|
|
} else {
|
|
|
|
if ($i->{'type'} eq 'm') {
|
|
|
|
# This simplifies the code below
|
|
|
|
$value = [ $cgi->param($name) ];
|
|
|
|
} else {
|
|
|
|
# Get rid of windows/mac-style line endings.
|
|
|
|
$value =~ s/\r\n?/\n/g;
|
|
|
|
# assume single linefeed is an empty string
|
|
|
|
$value =~ s/^\n$//;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
my $changed;
|
|
|
|
if ($i->{'type'} eq 'm') {
|
2006-07-04 01:26:22 +04:00
|
|
|
my @old = sort @{Bugzilla->params->{$name}};
|
2005-10-12 12:51:55 +04:00
|
|
|
my @new = sort @$value;
|
|
|
|
if (scalar(@old) != scalar(@new)) {
|
|
|
|
$changed = 1;
|
|
|
|
} else {
|
|
|
|
$changed = 0; # Assume not changed...
|
|
|
|
for (my $cnt = 0; $cnt < scalar(@old); ++$cnt) {
|
|
|
|
if ($old[$cnt] ne $new[$cnt]) {
|
|
|
|
# entry is different, therefore changed
|
|
|
|
$changed = 1;
|
|
|
|
last;
|
|
|
|
}
|
2002-08-11 18:12:33 +04:00
|
|
|
}
|
|
|
|
}
|
2005-10-12 12:51:55 +04:00
|
|
|
} else {
|
2006-07-04 01:26:22 +04:00
|
|
|
$changed = ($value eq Bugzilla->params->{$name})? 0 : 1;
|
2005-10-12 12:51:55 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($changed) {
|
|
|
|
if (exists $i->{'checker'}) {
|
|
|
|
my $ok = $i->{'checker'}->($value, $i);
|
|
|
|
if ($ok ne "") {
|
|
|
|
ThrowUserError('invalid_parameter', { name => $name, err => $ok });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
push(@changes, $name);
|
|
|
|
SetParam($name, $value);
|
|
|
|
if (($name eq "shutdownhtml") && ($value ne "")) {
|
|
|
|
$vars->{'shutdown_is_active'} = 1;
|
|
|
|
}
|
|
|
|
}
|
1998-09-01 08:21:45 +04:00
|
|
|
}
|
2005-10-12 12:51:55 +04:00
|
|
|
$vars->{'message'} = 'parameters_updated';
|
|
|
|
$vars->{'param_changed'} = \@changes;
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2006-08-01 02:15:55 +04:00
|
|
|
write_params();
|
2005-10-12 12:51:55 +04:00
|
|
|
}
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
$template->process("admin/params/editparams.html.tmpl", $vars)
|
|
|
|
|| ThrowTemplateError($template->error());
|