summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Install.pm
diff options
context:
space:
mode:
Diffstat (limited to 'Bugzilla/Install.pm')
-rw-r--r--Bugzilla/Install.pm795
1 files changed, 399 insertions, 396 deletions
diff --git a/Bugzilla/Install.pm b/Bugzilla/Install.pm
index 8bce9b5e7..705a8396c 100644
--- a/Bugzilla/Install.pm
+++ b/Bugzilla/Install.pm
@@ -31,509 +31,512 @@ use Bugzilla::Util qw(get_text);
use Bugzilla::Version;
use constant STATUS_WORKFLOW => (
- [undef, 'UNCONFIRMED'],
- [undef, 'CONFIRMED'],
- [undef, 'IN_PROGRESS'],
- ['UNCONFIRMED', 'CONFIRMED'],
- ['UNCONFIRMED', 'IN_PROGRESS'],
- ['UNCONFIRMED', 'RESOLVED'],
- ['CONFIRMED', 'IN_PROGRESS'],
- ['CONFIRMED', 'RESOLVED'],
- ['IN_PROGRESS', 'CONFIRMED'],
- ['IN_PROGRESS', 'RESOLVED'],
- ['RESOLVED', 'UNCONFIRMED'],
- ['RESOLVED', 'CONFIRMED'],
- ['RESOLVED', 'VERIFIED'],
- ['VERIFIED', 'UNCONFIRMED'],
- ['VERIFIED', 'CONFIRMED'],
+ [undef, 'UNCONFIRMED'],
+ [undef, 'CONFIRMED'],
+ [undef, 'IN_PROGRESS'],
+ ['UNCONFIRMED', 'CONFIRMED'],
+ ['UNCONFIRMED', 'IN_PROGRESS'],
+ ['UNCONFIRMED', 'RESOLVED'],
+ ['CONFIRMED', 'IN_PROGRESS'],
+ ['CONFIRMED', 'RESOLVED'],
+ ['IN_PROGRESS', 'CONFIRMED'],
+ ['IN_PROGRESS', 'RESOLVED'],
+ ['RESOLVED', 'UNCONFIRMED'],
+ ['RESOLVED', 'CONFIRMED'],
+ ['RESOLVED', 'VERIFIED'],
+ ['VERIFIED', 'UNCONFIRMED'],
+ ['VERIFIED', 'CONFIRMED'],
);
sub SETTINGS {
- return [
+ return [
# 2005-03-03 travis@sedsystems.ca -- Bug 41972
{
- name => 'display_quips',
- options => ["on", "off"],
- default => "on",
- category => 'Searching'
+ name => 'display_quips',
+ options => ["on", "off"],
+ default => "on",
+ category => 'Searching'
},
+
# 2005-03-10 travis@sedsystems.ca -- Bug 199048
{
- name => 'comment_sort_order',
- options => ["oldest_to_newest", "newest_to_oldest", "newest_to_oldest_desc_first"],
- default => "oldest_to_newest",
- category => 'Bug Editing'
+ name => 'comment_sort_order',
+ options =>
+ ["oldest_to_newest", "newest_to_oldest", "newest_to_oldest_desc_first"],
+ default => "oldest_to_newest",
+ category => 'Bug Editing'
},
+
# 2005-05-12 bugzilla@glob.com.au -- Bug 63536
{
- name => 'post_bug_submit_action',
- options => ["next_bug", "same_bug", "nothing"],
- default => "next_bug",
- category => 'Bug Editing'
+ name => 'post_bug_submit_action',
+ options => ["next_bug", "same_bug", "nothing"],
+ default => "next_bug",
+ category => 'Bug Editing'
},
+
# 2005-06-29 wurblzap@gmail.com -- Bug 257767
{
- name => 'csv_colsepchar',
- options => [',',';'],
- default => ',',
- category => 'Searching'
+ name => 'csv_colsepchar',
+ options => [',', ';'],
+ default => ',',
+ category => 'Searching'
},
+
# 2005-10-26 wurblzap@gmail.com -- Bug 291459
{
- name => 'zoom_textareas',
- options => ["on", "off"],
- default => "on",
- category => 'Bug Editing'
+ name => 'zoom_textareas',
+ options => ["on", "off"],
+ default => "on",
+ category => 'Bug Editing'
},
+
# 2005-10-21 LpSolit@gmail.com -- Bug 313020
{
- name => 'per_bug_queries',
- options => ['on', 'off'],
- default => 'off',
- category => 'Searching'
+ name => 'per_bug_queries',
+ options => ['on', 'off'],
+ default => 'off',
+ category => 'Searching'
},
+
# 2006-05-01 olav@bkor.dhs.org -- Bug 7710
{
- name => 'state_addselfcc',
- options => ['always', 'never', 'cc_unless_role'],
- default => 'cc_unless_role',
- category => 'Bug Editing'
+ name => 'state_addselfcc',
+ options => ['always', 'never', 'cc_unless_role'],
+ default => 'cc_unless_role',
+ category => 'Bug Editing'
},
+
# 2006-08-04 wurblzap@gmail.com -- Bug 322693
{
- name => 'skin',
- subclass => 'Skin',
- default => 'Dusk',
- category => 'User Interface'
+ name => 'skin',
+ subclass => 'Skin',
+ default => 'Dusk',
+ category => 'User Interface'
},
+
# 2006-12-10 LpSolit@gmail.com -- Bug 297186
{
- name => 'lang',
- subclass => 'Lang',
- default => ${Bugzilla->languages}[0],
- category => 'User Interface'
+ name => 'lang',
+ subclass => 'Lang',
+ default => ${Bugzilla->languages}[0],
+ category => 'User Interface'
},
+
# 2007-07-02 altlist@gmail.com -- Bug 225731
{
- name => 'quote_replies',
- options => ['quoted_reply', 'simple_reply', 'off'],
- default => "quoted_reply",
- category => 'Bug Editing'
+ name => 'quote_replies',
+ options => ['quoted_reply', 'simple_reply', 'off'],
+ default => "quoted_reply",
+ category => 'Bug Editing'
},
+
# 2009-02-01 mozilla@matt.mchenryfamily.org -- Bug 398473
{
- name => 'comment_box_position',
- options => ['before_comments', 'after_comments'],
- default => 'before_comments',
- category => 'Bug Editing'
+ name => 'comment_box_position',
+ options => ['before_comments', 'after_comments'],
+ default => 'before_comments',
+ category => 'Bug Editing'
},
+
# 2008-08-27 LpSolit@gmail.com -- Bug 182238
{
- name => 'timezone',
- subclass => 'Timezone',
- default => 'local',
- category => 'User Interface'
+ name => 'timezone',
+ subclass => 'Timezone',
+ default => 'local',
+ category => 'User Interface'
},
+
# 2011-02-07 dkl@mozilla.com -- Bug 580490
{
- name => 'quicksearch_fulltext',
- options => ['on', 'off'],
- default => 'on',
- category => 'Searching'
+ name => 'quicksearch_fulltext',
+ options => ['on', 'off'],
+ default => 'on',
+ category => 'Searching'
},
+
# 2011-06-21 glob@mozilla.com -- Bug 589128
{
- name => 'email_format',
- options => ['html', 'text_only'],
- default => 'html',
- category => 'Email Notifications'
+ name => 'email_format',
+ options => ['html', 'text_only'],
+ default => 'html',
+ category => 'Email Notifications'
},
+
# 2011-06-16 glob@mozilla.com -- Bug 663747
{
- name => 'bugmail_new_prefix',
- options => ['on', 'off'],
- default => 'on',
- category => 'Email Notifications'
+ name => 'bugmail_new_prefix',
+ options => ['on', 'off'],
+ default => 'on',
+ category => 'Email Notifications'
},
+
# 2013-07-26 joshi_sunil@in.com -- Bug 669535
{
- name => 'possible_duplicates',
- options => ['on', 'off'],
- default => 'on',
- category => 'User Interface'
+ name => 'possible_duplicates',
+ options => ['on', 'off'],
+ default => 'on',
+ category => 'User Interface'
},
+
# 2011-10-11 glob@mozilla.com -- Bug 301656
{
- name => 'requestee_cc',
- options => ['on', 'off'],
- default => 'on',
- category => 'Reviews and Needinfo'
+ name => 'requestee_cc',
+ options => ['on', 'off'],
+ default => 'on',
+ category => 'Reviews and Needinfo'
},
{
- name => 'api_key_only',
- options => ['on', 'off'],
- default => 'off',
- category => 'API'
+ name => 'api_key_only',
+ options => ['on', 'off'],
+ default => 'off',
+ category => 'API'
},
{
- name => 'use_elasticsearch',
- options => ['on', 'off'],
- default => 'off',
- category => 'Searching'
+ name => 'use_elasticsearch',
+ options => ['on', 'off'],
+ default => 'off',
+ category => 'Searching'
},
{
- name => 'autosize_comments',
- options => ['on', 'off'],
- default => 'on',
- category => 'User Interface'
+ name => 'autosize_comments',
+ options => ['on', 'off'],
+ default => 'on',
+ category => 'User Interface'
},
- ];
-};
+ ];
+}
use constant SYSTEM_GROUPS => (
- {
- name => 'admin',
- description => 'Administrators'
- },
- {
- name => 'tweakparams',
- description => 'Can change Parameters'
- },
- {
- name => 'editusers',
- description => 'Can edit or disable users'
- },
- {
- name => 'disableusers',
- description => 'Can disable users'
- },
- {
- name => 'creategroups',
- description => 'Can create and destroy groups'
- },
- {
- name => 'editclassifications',
- description => 'Can create, destroy, and edit classifications'
- },
- {
- name => 'editcomponents',
- description => 'Can create, destroy, and edit components'
- },
- {
- name => 'editkeywords',
- description => 'Can create, destroy, and edit keywords'
- },
- {
- name => 'editbugs',
- description => 'Can edit all bug fields',
- userregexp => '.*'
- },
- {
- name => 'canconfirm',
- description => 'Can confirm a bug or mark it a duplicate'
- },
- {
- name => 'bz_canusewhineatothers',
- description => 'Can configure whine reports for other users',
- },
- {
- name => 'bz_canusewhines',
- description => 'User can configure whine reports for self',
- # inherited_by means that users in the groups listed below are
- # automatically members of bz_canusewhines.
- inherited_by => ['editbugs', 'bz_canusewhineatothers'],
- },
- {
- name => 'bz_sudoers',
- description => 'Can perform actions as other users',
- },
- {
- name => 'bz_sudo_protect',
- description => 'Can not be impersonated by other users',
- inherited_by => ['bz_sudoers'],
- },
- {
- name => 'bz_quip_moderators',
- description => 'Can moderate quips',
- },
- {
- name => 'bz_can_disable_mfa',
- description => 'Can disable MFA when editing users',
- },
+ {name => 'admin', description => 'Administrators'},
+ {name => 'tweakparams', description => 'Can change Parameters'},
+ {name => 'editusers', description => 'Can edit or disable users'},
+ {name => 'disableusers', description => 'Can disable users'},
+ {name => 'creategroups', description => 'Can create and destroy groups'},
+ {
+ name => 'editclassifications',
+ description => 'Can create, destroy, and edit classifications'
+ },
+ {
+ name => 'editcomponents',
+ description => 'Can create, destroy, and edit components'
+ },
+ {
+ name => 'editkeywords',
+ description => 'Can create, destroy, and edit keywords'
+ },
+ {
+ name => 'editbugs',
+ description => 'Can edit all bug fields',
+ userregexp => '.*'
+ },
+ {
+ name => 'canconfirm',
+ description => 'Can confirm a bug or mark it a duplicate'
+ },
+ {
+ name => 'bz_canusewhineatothers',
+ description => 'Can configure whine reports for other users',
+ },
+ {
+ name => 'bz_canusewhines',
+ description => 'User can configure whine reports for self',
+
+ # inherited_by means that users in the groups listed below are
+ # automatically members of bz_canusewhines.
+ inherited_by => ['editbugs', 'bz_canusewhineatothers'],
+ },
+ {name => 'bz_sudoers', description => 'Can perform actions as other users',},
+ {
+ name => 'bz_sudo_protect',
+ description => 'Can not be impersonated by other users',
+ inherited_by => ['bz_sudoers'],
+ },
+ {name => 'bz_quip_moderators', description => 'Can moderate quips',},
+ {
+ name => 'bz_can_disable_mfa',
+ description => 'Can disable MFA when editing users',
+ },
);
-use constant DEFAULT_CLASSIFICATION => {
- name => 'Unclassified',
- description => 'Not assigned to any classification'
-};
+use constant DEFAULT_CLASSIFICATION =>
+ {name => 'Unclassified', description => 'Not assigned to any classification'};
use constant DEFAULT_PRODUCT => {
- name => 'TestProduct',
- description => 'This is a test product.'
- . ' This ought to be blown away and replaced with real stuff in a'
- . ' finished installation of bugzilla.',
- version => Bugzilla::Version::DEFAULT_VERSION,
- classification => 'Unclassified',
- defaultmilestone => DEFAULT_MILESTONE,
+ name => 'TestProduct',
+ description => 'This is a test product.'
+ . ' This ought to be blown away and replaced with real stuff in a'
+ . ' finished installation of bugzilla.',
+ version => Bugzilla::Version::DEFAULT_VERSION,
+ classification => 'Unclassified',
+ defaultmilestone => DEFAULT_MILESTONE,
};
use constant DEFAULT_COMPONENT => {
- name => 'TestComponent',
- description => 'This is a test component in the test product database.'
- . ' This ought to be blown away and replaced with real stuff in'
- . ' a finished installation of Bugzilla.'
+ name => 'TestComponent',
+ description => 'This is a test component in the test product database.'
+ . ' This ought to be blown away and replaced with real stuff in'
+ . ' a finished installation of Bugzilla.'
};
sub update_settings {
- my $dbh = Bugzilla->dbh;
- # If we're setting up settings for the first time, we want to be quieter.
- my $any_settings = $dbh->selectrow_array(
- 'SELECT 1 FROM setting ' . $dbh->sql_limit(1));
- if (!$any_settings) {
- print get_text('install_setting_setup'), "\n";
- }
-
- my @settings = @{SETTINGS()};
- foreach my $params (@settings) {
- add_setting($params);
- }
+ my $dbh = Bugzilla->dbh;
+
+ # If we're setting up settings for the first time, we want to be quieter.
+ my $any_settings
+ = $dbh->selectrow_array('SELECT 1 FROM setting ' . $dbh->sql_limit(1));
+ if (!$any_settings) {
+ print get_text('install_setting_setup'), "\n";
+ }
+
+ my @settings = @{SETTINGS()};
+ foreach my $params (@settings) {
+ add_setting($params);
+ }
}
sub update_system_groups {
- my $dbh = Bugzilla->dbh;
-
- $dbh->bz_start_transaction();
-
- # If there is no editbugs group, this is the first time we're
- # adding groups.
- my $editbugs_exists = new Bugzilla::Group({ name => 'editbugs' });
- if (!$editbugs_exists) {
- print get_text('install_groups_setup'), "\n";
- }
-
- # Create most of the system groups
- foreach my $definition (SYSTEM_GROUPS) {
- my $exists = new Bugzilla::Group({ name => $definition->{name} });
- if (!$exists) {
- $definition->{isbuggroup} = 0;
- $definition->{silently} = !$editbugs_exists;
- my $inherited_by = delete $definition->{inherited_by};
- my $created = Bugzilla::Group->create($definition);
- # Each group in inherited_by is automatically a member of this
- # group.
- if ($inherited_by) {
- foreach my $name (@$inherited_by) {
- my $member = Bugzilla::Group->check($name);
- $dbh->do('INSERT INTO group_group_map (grantor_id,
- member_id) VALUES (?,?)',
- undef, $created->id, $member->id);
- }
- }
+ my $dbh = Bugzilla->dbh;
+
+ $dbh->bz_start_transaction();
+
+ # If there is no editbugs group, this is the first time we're
+ # adding groups.
+ my $editbugs_exists = new Bugzilla::Group({name => 'editbugs'});
+ if (!$editbugs_exists) {
+ print get_text('install_groups_setup'), "\n";
+ }
+
+ # Create most of the system groups
+ foreach my $definition (SYSTEM_GROUPS) {
+ my $exists = new Bugzilla::Group({name => $definition->{name}});
+ if (!$exists) {
+ $definition->{isbuggroup} = 0;
+ $definition->{silently} = !$editbugs_exists;
+ my $inherited_by = delete $definition->{inherited_by};
+ my $created = Bugzilla::Group->create($definition);
+
+ # Each group in inherited_by is automatically a member of this
+ # group.
+ if ($inherited_by) {
+ foreach my $name (@$inherited_by) {
+ my $member = Bugzilla::Group->check($name);
+ $dbh->do(
+ 'INSERT INTO group_group_map (grantor_id,
+ member_id) VALUES (?,?)', undef, $created->id,
+ $member->id
+ );
}
+ }
}
+ }
- $dbh->bz_commit_transaction();
+ $dbh->bz_commit_transaction();
}
sub create_default_classification {
- my $dbh = Bugzilla->dbh;
-
- # Make the default Classification if it doesn't already exist.
- if (!$dbh->selectrow_array('SELECT 1 FROM classifications')) {
- print get_text('install_default_classification',
- { name => DEFAULT_CLASSIFICATION->{name} }) . "\n";
- Bugzilla::Classification->create(DEFAULT_CLASSIFICATION);
- }
+ my $dbh = Bugzilla->dbh;
+
+ # Make the default Classification if it doesn't already exist.
+ if (!$dbh->selectrow_array('SELECT 1 FROM classifications')) {
+ print get_text('install_default_classification',
+ {name => DEFAULT_CLASSIFICATION->{name}})
+ . "\n";
+ Bugzilla::Classification->create(DEFAULT_CLASSIFICATION);
+ }
}
# This function should be called only after creating the admin user.
sub create_default_product {
- my $dbh = Bugzilla->dbh;
-
- # And same for the default product/component.
- if (!$dbh->selectrow_array('SELECT 1 FROM products')) {
- print get_text('install_default_product',
- { name => DEFAULT_PRODUCT->{name} }) . "\n";
-
- my $product = Bugzilla::Product->create(DEFAULT_PRODUCT);
-
- # Get the user who will be the owner of the Component.
- # We pick the admin with the lowest id, which is probably the
- # admin checksetup.pl just created.
- my $admin_group = new Bugzilla::Group({name => 'admin'});
- my ($admin_id) = $dbh->selectrow_array(
- 'SELECT user_id FROM user_group_map WHERE group_id = ?
- ORDER BY user_id ' . $dbh->sql_limit(1),
- undef, $admin_group->id);
- my $admin = Bugzilla::User->new($admin_id);
-
- Bugzilla::Component->create({
- %{ DEFAULT_COMPONENT() }, product => $product,
- initialowner => $admin->login });
- }
+ my $dbh = Bugzilla->dbh;
+
+ # And same for the default product/component.
+ if (!$dbh->selectrow_array('SELECT 1 FROM products')) {
+ print get_text('install_default_product', {name => DEFAULT_PRODUCT->{name}})
+ . "\n";
+
+ my $product = Bugzilla::Product->create(DEFAULT_PRODUCT);
+
+ # Get the user who will be the owner of the Component.
+ # We pick the admin with the lowest id, which is probably the
+ # admin checksetup.pl just created.
+ my $admin_group = new Bugzilla::Group({name => 'admin'});
+ my ($admin_id) = $dbh->selectrow_array(
+ 'SELECT user_id FROM user_group_map WHERE group_id = ?
+ ORDER BY user_id ' . $dbh->sql_limit(1), undef, $admin_group->id
+ );
+ my $admin = Bugzilla::User->new($admin_id);
+
+ Bugzilla::Component->create({
+ %{DEFAULT_COMPONENT()}, product => $product, initialowner => $admin->login
+ });
+ }
}
sub init_workflow {
- my $dbh = Bugzilla->dbh;
- my $has_workflow = $dbh->selectrow_array('SELECT 1 FROM status_workflow');
- return if $has_workflow;
-
- print get_text('install_workflow_init'), "\n";
-
- my %status_ids = @{ $dbh->selectcol_arrayref(
- 'SELECT value, id FROM bug_status', {Columns=>[1,2]}) };
-
- foreach my $pair (STATUS_WORKFLOW) {
- my $old_id = $pair->[0] ? $status_ids{$pair->[0]} : undef;
- my $new_id = $status_ids{$pair->[1]};
- $dbh->do('INSERT INTO status_workflow (old_status, new_status)
- VALUES (?,?)', undef, $old_id, $new_id);
- }
+ my $dbh = Bugzilla->dbh;
+ my $has_workflow = $dbh->selectrow_array('SELECT 1 FROM status_workflow');
+ return if $has_workflow;
+
+ print get_text('install_workflow_init'), "\n";
+
+ my %status_ids = @{
+ $dbh->selectcol_arrayref('SELECT value, id FROM bug_status',
+ {Columns => [1, 2]})
+ };
+
+ foreach my $pair (STATUS_WORKFLOW) {
+ my $old_id = $pair->[0] ? $status_ids{$pair->[0]} : undef;
+ my $new_id = $status_ids{$pair->[1]};
+ $dbh->do(
+ 'INSERT INTO status_workflow (old_status, new_status)
+ VALUES (?,?)', undef, $old_id, $new_id
+ );
+ }
}
sub create_admin {
- my ($params) = @_;
- my $dbh = Bugzilla->dbh;
- my $template = Bugzilla->template;
-
- my $admin_group = new Bugzilla::Group({ name => 'admin' });
- my $admin_inheritors =
- Bugzilla::Group->flatten_group_membership($admin_group->id);
- my $admin_group_ids = join(',', @$admin_inheritors);
-
- my ($admin_count) = $dbh->selectrow_array(
- "SELECT COUNT(*) FROM user_group_map
- WHERE group_id IN ($admin_group_ids)");
-
- return if $admin_count;
-
- my %answer = %{Bugzilla->installation_answers};
- my $login = $answer{'ADMIN_EMAIL'};
- my $password = $answer{'ADMIN_PASSWORD'};
- my $full_name = $answer{'ADMIN_REALNAME'};
-
- if (!$login || !$password || !$full_name) {
- print "\n" . get_text('install_admin_setup') . "\n\n";
- }
-
- while (!$login) {
- print get_text('install_admin_get_email') . ' ';
- $login = <STDIN>;
- chomp $login;
- eval { Bugzilla::User->check_login_name_for_creation($login); };
- if ($@) {
- print $@ . "\n";
- undef $login;
- }
- }
-
- while (!defined $full_name) {
- print get_text('install_admin_get_name') . ' ';
- $full_name = <STDIN>;
- chomp($full_name);
+ my ($params) = @_;
+ my $dbh = Bugzilla->dbh;
+ my $template = Bugzilla->template;
+
+ my $admin_group = new Bugzilla::Group({name => 'admin'});
+ my $admin_inheritors
+ = Bugzilla::Group->flatten_group_membership($admin_group->id);
+ my $admin_group_ids = join(',', @$admin_inheritors);
+
+ my ($admin_count) = $dbh->selectrow_array(
+ "SELECT COUNT(*) FROM user_group_map
+ WHERE group_id IN ($admin_group_ids)"
+ );
+
+ return if $admin_count;
+
+ my %answer = %{Bugzilla->installation_answers};
+ my $login = $answer{'ADMIN_EMAIL'};
+ my $password = $answer{'ADMIN_PASSWORD'};
+ my $full_name = $answer{'ADMIN_REALNAME'};
+
+ if (!$login || !$password || !$full_name) {
+ print "\n" . get_text('install_admin_setup') . "\n\n";
+ }
+
+ while (!$login) {
+ print get_text('install_admin_get_email') . ' ';
+ $login = <STDIN>;
+ chomp $login;
+ eval { Bugzilla::User->check_login_name_for_creation($login); };
+ if ($@) {
+ print $@ . "\n";
+ undef $login;
}
-
- if (!$password) {
- $password = _prompt_for_password(
- get_text('install_admin_get_password'));
- }
-
- my $admin = Bugzilla::User->create({ login_name => $login,
- realname => $full_name,
- cryptpassword => $password });
- make_admin($admin);
+ }
+
+ while (!defined $full_name) {
+ print get_text('install_admin_get_name') . ' ';
+ $full_name = <STDIN>;
+ chomp($full_name);
+ }
+
+ if (!$password) {
+ $password = _prompt_for_password(get_text('install_admin_get_password'));
+ }
+
+ my $admin
+ = Bugzilla::User->create({
+ login_name => $login, realname => $full_name, cryptpassword => $password
+ });
+ make_admin($admin);
}
sub make_admin {
- my ($user) = @_;
- my $dbh = Bugzilla->dbh;
-
- $user = ref($user) ? $user
- : new Bugzilla::User(login_to_id($user, THROW_ERROR));
-
- my $group_insert = $dbh->prepare(
- 'INSERT INTO user_group_map (user_id, group_id, isbless, grant_type)
- VALUES (?, ?, ?, ?)');
-
- # Admins get explicit membership and bless capability for the admin group
- my $admin_group = new Bugzilla::Group({ name => 'admin' });
- # These are run in an eval so that we can ignore the error of somebody
- # already being granted these things.
- eval {
- $group_insert->execute($user->id, $admin_group->id, 0, GRANT_DIRECT);
- };
- eval {
- $group_insert->execute($user->id, $admin_group->id, 1, GRANT_DIRECT);
- };
-
- # Admins should also have editusers directly, even though they'll usually
- # inherit it. People could have changed their inheritance structure.
- my $editusers = new Bugzilla::Group({ name => 'editusers' });
- eval {
- $group_insert->execute($user->id, $editusers->id, 0, GRANT_DIRECT);
- };
-
- # If there is no maintainer set, make this user the maintainer.
- if (!Bugzilla->params->{'maintainer'}) {
- SetParam('maintainer', $user->email);
- write_params();
- }
-
- if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
- print "\n", get_text('install_admin_created', { user => $user }), "\n";
- }
+ my ($user) = @_;
+ my $dbh = Bugzilla->dbh;
+
+ $user
+ = ref($user) ? $user : new Bugzilla::User(login_to_id($user, THROW_ERROR));
+
+ my $group_insert = $dbh->prepare(
+ 'INSERT INTO user_group_map (user_id, group_id, isbless, grant_type)
+ VALUES (?, ?, ?, ?)'
+ );
+
+ # Admins get explicit membership and bless capability for the admin group
+ my $admin_group = new Bugzilla::Group({name => 'admin'});
+
+ # These are run in an eval so that we can ignore the error of somebody
+ # already being granted these things.
+ eval { $group_insert->execute($user->id, $admin_group->id, 0, GRANT_DIRECT); };
+ eval { $group_insert->execute($user->id, $admin_group->id, 1, GRANT_DIRECT); };
+
+ # Admins should also have editusers directly, even though they'll usually
+ # inherit it. People could have changed their inheritance structure.
+ my $editusers = new Bugzilla::Group({name => 'editusers'});
+ eval { $group_insert->execute($user->id, $editusers->id, 0, GRANT_DIRECT); };
+
+ # If there is no maintainer set, make this user the maintainer.
+ if (!Bugzilla->params->{'maintainer'}) {
+ SetParam('maintainer', $user->email);
+ write_params();
+ }
+
+ if (Bugzilla->usage_mode == USAGE_MODE_CMDLINE) {
+ print "\n", get_text('install_admin_created', {user => $user}), "\n";
+ }
}
sub _prompt_for_password {
- my $prompt = shift;
-
- my $password;
- while (!$password) {
- # trap a few interrupts so we can fix the echo if we get aborted.
- local $SIG{HUP} = \&_password_prompt_exit;
- local $SIG{INT} = \&_password_prompt_exit;
- local $SIG{QUIT} = \&_password_prompt_exit;
- local $SIG{TERM} = \&_password_prompt_exit;
-
- system("stty","-echo") unless ON_WINDOWS; # disable input echoing
-
- print $prompt, ' ';
- $password = <STDIN>;
- chomp $password;
- print "\n", get_text('install_confirm_password'), ' ';
- my $pass2 = <STDIN>;
- chomp $pass2;
- my $pwqc = Bugzilla->passwdqc;
- my $ok = $pwqc->validate_password($password);
- if (!$ok) {
- print "\n", $pwqc->reason, "\n";
- undef $password;
- }
- elsif ($password ne $pass2) {
- print "\n", "passwords do not match\n";
- undef $password;
- }
- system("stty","echo") unless ON_WINDOWS;
+ my $prompt = shift;
+
+ my $password;
+ while (!$password) {
+
+ # trap a few interrupts so we can fix the echo if we get aborted.
+ local $SIG{HUP} = \&_password_prompt_exit;
+ local $SIG{INT} = \&_password_prompt_exit;
+ local $SIG{QUIT} = \&_password_prompt_exit;
+ local $SIG{TERM} = \&_password_prompt_exit;
+
+ system("stty", "-echo") unless ON_WINDOWS; # disable input echoing
+
+ print $prompt, ' ';
+ $password = <STDIN>;
+ chomp $password;
+ print "\n", get_text('install_confirm_password'), ' ';
+ my $pass2 = <STDIN>;
+ chomp $pass2;
+ my $pwqc = Bugzilla->passwdqc;
+ my $ok = $pwqc->validate_password($password);
+ if (!$ok) {
+ print "\n", $pwqc->reason, "\n";
+ undef $password;
}
- return $password;
+ elsif ($password ne $pass2) {
+ print "\n", "passwords do not match\n";
+ undef $password;
+ }
+ system("stty", "echo") unless ON_WINDOWS;
+ }
+ return $password;
}
# This is just in case we get interrupted while getting a password.
sub _password_prompt_exit {
- # re-enable input echoing
- system("stty","echo") unless ON_WINDOWS;
- exit 1;
+
+ # re-enable input echoing
+ system("stty", "echo") unless ON_WINDOWS;
+ exit 1;
}
sub reset_password {
- my $login = shift;
- my $user = Bugzilla::User->check($login);
- my $prompt = "\n" . get_text('install_reset_password', { user => $user });
- my $password = _prompt_for_password($prompt);
- $user->set_password($password);
- $user->update();
- print "\n", get_text('install_reset_password_done'), "\n";
+ my $login = shift;
+ my $user = Bugzilla::User->check($login);
+ my $prompt = "\n" . get_text('install_reset_password', {user => $user});
+ my $password = _prompt_for_password($prompt);
+ $user->set_password($password);
+ $user->update();
+ print "\n", get_text('install_reset_password_done'), "\n";
}
1;