2003-03-27 03:07:02 +03: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>
|
1998-09-01 08:21:45 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
use strict;
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2002-01-20 04:44:52 +03:00
|
|
|
use lib qw(.);
|
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
use Bugzilla;
|
2003-11-22 06:50:42 +03:00
|
|
|
use Bugzilla::Config qw(:DEFAULT :admin $datadir);
|
2002-08-29 13:25:54 +04:00
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
require "CGI.pl";
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2002-08-29 13:25:54 +04:00
|
|
|
use vars %::MFORM;
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2002-06-17 13:39:00 +04:00
|
|
|
ConnectToDatabase();
|
1998-09-16 01:49:26 +04:00
|
|
|
confirm_login();
|
|
|
|
|
2003-05-05 05:15:38 +04:00
|
|
|
my $cgi = Bugzilla->cgi;
|
|
|
|
|
|
|
|
print $cgi->header();
|
1998-09-16 01:49:26 +04:00
|
|
|
|
1999-03-11 19:30:54 +03:00
|
|
|
if (!UserInGroup("tweakparams")) {
|
2003-07-16 13:16:16 +04:00
|
|
|
print "<h1>Sorry, you aren't a member of the 'tweakparams' group.</h1>\n";
|
1999-03-11 19:30:54 +03:00
|
|
|
print "And so, you aren't allowed to edit the parameters.\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
PutFooter();
|
1998-09-16 01:49:26 +04:00
|
|
|
exit;
|
1998-09-01 08:21:45 +04:00
|
|
|
}
|
|
|
|
|
2001-08-13 23:11:35 +04:00
|
|
|
PutHeader("Saving new parameters");
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2003-09-02 05:47:15 +04:00
|
|
|
my $howto = "";
|
|
|
|
|
2002-08-29 13:25:54 +04:00
|
|
|
foreach my $i (GetParamList()) {
|
|
|
|
my $name = $i->{'name'};
|
|
|
|
my $value = $::FORM{$name};
|
|
|
|
if (exists $::FORM{"reset-$name"}) {
|
|
|
|
$value = $i->{'default'};
|
|
|
|
} else {
|
|
|
|
if ($i->{'type'} eq 'm') {
|
|
|
|
# This simplifies the code below
|
|
|
|
$value = \@{$::MFORM{$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$//;
|
2002-08-11 18:12:33 +04:00
|
|
|
}
|
2002-08-29 13:25:54 +04:00
|
|
|
}
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
2002-08-29 13:25:54 +04:00
|
|
|
} else {
|
|
|
|
$changed = ($value eq Param($name) ? 0 : 1);
|
1998-09-01 08:21:45 +04:00
|
|
|
}
|
2002-08-29 13:25:54 +04:00
|
|
|
if ($changed) {
|
|
|
|
if (exists $i->{'checker'}) {
|
|
|
|
my $ok = $i->{'checker'}->($value, $i);
|
1998-09-16 01:49:26 +04:00
|
|
|
if ($ok ne "") {
|
2002-08-29 13:25:54 +04:00
|
|
|
print "New value for " . html_quote($name) .
|
|
|
|
" is invalid: $ok<p>\n";
|
1998-09-16 01:49:26 +04:00
|
|
|
print "Please hit <b>Back</b> and try again.\n";
|
2000-01-15 01:35:49 +03:00
|
|
|
PutFooter();
|
1998-09-16 01:49:26 +04:00
|
|
|
exit;
|
1998-09-01 08:21:45 +04:00
|
|
|
}
|
|
|
|
}
|
2003-07-16 13:16:16 +04:00
|
|
|
print "Changed " . html_quote($name) . ".<br>\n";
|
2002-08-29 13:25:54 +04:00
|
|
|
SetParam($name, $value);
|
2003-09-02 05:47:15 +04:00
|
|
|
if (($name eq "shutdownhtml") && ($value ne "")) {
|
|
|
|
# The system is down, inform the user how to restore it
|
|
|
|
$howto = "<p>Bugzilla has now been shut down, to re-enable ".
|
|
|
|
"the system, please return to ".
|
|
|
|
"<a href=\"editparams.cgi\">editparams.cgi</a>.</p>";
|
|
|
|
}
|
1998-09-01 08:21:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-09-16 01:49:26 +04:00
|
|
|
WriteParams();
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2003-11-22 06:50:42 +03:00
|
|
|
unlink "$datadir/versioncache";
|
1999-01-28 00:17:10 +03:00
|
|
|
|
2003-09-02 05:47:15 +04:00
|
|
|
print "<p>OK, done.</p>\n";
|
|
|
|
print $howto;
|
2003-07-16 13:16:16 +04:00
|
|
|
print "<a href=\"editparams.cgi\">Edit the params some more.</a><p>\n";
|
|
|
|
print "<a href=\"query.cgi\">Go back to the query page.</a>\n";
|
1998-09-01 08:21:45 +04:00
|
|
|
|
2000-01-15 01:35:49 +03:00
|
|
|
PutFooter();
|