summaryrefslogtreecommitdiffstats
path: root/extensions/RestrictComments/Extension.pm
diff options
context:
space:
mode:
Diffstat (limited to 'extensions/RestrictComments/Extension.pm')
-rw-r--r--extensions/RestrictComments/Extension.pm98
1 files changed, 50 insertions, 48 deletions
diff --git a/extensions/RestrictComments/Extension.pm b/extensions/RestrictComments/Extension.pm
index e93540d5a..83075ac23 100644
--- a/extensions/RestrictComments/Extension.pm
+++ b/extensions/RestrictComments/Extension.pm
@@ -17,84 +17,86 @@ use Bugzilla::Constants;
use Bugzilla::Util qw(i_am_webservice);
BEGIN {
- *Bugzilla::Bug::restrict_comments = \&_bug_restrict_comments;
+ *Bugzilla::Bug::restrict_comments = \&_bug_restrict_comments;
}
sub _bug_restrict_comments {
- my ($self) = @_;
- return $self->{restrict_comments};
+ my ($self) = @_;
+ return $self->{restrict_comments};
}
sub bug_check_can_change_field {
- my ($self, $args) = @_;
- my ($bug, $priv_results) = @$args{qw(bug priv_results)};
- my $user = Bugzilla->user;
-
- if ($user->id
- && $bug->restrict_comments
- && !$user->in_group(Bugzilla->params->{'restrict_comments_group'}))
- {
- push(@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED);
- return;
- }
+ my ($self, $args) = @_;
+ my ($bug, $priv_results) = @$args{qw(bug priv_results)};
+ my $user = Bugzilla->user;
+
+ if ( $user->id
+ && $bug->restrict_comments
+ && !$user->in_group(Bugzilla->params->{'restrict_comments_group'}))
+ {
+ push(@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED);
+ return;
+ }
}
sub _can_restrict_comments {
- my ($self, $object) = @_;
- return unless $object->isa('Bugzilla::Bug');
- $self->{setter_group} ||= Bugzilla->params->{'restrict_comments_enable_group'};
- return Bugzilla->user->in_group($self->{setter_group});
+ my ($self, $object) = @_;
+ return unless $object->isa('Bugzilla::Bug');
+ $self->{setter_group} ||= Bugzilla->params->{'restrict_comments_enable_group'};
+ return Bugzilla->user->in_group($self->{setter_group});
}
sub object_end_of_set_all {
- my ($self, $args) = @_;
- my $object = $args->{object};
- my $input = Bugzilla->input_params;
- my $update_restrict_comments = !i_am_webservice() || exists $input->{restrict_comments};
- if ($update_restrict_comments && $self->_can_restrict_comments($object)) {
- $object->set('restrict_comments', $input->{restrict_comments} ? 1 : undef);
- }
+ my ($self, $args) = @_;
+ my $object = $args->{object};
+ my $input = Bugzilla->input_params;
+ my $update_restrict_comments
+ = !i_am_webservice() || exists $input->{restrict_comments};
+ if ($update_restrict_comments && $self->_can_restrict_comments($object)) {
+ $object->set('restrict_comments', $input->{restrict_comments} ? 1 : undef);
+ }
}
sub object_update_columns {
- my ($self, $args) = @_;
- my ($object, $columns) = @$args{qw(object columns)};
- if ($self->_can_restrict_comments($object)) {
- push(@$columns, 'restrict_comments');
- }
+ my ($self, $args) = @_;
+ my ($object, $columns) = @$args{qw(object columns)};
+ if ($self->_can_restrict_comments($object)) {
+ push(@$columns, 'restrict_comments');
+ }
}
sub object_columns {
- my ($self, $args) = @_;
- my ($class, $columns) = @$args{qw(class columns)};
- if ($class->isa('Bugzilla::Bug')) {
- if (Bugzilla->dbh->bz_column_info($class->DB_TABLE, 'restrict_comments')) {
- push @$columns, 'restrict_comments';
- }
+ my ($self, $args) = @_;
+ my ($class, $columns) = @$args{qw(class columns)};
+ if ($class->isa('Bugzilla::Bug')) {
+ if (Bugzilla->dbh->bz_column_info($class->DB_TABLE, 'restrict_comments')) {
+ push @$columns, 'restrict_comments';
}
+ }
}
sub bug_fields {
- my ($self, $args) = @_;
- my $fields = $args->{'fields'};
- push (@$fields, 'restrict_comments')
+ my ($self, $args) = @_;
+ my $fields = $args->{'fields'};
+ push(@$fields, 'restrict_comments');
}
sub config_add_panels {
- my ($self, $args) = @_;
- my $modules = $args->{panel_modules};
- $modules->{RestrictComments} = "Bugzilla::Extension::RestrictComments::Config";
+ my ($self, $args) = @_;
+ my $modules = $args->{panel_modules};
+ $modules->{RestrictComments} = "Bugzilla::Extension::RestrictComments::Config";
}
sub install_update_db {
- my $dbh = Bugzilla->dbh;
+ my $dbh = Bugzilla->dbh;
- my $field = new Bugzilla::Field({ name => 'restrict_comments' });
- if (!$field) {
- Bugzilla::Field->create({ name => 'restrict_comments', description => 'Restrict Comments' });
- }
+ my $field = new Bugzilla::Field({name => 'restrict_comments'});
+ if (!$field) {
+ Bugzilla::Field->create(
+ {name => 'restrict_comments', description => 'Restrict Comments'});
+ }
- $dbh->bz_add_column('bugs', 'restrict_comments', { TYPE => 'BOOLEAN' });
+ $dbh->bz_add_column('bugs', 'restrict_comments', {TYPE => 'BOOLEAN'});
}
__PACKAGE__->NAME;