diff options
author | Perl Tidy <perltidy@bugzilla.org> | 2018-12-05 21:38:52 +0100 |
---|---|---|
committer | Dylan William Hardison <dylan@hardison.net> | 2018-12-05 23:49:08 +0100 |
commit | 8ec8da0491ad89604700b3e29a227966f6d84ba1 (patch) | |
tree | 9d270f173330ca19700e0ba9f2ee931300646de1 /extensions/ShadowBugs | |
parent | a7bb5a65b71644d9efce5fed783ed545b9336548 (diff) | |
download | bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.gz bugzilla-8ec8da0491ad89604700b3e29a227966f6d84ba1.tar.xz |
no bug - reformat all the code using the new perltidy rules
Diffstat (limited to 'extensions/ShadowBugs')
-rw-r--r-- | extensions/ShadowBugs/Config.pm | 2 | ||||
-rw-r--r-- | extensions/ShadowBugs/Extension.pm | 114 |
2 files changed, 59 insertions, 57 deletions
diff --git a/extensions/ShadowBugs/Config.pm b/extensions/ShadowBugs/Config.pm index 6999edaf3..a45948dd4 100644 --- a/extensions/ShadowBugs/Config.pm +++ b/extensions/ShadowBugs/Config.pm @@ -8,7 +8,7 @@ package Bugzilla::Extension::ShadowBugs; use strict; -use constant NAME => 'ShadowBugs'; +use constant NAME => 'ShadowBugs'; use constant REQUIRED_MODULES => []; use constant OPTIONAL_MODULES => []; diff --git a/extensions/ShadowBugs/Extension.pm b/extensions/ShadowBugs/Extension.pm index a9a1e0861..a1eb4a8c1 100644 --- a/extensions/ShadowBugs/Extension.pm +++ b/extensions/ShadowBugs/Extension.pm @@ -19,81 +19,83 @@ use Bugzilla::User; our $VERSION = '1'; BEGIN { - *Bugzilla::is_cf_shadow_bug_hidden = \&_is_cf_shadow_bug_hidden; - *Bugzilla::Bug::cf_shadow_bug_obj = \&_cf_shadow_bug_obj; + *Bugzilla::is_cf_shadow_bug_hidden = \&_is_cf_shadow_bug_hidden; + *Bugzilla::Bug::cf_shadow_bug_obj = \&_cf_shadow_bug_obj; } # Determine if the shadow-bug / shadowed-by fields are visibile on the # specified bug. sub _is_cf_shadow_bug_hidden { - my ($self, $bug) = @_; + my ($self, $bug) = @_; - # completely hide unless you're a member of the right group - return 1 unless Bugzilla->user->in_group('can_shadow_bugs'); + # completely hide unless you're a member of the right group + return 1 unless Bugzilla->user->in_group('can_shadow_bugs'); - my $is_public = Bugzilla::User->new()->can_see_bug($bug->id); - if ($is_public) { - # hide on public bugs, unless it's shadowed - my $related = $bug->related_bugs(Bugzilla->process_cache->{shadow_bug_field}); - return 1 if !@$related; - } + my $is_public = Bugzilla::User->new()->can_see_bug($bug->id); + if ($is_public) { + + # hide on public bugs, unless it's shadowed + my $related = $bug->related_bugs(Bugzilla->process_cache->{shadow_bug_field}); + return 1 if !@$related; + } } sub _cf_shadow_bug_obj { - my ($self) = @_; - return unless $self->cf_shadow_bug; - return $self->{cf_shadow_bug_obj} ||= Bugzilla::Bug->new($self->cf_shadow_bug); + my ($self) = @_; + return unless $self->cf_shadow_bug; + return $self->{cf_shadow_bug_obj} ||= Bugzilla::Bug->new($self->cf_shadow_bug); } sub template_before_process { - my ($self, $args) = @_; - my $file = $args->{'file'}; - my $vars = $args->{'vars'}; - - Bugzilla->process_cache->{shadow_bug_field} ||= Bugzilla::Field->new({ name => 'cf_shadow_bug' }); - - return unless Bugzilla->user->in_group('can_shadow_bugs'); - return unless - $file eq 'bug/edit.html.tmpl' - || $file eq 'bug/show.html.tmpl' - || $file eq 'bug/show-header.html.tmpl'; - my $bug = exists $vars->{'bugs'} ? $vars->{'bugs'}[0] : $vars->{'bug'}; - return unless $bug && $bug->cf_shadow_bug; - $vars->{is_shadow_bug} = 1; - - if ($file eq 'bug/edit.html.tmpl') { - # load comments from other bug - $vars->{shadow_comments} = $bug->cf_shadow_bug_obj->comments; - } + my ($self, $args) = @_; + my $file = $args->{'file'}; + my $vars = $args->{'vars'}; + + Bugzilla->process_cache->{shadow_bug_field} + ||= Bugzilla::Field->new({name => 'cf_shadow_bug'}); + + return unless Bugzilla->user->in_group('can_shadow_bugs'); + return + unless $file eq 'bug/edit.html.tmpl' + || $file eq 'bug/show.html.tmpl' + || $file eq 'bug/show-header.html.tmpl'; + my $bug = exists $vars->{'bugs'} ? $vars->{'bugs'}[0] : $vars->{'bug'}; + return unless $bug && $bug->cf_shadow_bug; + $vars->{is_shadow_bug} = 1; + + if ($file eq 'bug/edit.html.tmpl') { + + # load comments from other bug + $vars->{shadow_comments} = $bug->cf_shadow_bug_obj->comments; + } } sub bug_end_of_update { - my ($self, $args) = @_; - - # don't allow shadowing non-public bugs - if (exists $args->{changes}->{cf_shadow_bug}) { - my ($old_id, $new_id) = @{ $args->{changes}->{cf_shadow_bug} }; - if ($new_id) { - if (!Bugzilla::User->new()->can_see_bug($new_id)) { - ThrowUserError('illegal_shadow_bug_public', { id => $new_id }); - } - } + my ($self, $args) = @_; + + # don't allow shadowing non-public bugs + if (exists $args->{changes}->{cf_shadow_bug}) { + my ($old_id, $new_id) = @{$args->{changes}->{cf_shadow_bug}}; + if ($new_id) { + if (!Bugzilla::User->new()->can_see_bug($new_id)) { + ThrowUserError('illegal_shadow_bug_public', {id => $new_id}); + } } + } + + # if a shadow bug is made public, clear the shadow_bug field + if (exists $args->{changes}->{bug_group}) { + my $bug = $args->{bug}; + return unless my $shadow_id = $bug->cf_shadow_bug; + my $is_public = Bugzilla::User->new()->can_see_bug($bug->id); + if ($is_public) { + Bugzilla->dbh->do("UPDATE bugs SET cf_shadow_bug=NULL WHERE bug_id=?", + undef, $bug->id); + LogActivityEntry($bug->id, 'cf_shadow_bug', $shadow_id, '', Bugzilla->user->id, + $args->{timestamp}); - # if a shadow bug is made public, clear the shadow_bug field - if (exists $args->{changes}->{bug_group}) { - my $bug = $args->{bug}; - return unless my $shadow_id = $bug->cf_shadow_bug; - my $is_public = Bugzilla::User->new()->can_see_bug($bug->id); - if ($is_public) { - Bugzilla->dbh->do( - "UPDATE bugs SET cf_shadow_bug=NULL WHERE bug_id=?", - undef, $bug->id); - LogActivityEntry($bug->id, 'cf_shadow_bug', $shadow_id, '', - Bugzilla->user->id, $args->{timestamp}); - - } } + } } __PACKAGE__->NAME; |