summaryrefslogtreecommitdiffstats
path: root/Bugzilla/User
diff options
context:
space:
mode:
authorPerl Tidy <perltidy@bugzilla.org>2018-12-05 21:38:52 +0100
committerDylan William Hardison <dylan@hardison.net>2018-12-05 23:49:08 +0100
commit8ec8da0491ad89604700b3e29a227966f6d84ba1 (patch)
tree9d270f173330ca19700e0ba9f2ee931300646de1 /Bugzilla/User
parenta7bb5a65b71644d9efce5fed783ed545b9336548 (diff)
downloadbugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.gz
bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.xz
no bug - reformat all the code using the new perltidy rules
Diffstat (limited to 'Bugzilla/User')
-rw-r--r--Bugzilla/User/APIKey.pm94
-rw-r--r--Bugzilla/User/Session.pm36
-rw-r--r--Bugzilla/User/Setting.pm437
-rw-r--r--Bugzilla/User/Setting/Lang.pm6
-rw-r--r--Bugzilla/User/Setting/Skin.pm43
-rw-r--r--Bugzilla/User/Setting/Timezone.pm22
6 files changed, 331 insertions, 307 deletions
diff --git a/Bugzilla/User/APIKey.pm b/Bugzilla/User/APIKey.pm
index c1a4ed572..a30c6718f 100644
--- a/Bugzilla/User/APIKey.pm
+++ b/Bugzilla/User/APIKey.pm
@@ -21,58 +21,60 @@ use Bugzilla::Error;
# Overriden Constants that are used as methods
#####################################################################
-use constant DB_TABLE => 'user_api_keys';
-use constant DB_COLUMNS => qw(
- id
- user_id
- api_key
- app_id
- description
- revoked
- last_used
- last_used_ip
+use constant DB_TABLE => 'user_api_keys';
+use constant DB_COLUMNS => qw(
+ id
+ user_id
+ api_key
+ app_id
+ description
+ revoked
+ last_used
+ last_used_ip
);
use constant UPDATE_COLUMNS => qw(description revoked last_used last_used_ip);
use constant VALIDATORS => {
- api_key => \&_check_api_key,
- app_id => \&_check_app_id,
- description => \&_check_description,
- revoked => \&Bugzilla::Object::check_boolean,
+ api_key => \&_check_api_key,
+ app_id => \&_check_app_id,
+ description => \&_check_description,
+ revoked => \&Bugzilla::Object::check_boolean,
};
-use constant LIST_ORDER => 'id';
-use constant NAME_FIELD => 'api_key';
+use constant LIST_ORDER => 'id';
+use constant NAME_FIELD => 'api_key';
# turn off auditing and exclude these objects from memcached
-use constant { AUDIT_CREATES => 0,
- AUDIT_UPDATES => 0,
- AUDIT_REMOVES => 0,
- USE_MEMCACHED => 0 };
+use constant {
+ AUDIT_CREATES => 0,
+ AUDIT_UPDATES => 0,
+ AUDIT_REMOVES => 0,
+ USE_MEMCACHED => 0
+};
# Accessors
-sub id { return $_[0]->{id} }
-sub user_id { return $_[0]->{user_id} }
-sub api_key { return $_[0]->{api_key} }
-sub app_id { return $_[0]->{app_id} }
-sub description { return $_[0]->{description} }
-sub revoked { return $_[0]->{revoked} }
-sub last_used { return $_[0]->{last_used} }
-sub last_used_ip { return $_[0]->{last_used_ip} }
+sub id { return $_[0]->{id} }
+sub user_id { return $_[0]->{user_id} }
+sub api_key { return $_[0]->{api_key} }
+sub app_id { return $_[0]->{app_id} }
+sub description { return $_[0]->{description} }
+sub revoked { return $_[0]->{revoked} }
+sub last_used { return $_[0]->{last_used} }
+sub last_used_ip { return $_[0]->{last_used_ip} }
# Helpers
sub user {
- my $self = shift;
- $self->{user} //= Bugzilla::User->new({name => $self->user_id, cache => 1});
- return $self->{user};
+ my $self = shift;
+ $self->{user} //= Bugzilla::User->new({name => $self->user_id, cache => 1});
+ return $self->{user};
}
sub update_last_used {
- my $self = shift;
- my $timestamp = shift
- || Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
- $self->set('last_used', $timestamp);
- $self->set('last_used_ip', remote_ip());
- $self->update;
+ my $self = shift;
+ my $timestamp
+ = shift || Bugzilla->dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
+ $self->set('last_used', $timestamp);
+ $self->set('last_used_ip', remote_ip());
+ $self->update;
}
# Setters
@@ -80,20 +82,22 @@ sub set_description { $_[0]->set('description', $_[1]); }
sub set_revoked { $_[0]->set('revoked', $_[1]); }
# Validators
-sub _check_api_key { return generate_random_password(40); }
-sub _check_description { return trim($_[1]) || ''; }
+sub _check_api_key { return generate_random_password(40); }
+sub _check_description { return trim($_[1]) || ''; }
+
sub _check_app_id {
- my ($invocant, $app_id) = @_;
+ my ($invocant, $app_id) = @_;
- ThrowCodeError("invalid_app_id", { app_id => $app_id }) unless $app_id =~ /^[[:xdigit:]]+$/;
+ ThrowCodeError("invalid_app_id", {app_id => $app_id})
+ unless $app_id =~ /^[[:xdigit:]]+$/;
- return $app_id;
+ return $app_id;
}
sub create_special {
- my ($class, @args) = @_;
- local VALIDATORS->{api_key} = sub { return $_[1] };
- return $class->create(@args);
+ my ($class, @args) = @_;
+ local VALIDATORS->{api_key} = sub { return $_[1] };
+ return $class->create(@args);
}
1;
diff --git a/Bugzilla/User/Session.pm b/Bugzilla/User/Session.pm
index 56e1cd07a..652a866c1 100644
--- a/Bugzilla/User/Session.pm
+++ b/Bugzilla/User/Session.pm
@@ -17,14 +17,14 @@ use base qw(Bugzilla::Object);
# Overriden Constants that are used as methods
#####################################################################
-use constant DB_TABLE => 'logincookies';
-use constant DB_COLUMNS => qw(
- cookie
- userid
- lastused
- ipaddr
- id
- restrict_ipaddr
+use constant DB_TABLE => 'logincookies';
+use constant DB_COLUMNS => qw(
+ cookie
+ userid
+ lastused
+ ipaddr
+ id
+ restrict_ipaddr
);
use constant UPDATE_COLUMNS => qw();
@@ -33,17 +33,19 @@ use constant LIST_ORDER => 'lastused DESC';
use constant NAME_FIELD => 'cookie';
# turn off auditing and exclude these objects from memcached
-use constant { AUDIT_CREATES => 0,
- AUDIT_UPDATES => 0,
- AUDIT_REMOVES => 0,
- USE_MEMCACHED => 0 };
+use constant {
+ AUDIT_CREATES => 0,
+ AUDIT_UPDATES => 0,
+ AUDIT_REMOVES => 0,
+ USE_MEMCACHED => 0
+};
# Accessors
-sub id { return $_[0]->{id} }
-sub userid { return $_[0]->{userid} }
-sub cookie { return $_[0]->{cookie} }
-sub lastused { return $_[0]->{lastused} }
-sub ipaddr { return $_[0]->{ipaddr} }
+sub id { return $_[0]->{id} }
+sub userid { return $_[0]->{userid} }
+sub cookie { return $_[0]->{cookie} }
+sub lastused { return $_[0]->{lastused} }
+sub ipaddr { return $_[0]->{ipaddr} }
sub restrict_ipaddr { return $_[0]->{restrict_ipaddr} }
1;
diff --git a/Bugzilla/User/Setting.pm b/Bugzilla/User/Setting.pm
index ac53fbb32..e08f3bd8c 100644
--- a/Bugzilla/User/Setting.pm
+++ b/Bugzilla/User/Setting.pm
@@ -13,12 +13,13 @@ use strict;
use warnings;
use base qw(Exporter);
+
# Module stuff
@Bugzilla::User::Setting::EXPORT = qw(
- get_all_settings
- get_defaults
- add_setting
- clear_settings_cache
+ get_all_settings
+ get_defaults
+ add_setting
+ clear_settings_cache
);
use Bugzilla::Error;
@@ -30,89 +31,86 @@ use Module::Runtime qw(require_module);
###############################
sub new {
- my $invocant = shift;
- my $setting_name = shift;
- my $user_id = shift;
-
- my $class = ref($invocant) || $invocant;
- my $subclass = '';
-
- # Create a ref to an empty hash and bless it
- my $self = {};
-
- my $dbh = Bugzilla->dbh;
-
- # Confirm that the $setting_name is properly formed;
- # if not, throw a code error.
- #
- # NOTE: due to the way that setting names are used in templates,
- # they must conform to to the limitations set for HTML NAMEs and IDs.
- #
- if ( !($setting_name =~ /^[a-zA-Z][-.:\w]*$/) ) {
- ThrowCodeError("setting_name_invalid", { name => $setting_name });
- }
-
- # If there were only two parameters passed in, then we need
- # to retrieve the information for this setting ourselves.
- if (scalar @_ == 0) {
-
- my ($default, $is_enabled, $value, $category);
- ($default, $is_enabled, $value, $subclass, $category) =
- $dbh->selectrow_array(
- q{SELECT default_value, is_enabled, setting_value, subclass, category
+ my $invocant = shift;
+ my $setting_name = shift;
+ my $user_id = shift;
+
+ my $class = ref($invocant) || $invocant;
+ my $subclass = '';
+
+ # Create a ref to an empty hash and bless it
+ my $self = {};
+
+ my $dbh = Bugzilla->dbh;
+
+ # Confirm that the $setting_name is properly formed;
+ # if not, throw a code error.
+ #
+ # NOTE: due to the way that setting names are used in templates,
+ # they must conform to to the limitations set for HTML NAMEs and IDs.
+ #
+ if (!($setting_name =~ /^[a-zA-Z][-.:\w]*$/)) {
+ ThrowCodeError("setting_name_invalid", {name => $setting_name});
+ }
+
+ # If there were only two parameters passed in, then we need
+ # to retrieve the information for this setting ourselves.
+ if (scalar @_ == 0) {
+
+ my ($default, $is_enabled, $value, $category);
+ ($default, $is_enabled, $value, $subclass, $category) = $dbh->selectrow_array(
+ q{SELECT default_value, is_enabled, setting_value, subclass, category
FROM setting
LEFT JOIN profile_setting
ON setting.name = profile_setting.setting_name
WHERE name = ?
- AND profile_setting.user_id = ?},
- undef,
- $setting_name, $user_id);
-
- # if not defined, then grab the default value
- if (! defined $value) {
- ($default, $is_enabled, $subclass, $category) =
- $dbh->selectrow_array(
- q{SELECT default_value, is_enabled, subclass, category
+ AND profile_setting.user_id = ?}, undef, $setting_name, $user_id
+ );
+
+ # if not defined, then grab the default value
+ if (!defined $value) {
+ ($default, $is_enabled, $subclass, $category) = $dbh->selectrow_array(
+ q{SELECT default_value, is_enabled, subclass, category
FROM setting
- WHERE name = ?},
- undef,
- $setting_name);
- }
-
- $self->{'is_enabled'} = $is_enabled;
- $self->{'default_value'} = $default;
- $self->{'category'} = $category;
-
- # IF the setting is enabled, AND the user has chosen a setting
- # THEN return that value
- # ELSE return the site default, and note that it is the default.
- if ( ($is_enabled) && (defined $value) ) {
- $self->{'value'} = $value;
- } else {
- $self->{'value'} = $default;
- $self->{'isdefault'} = 1;
- }
- }
- else {
- # If the values were passed in, simply assign them and return.
- $self->{'is_enabled'} = shift;
- $self->{'default_value'} = shift;
- $self->{'value'} = shift;
- $self->{'is_default'} = shift;
- $subclass = shift;
- $self->{'category'} = shift;
+ WHERE name = ?}, undef, $setting_name
+ );
}
- if ($subclass) {
- eval { require_module( $class . '::' . $subclass ) }
- || ThrowCodeError( 'setting_subclass_invalid', { 'subclass' => $subclass } );
- $class = $class . '::' . $subclass;
- }
- bless($self, $class);
- $self->{'_setting_name'} = $setting_name;
- $self->{'_user_id'} = $user_id;
+ $self->{'is_enabled'} = $is_enabled;
+ $self->{'default_value'} = $default;
+ $self->{'category'} = $category;
- return $self;
+ # IF the setting is enabled, AND the user has chosen a setting
+ # THEN return that value
+ # ELSE return the site default, and note that it is the default.
+ if (($is_enabled) && (defined $value)) {
+ $self->{'value'} = $value;
+ }
+ else {
+ $self->{'value'} = $default;
+ $self->{'isdefault'} = 1;
+ }
+ }
+ else {
+ # If the values were passed in, simply assign them and return.
+ $self->{'is_enabled'} = shift;
+ $self->{'default_value'} = shift;
+ $self->{'value'} = shift;
+ $self->{'is_default'} = shift;
+ $subclass = shift;
+ $self->{'category'} = shift;
+ }
+ if ($subclass) {
+ eval { require_module($class . '::' . $subclass) }
+ || ThrowCodeError('setting_subclass_invalid', {'subclass' => $subclass});
+ $class = $class . '::' . $subclass;
+ }
+ bless($self, $class);
+
+ $self->{'_setting_name'} = $setting_name;
+ $self->{'_user_id'} = $user_id;
+
+ return $self;
}
###############################
@@ -120,205 +118,220 @@ sub new {
###############################
sub add_setting {
- my ($params) = @_;
- my ($name, $options, $default, $subclass, $force_check, $silently, $category)
- = @$params{qw( name options default subclass force_check silently category )};
- my $dbh = Bugzilla->dbh;
-
- # Categories were added later, so we need to check if the old
- # setting has the correct category if provided
- my $exists = _setting_exists($name);
- if ($exists && $category) {
- my $old_category = $dbh->selectrow_arrayref(
- "SELECT category FROM setting WHERE name = ?", undef, $name);
- if ($old_category ne $category) {
- $dbh->do('UPDATE setting SET category = ? WHERE name = ?',
- undef, $category, $name);
- Bugzilla->memcached->clear_config();
- }
+ my ($params) = @_;
+ my ($name, $options, $default, $subclass, $force_check, $silently, $category)
+ = @$params{qw( name options default subclass force_check silently category )};
+ my $dbh = Bugzilla->dbh;
+
+ # Categories were added later, so we need to check if the old
+ # setting has the correct category if provided
+ my $exists = _setting_exists($name);
+ if ($exists && $category) {
+ my $old_category
+ = $dbh->selectrow_arrayref("SELECT category FROM setting WHERE name = ?",
+ undef, $name);
+ if ($old_category ne $category) {
+ $dbh->do('UPDATE setting SET category = ? WHERE name = ?',
+ undef, $category, $name);
+ Bugzilla->memcached->clear_config();
}
+ }
- return if ($exists && !$force_check);
-
- ($name && $default)
- || ThrowCodeError("setting_info_invalid");
-
- if ($exists) {
- # If this setting exists, we delete it and regenerate it.
- $dbh->do('DELETE FROM setting_value WHERE name = ?', undef, $name);
- $dbh->do('DELETE FROM setting WHERE name = ?', undef, $name);
- # Remove obsolete user preferences for this setting.
- if (defined $options && scalar(@$options)) {
- my $list = join(', ', map {$dbh->quote($_)} @$options);
- $dbh->do("DELETE FROM profile_setting
- WHERE setting_name = ? AND setting_value NOT IN ($list)",
- undef, $name);
- }
- }
- elsif (!$silently) {
- print get_text('install_setting_new', { name => $name }) . "\n";
- }
- $dbh->do(q{INSERT INTO setting (name, default_value, is_enabled, subclass, category)
- VALUES (?, ?, 1, ?, ?)},
- undef, ($name, $default, $subclass, $category));
+ return if ($exists && !$force_check);
+
+ ($name && $default) || ThrowCodeError("setting_info_invalid");
- my $sth = $dbh->prepare(q{INSERT INTO setting_value (name, value, sortindex)
- VALUES (?, ?, ?)});
+ if ($exists) {
- my $sortindex = 5;
- foreach my $key (@$options){
- $sth->execute($name, $key, $sortindex);
- $sortindex += 5;
+ # If this setting exists, we delete it and regenerate it.
+ $dbh->do('DELETE FROM setting_value WHERE name = ?', undef, $name);
+ $dbh->do('DELETE FROM setting WHERE name = ?', undef, $name);
+
+ # Remove obsolete user preferences for this setting.
+ if (defined $options && scalar(@$options)) {
+ my $list = join(', ', map { $dbh->quote($_) } @$options);
+ $dbh->do(
+ "DELETE FROM profile_setting
+ WHERE setting_name = ? AND setting_value NOT IN ($list)", undef,
+ $name
+ );
}
+ }
+ elsif (!$silently) {
+ print get_text('install_setting_new', {name => $name}) . "\n";
+ }
+ $dbh->do(
+ q{INSERT INTO setting (name, default_value, is_enabled, subclass, category)
+ VALUES (?, ?, 1, ?, ?)}, undef,
+ ($name, $default, $subclass, $category)
+ );
+
+ my $sth = $dbh->prepare(
+ q{INSERT INTO setting_value (name, value, sortindex)
+ VALUES (?, ?, ?)}
+ );
+
+ my $sortindex = 5;
+ foreach my $key (@$options) {
+ $sth->execute($name, $key, $sortindex);
+ $sortindex += 5;
+ }
}
sub get_all_settings {
- my ($user_id) = @_;
- my $settings = {};
- my $dbh = Bugzilla->dbh;
-
- my $cache_key = "user_settings.$user_id";
- my $rows = Bugzilla->memcached->get_config({ key => $cache_key });
- if (!$rows) {
- $rows = $dbh->selectall_arrayref(
- q{SELECT name, default_value, is_enabled, setting_value, subclass, category
+ my ($user_id) = @_;
+ my $settings = {};
+ my $dbh = Bugzilla->dbh;
+
+ my $cache_key = "user_settings.$user_id";
+ my $rows = Bugzilla->memcached->get_config({key => $cache_key});
+ if (!$rows) {
+ $rows = $dbh->selectall_arrayref(
+ q{SELECT name, default_value, is_enabled, setting_value, subclass, category
FROM setting
LEFT JOIN profile_setting
ON setting.name = profile_setting.setting_name
- AND profile_setting.user_id = ?}, undef, ($user_id));
- Bugzilla->memcached->set_config({ key => $cache_key, data => $rows });
- }
+ AND profile_setting.user_id = ?}, undef, ($user_id)
+ );
+ Bugzilla->memcached->set_config({key => $cache_key, data => $rows});
+ }
- foreach my $row (@$rows) {
- my ($name, $default_value, $is_enabled, $value, $subclass, $category) = @$row;
+ foreach my $row (@$rows) {
+ my ($name, $default_value, $is_enabled, $value, $subclass, $category) = @$row;
- my $is_default;
+ my $is_default;
- if ( ($is_enabled) && (defined $value) ) {
- $is_default = 0;
- } else {
- $value = $default_value;
- $is_default = 1;
- }
-
- $settings->{$name} = new Bugzilla::User::Setting(
- $name, $user_id, $is_enabled,
- $default_value, $value, $is_default,
- $subclass, $category);
+ if (($is_enabled) && (defined $value)) {
+ $is_default = 0;
}
+ else {
+ $value = $default_value;
+ $is_default = 1;
+ }
+
+ $settings->{$name}
+ = new Bugzilla::User::Setting($name, $user_id, $is_enabled, $default_value,
+ $value, $is_default, $subclass, $category);
+ }
- return $settings;
+ return $settings;
}
sub clear_settings_cache {
- my ($user_id) = @_;
- Bugzilla->memcached->clear_config({ key => "user_settings.$user_id" });
+ my ($user_id) = @_;
+ Bugzilla->memcached->clear_config({key => "user_settings.$user_id"});
}
sub get_defaults {
- my ($user_id) = @_;
- my $dbh = Bugzilla->dbh;
- my $default_settings = {};
+ my ($user_id) = @_;
+ my $dbh = Bugzilla->dbh;
+ my $default_settings = {};
- $user_id ||= 0;
+ $user_id ||= 0;
- my $rows = $dbh->selectall_arrayref(q{SELECT name, default_value, is_enabled, subclass, category
- FROM setting});
+ my $rows = $dbh->selectall_arrayref(
+ q{SELECT name, default_value, is_enabled, subclass, category
+ FROM setting}
+ );
- foreach my $row (@$rows) {
- my ($name, $default_value, $is_enabled, $subclass, $category) = @$row;
+ foreach my $row (@$rows) {
+ my ($name, $default_value, $is_enabled, $subclass, $category) = @$row;
- $default_settings->{$name} = new Bugzilla::User::Setting(
- $name, $user_id, $is_enabled, $default_value, $default_value, 1,
- $subclass, $category);
- }
+ $default_settings->{$name}
+ = new Bugzilla::User::Setting($name, $user_id, $is_enabled, $default_value,
+ $default_value, 1, $subclass, $category);
+ }
- return $default_settings;
+ return $default_settings;
}
sub set_default {
- my ($setting_name, $default_value, $is_enabled) = @_;
- my $dbh = Bugzilla->dbh;
+ my ($setting_name, $default_value, $is_enabled) = @_;
+ my $dbh = Bugzilla->dbh;
- my $sth = $dbh->prepare(q{UPDATE setting
+ my $sth = $dbh->prepare(
+ q{UPDATE setting
SET default_value = ?, is_enabled = ?
- WHERE name = ?});
- $sth->execute($default_value, $is_enabled, $setting_name);
+ WHERE name = ?}
+ );
+ $sth->execute($default_value, $is_enabled, $setting_name);
}
sub _setting_exists {
- my ($setting_name) = @_;
- my $dbh = Bugzilla->dbh;
- return $dbh->selectrow_arrayref(
- "SELECT 1 FROM setting WHERE name = ?", undef, $setting_name) || 0;
+ my ($setting_name) = @_;
+ my $dbh = Bugzilla->dbh;
+ return $dbh->selectrow_arrayref("SELECT 1 FROM setting WHERE name = ?",
+ undef, $setting_name)
+ || 0;
}
sub legal_values {
- my ($self) = @_;
+ my ($self) = @_;
- return $self->{'legal_values'} if defined $self->{'legal_values'};
+ return $self->{'legal_values'} if defined $self->{'legal_values'};
- my $dbh = Bugzilla->dbh;
- $self->{'legal_values'} = $dbh->selectcol_arrayref(
- q{SELECT value
+ my $dbh = Bugzilla->dbh;
+ $self->{'legal_values'} = $dbh->selectcol_arrayref(
+ q{SELECT value
FROM setting_value
WHERE name = ?
- ORDER BY sortindex},
- undef, $self->{'_setting_name'});
+ ORDER BY sortindex}, undef, $self->{'_setting_name'}
+ );
- return $self->{'legal_values'};
+ return $self->{'legal_values'};
}
sub validate_value {
- my $self = shift;
-
- if (grep(/^$_[0]$/, @{$self->legal_values()})) {
- trick_taint($_[0]);
- }
- else {
- ThrowCodeError('setting_value_invalid',
- {'name' => $self->{'_setting_name'},
- 'value' => $_[0]});
- }
+ my $self = shift;
+
+ if (grep(/^$_[0]$/, @{$self->legal_values()})) {
+ trick_taint($_[0]);
+ }
+ else {
+ ThrowCodeError('setting_value_invalid',
+ {'name' => $self->{'_setting_name'}, 'value' => $_[0]});
+ }
}
sub reset_to_default {
- my ($self) = @_;
+ my ($self) = @_;
- my $dbh = Bugzilla->dbh;
- my $sth = $dbh->do(q{ DELETE
+ my $dbh = Bugzilla->dbh;
+ my $sth = $dbh->do(
+ q{ DELETE
FROM profile_setting
WHERE setting_name = ?
- AND user_id = ?},
- undef, $self->{'_setting_name'}, $self->{'_user_id'});
- $self->{'value'} = $self->{'default_value'};
- $self->{'is_default'} = 1;
+ AND user_id = ?}, undef, $self->{'_setting_name'},
+ $self->{'_user_id'}
+ );
+ $self->{'value'} = $self->{'default_value'};
+ $self->{'is_default'} = 1;
}
sub set {
- my ($self, $value) = @_;
- my $dbh = Bugzilla->dbh;
- my $query;
+ my ($self, $value) = @_;
+ my $dbh = Bugzilla->dbh;
+ my $query;
- if ($self->{'is_default'}) {
- $query = q{INSERT INTO profile_setting
+ if ($self->{'is_default'}) {
+ $query = q{INSERT INTO profile_setting
(setting_value, setting_name, user_id)
VALUES (?,?,?)};
- } else {
- $query = q{UPDATE profile_setting
+ }
+ else {
+ $query = q{UPDATE profile_setting
SET setting_value = ?
WHERE setting_name = ?
AND user_id = ?};
- }
- $dbh->do($query, undef, $value, $self->{'_setting_name'}, $self->{'_user_id'});
+ }
+ $dbh->do($query, undef, $value, $self->{'_setting_name'}, $self->{'_user_id'});
- $self->{'value'} = $value;
- $self->{'is_default'} = 0;
+ $self->{'value'} = $value;
+ $self->{'is_default'} = 0;
}
-
1;
__END__
diff --git a/Bugzilla/User/Setting/Lang.pm b/Bugzilla/User/Setting/Lang.pm
index a3032b9fc..5f49bc6e4 100644
--- a/Bugzilla/User/Setting/Lang.pm
+++ b/Bugzilla/User/Setting/Lang.pm
@@ -16,11 +16,11 @@ use base qw(Bugzilla::User::Setting);
use Bugzilla::Constants;
sub legal_values {
- my ($self) = @_;
+ my ($self) = @_;
- return $self->{'legal_values'} if defined $self->{'legal_values'};
+ return $self->{'legal_values'} if defined $self->{'legal_values'};
- return $self->{'legal_values'} = Bugzilla->languages;
+ return $self->{'legal_values'} = Bugzilla->languages;
}
1;
diff --git a/Bugzilla/User/Setting/Skin.pm b/Bugzilla/User/Setting/Skin.pm
index f0ea502ef..f4d82007b 100644
--- a/Bugzilla/User/Setting/Skin.pm
+++ b/Bugzilla/User/Setting/Skin.pm
@@ -21,28 +21,31 @@ use File::Basename;
use constant BUILTIN_SKIN_NAMES => ['standard'];
sub legal_values {
- my ($self) = @_;
-
- return $self->{'legal_values'} if defined $self->{'legal_values'};
-
- my $dirbase = bz_locations()->{'skinsdir'} . '/contrib';
- # Avoid modification of the list BUILTIN_SKIN_NAMES points to by copying the
- # list over instead of simply writing $legal_values = BUILTIN_SKIN_NAMES.
- my @legal_values = @{(BUILTIN_SKIN_NAMES)};
-
- foreach my $direntry (glob(catdir($dirbase, '*'))) {
- if (-d $direntry) {
- # Stylesheet set
- next if basename($direntry) =~ /^cvs$/i;
- push(@legal_values, basename($direntry));
- }
- elsif ($direntry =~ /\.css$/) {
- # Single-file stylesheet
- push(@legal_values, basename($direntry));
- }
+ my ($self) = @_;
+
+ return $self->{'legal_values'} if defined $self->{'legal_values'};
+
+ my $dirbase = bz_locations()->{'skinsdir'} . '/contrib';
+
+ # Avoid modification of the list BUILTIN_SKIN_NAMES points to by copying the
+ # list over instead of simply writing $legal_values = BUILTIN_SKIN_NAMES.
+ my @legal_values = @{(BUILTIN_SKIN_NAMES)};
+
+ foreach my $direntry (glob(catdir($dirbase, '*'))) {
+ if (-d $direntry) {
+
+ # Stylesheet set
+ next if basename($direntry) =~ /^cvs$/i;
+ push(@legal_values, basename($direntry));
+ }
+ elsif ($direntry =~ /\.css$/) {
+
+ # Single-file stylesheet
+ push(@legal_values, basename($direntry));
}
+ }
- return $self->{'legal_values'} = \@legal_values;
+ return $self->{'legal_values'} = \@legal_values;
}
1;
diff --git a/Bugzilla/User/Setting/Timezone.pm b/Bugzilla/User/Setting/Timezone.pm
index a9515259e..6e20f1fc2 100644
--- a/Bugzilla/User/Setting/Timezone.pm
+++ b/Bugzilla/User/Setting/Timezone.pm
@@ -18,19 +18,21 @@ use base qw(Bugzilla::User::Setting);
use Bugzilla::Constants;
sub legal_values {
- my ($self) = @_;
+ my ($self) = @_;
- return $self->{'legal_values'} if defined $self->{'legal_values'};
+ return $self->{'legal_values'} if defined $self->{'legal_values'};
- my @timezones = DateTime::TimeZone->all_names;
- # Remove old formats, such as CST6CDT, EST, EST5EDT.
- @timezones = grep { $_ =~ m#.+/.+#} @timezones;
- # Append 'local' to the list, which will use the timezone
- # given by the server.
- push(@timezones, 'local');
- push(@timezones, 'UTC');
+ my @timezones = DateTime::TimeZone->all_names;
- return $self->{'legal_values'} = \@timezones;
+ # Remove old formats, such as CST6CDT, EST, EST5EDT.
+ @timezones = grep { $_ =~ m#.+/.+# } @timezones;
+
+ # Append 'local' to the list, which will use the timezone
+ # given by the server.
+ push(@timezones, 'local');
+ push(@timezones, 'UTC');
+
+ return $self->{'legal_values'} = \@timezones;
}
1;