summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkanat%bugzilla.org <>2006-08-02 19:32:13 +0200
committermkanat%bugzilla.org <>2006-08-02 19:32:13 +0200
commitb06a56e99c623093a15921546f68f8bc8f7ba75e (patch)
tree76168a77593cc9b0a48edf4c4276585c7c047305
parent01c3f172a95760538553e944b34c71de0b0ada13 (diff)
downloadbugzilla-b06a56e99c623093a15921546f68f8bc8f7ba75e.tar.gz
bugzilla-b06a56e99c623093a15921546f68f8bc8f7ba75e.tar.xz
Bug 346932: Move settings creation/maintenance into Bugzilla::Install
Patch By Max Kanat-Alexander <mkanat@bugzilla.org> (module owner) a=myk
-rw-r--r--Bugzilla/Install.pm103
-rw-r--r--Bugzilla/User/Setting.pm19
-rwxr-xr-xchecksetup.pl32
3 files changed, 116 insertions, 38 deletions
diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm
new file mode 100644
index 000000000..4e94fa4a4
--- /dev/null
+++ b/Bugzilla/Install.pm
@@ -0,0 +1,103 @@
+# -*- Mode: perl; indent-tabs-mode: nil -*-
+#
+# 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.
+#
+# The Original Code is the Bugzilla Bug Tracking System.
+#
+# Contributor(s): Max Kanat-Alexander <mkanat@bugzilla.org>
+
+package Bugzilla::Install;
+
+# Functions in this this package can assume that the database
+# has been set up, params are available, localconfig is
+# available, and any module can be used.
+#
+# If you want to write an installation function that can't
+# make those assumptions, then it should go into one of the
+# packages under the Bugzilla::Install namespace.
+
+use strict;
+
+use Bugzilla::User::Setting;
+
+use constant SETTINGS => {
+ # 2005-03-03 travis@sedsystems.ca -- Bug 41972
+ display_quips => { options => ["on", "off"], default => "on" },
+ # 2005-03-10 travis@sedsystems.ca -- Bug 199048
+ comment_sort_order => { options => ["oldest_to_newest", "newest_to_oldest",
+ "newest_to_oldest_desc_first"],
+ default => "oldest_to_newest" },
+ # 2005-05-12 bugzilla@glob.com.au -- Bug 63536
+ post_bug_submit_action => { options => ["next_bug", "same_bug", "nothing"],
+ default => "next_bug" },
+ # 2005-06-29 wurblzap@gmail.com -- Bug 257767
+ csv_colsepchar => { options => [',',';'], default => ',' },
+ # 2005-10-26 wurblzap@gmail.com -- Bug 291459
+ zoom_textareas => { options => ["on", "off"], default => "on" },
+ # 2005-10-21 LpSolit@gmail.com -- Bug 313020
+ per_bug_queries => { options => ['on', 'off'], default => 'on' },
+ # 2006-05-01 olav@bkor.dhs.org -- Bug 7710
+ state_addselfcc => { options => ['always', 'never', 'cc_unless_role'],
+ default => 'cc_unless_role' },
+
+};
+
+sub update_settings {
+ my %settings = %{SETTINGS()};
+ foreach my $setting (keys %settings) {
+ add_setting($setting, $settings{$setting}->{options},
+ $settings{$setting}->{default});
+ }
+}
+
+1;
+
+__END__
+
+=head1 NAME
+
+Bugzilla::Install - Functions and variables having to do with
+ installation.
+
+=head1 SYNOPSIS
+
+ use Bugzilla::Install;
+ Bugzilla::Install::update_settings();
+
+=head1 DESCRIPTION
+
+This module is used primarily by L<checksetup.pl> during installation.
+This module contains functions that deal with general installation
+issues after the database is completely set up and configured.
+
+=head1 CONSTANTS
+
+=over
+
+=item C<SETTINGS>
+
+Contains information about Settings, used by L</update_settings()>.
+
+=back
+
+=head1 SUBROUTINES
+
+=over
+
+=item C<update_settings()>
+
+Description: Adds and updates Settings for users.
+
+Params: none
+
+Returns: nothing.
+
+=back
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm
index 450d20a7f..71aeb2ef4 100644
--- a/Bugzilla/User/Setting.pm
+++ b/Bugzilla/User/Setting.pm
@@ -130,9 +130,10 @@ sub add_setting {
my $sth = $dbh->prepare(q{INSERT INTO setting_value (name, value, sortindex)
VALUES (?, ?, ?)});
- my @values_list = keys %{$values};
- foreach my $key (@values_list){
- $sth->execute($name, $key, $values->{$key});
+ my $sortindex = 5;
+ foreach my $key (@$values){
+ $sth->execute($name, $key, $sortindex);
+ $sortindex += 5;
}
}
@@ -307,17 +308,19 @@ $settings->{$setting_name} = new Bugzilla::User::Setting(
=over 4
-=item C<add_setting($name, $values, $default_value)>
+=item C<add_setting($name, \@values, $default_value)>
Description: Checks for the existence of a setting, and adds it
to the database if it does not yet exist.
+
Params: C<$name> - string - the name of the new setting
- C<$values> - hash - contains the new values (key) and
- sortindexes for the new setting
+ C<$values> - arrayref - contains the new choices
+ for the new Setting.
C<$default_value> - string - the site default
+
Returns: a pointer to a hash of settings
-#
-#
+
+
=item C<get_all_settings($user_id)>
Description: Provides the user's choices for each setting in the
diff --git a/checksetup.pl b/checksetup.pl
index 813aa0a83..9d48644ae 100755
--- a/checksetup.pl
+++ b/checksetup.pl
@@ -329,6 +329,7 @@ import Bugzilla::Install::Filesystem qw(update_filesystem create_htaccess
require Bugzilla::DB;
require Bugzilla::Template;
+require Bugzilla::Install;
###########################################################################
# Check and update --LOCAL-- configuration
@@ -3264,36 +3265,7 @@ if (!GroupDoesExist('bz_sudoers')) {
# Create --SETTINGS-- users can adjust
###########################################################################
-# 2005-03-03 travis@sedsystems.ca -- Bug 41972
-add_setting ("display_quips", {"on" => 1, "off" => 2 }, "on" );
-
-# 2005-03-10 travis@sedsystems.ca -- Bug 199048
-add_setting ("comment_sort_order", {"oldest_to_newest" => 1,
- "newest_to_oldest" => 2,
- "newest_to_oldest_desc_first" => 3},
- "oldest_to_newest" );
-
-# 2005-05-12 bugzilla@glob.com.au -- Bug 63536
-add_setting ("post_bug_submit_action", {"next_bug" => 1,
- "same_bug" => 2,
- "nothing" => 3,
- },
- "next_bug" );
-
-# 2005-06-29 wurblzap@gmail.com -- Bug 257767
-add_setting ('csv_colsepchar', {',' => 1, ';' => 2 }, ',' );
-
-# 2005-10-26 wurblzap@gmail.com -- Bug 291459
-add_setting ("zoom_textareas", {"on" => 1, "off" => 2 }, "on" );
-
-# 2005-10-21 LpSolit@gmail.com -- Bug 313020
-add_setting('per_bug_queries', {'on' => 1, 'off' => 2}, 'on');
-
-# 2006-05-01 olav@bkor.dhs.org -- Bug 7710
-add_setting('state_addselfcc', {'always' => 1,
- 'never' => 2,
- 'cc_unless_role' => '3'},
- 'cc_unless_role');
+Bugzilla::Install::update_settings();
###########################################################################
# Create Administrator --ADMIN--