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
|
|
|
|
2004-03-27 06:51:44 +03:00
|
|
|
use Bugzilla::Constants;
|
2005-10-12 12:51:55 +04:00
|
|
|
use Bugzilla::Config qw(:DEFAULT :admin :params $datadir);
|
2005-10-12 19:15:06 +04:00
|
|
|
use Bugzilla::Config::Common;
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2005-08-10 05:30:41 +04:00
|
|
|
require "globals.pl";
|
2005-10-12 12:51:55 +04:00
|
|
|
use vars qw($vars @parampanels);
|
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-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",
|
|
|
|
action => "modify",
|
|
|
|
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;
|
|
|
|
|
2005-10-18 22:47:08 +04:00
|
|
|
GetVersionTable();
|
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
my $current_module;
|
|
|
|
my @panels = ();
|
|
|
|
foreach my $panel (@parampanels) {
|
|
|
|
next if ($panel eq 'Common');
|
2005-10-12 19:15:06 +04:00
|
|
|
require "Bugzilla/Config/$panel.pm";
|
2005-10-12 12:51:55 +04:00
|
|
|
my @module_param_list = "Bugzilla::Config::${panel}"->get_param_list();
|
|
|
|
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 = ();
|
|
|
|
my @module_param_list = "Bugzilla::Config::${current_module}"->get_param_list();
|
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') {
|
|
|
|
my @old = sort @{Param($name)};
|
|
|
|
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 {
|
|
|
|
$changed = ($value eq Param($name))? 0 : 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
2005-10-12 12:51:55 +04:00
|
|
|
WriteParams();
|
|
|
|
unlink "$datadir/versioncache";
|
|
|
|
}
|
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());
|