diff options
Diffstat (limited to 'extensions/UserStory')
-rw-r--r-- | extensions/UserStory/Config.pm | 9 | ||||
-rw-r--r-- | extensions/UserStory/Extension.pm | 110 | ||||
-rw-r--r-- | extensions/UserStory/lib/Constants.pm | 2 |
3 files changed, 58 insertions, 63 deletions
diff --git a/extensions/UserStory/Config.pm b/extensions/UserStory/Config.pm index 8668deaa7..baf1776d3 100644 --- a/extensions/UserStory/Config.pm +++ b/extensions/UserStory/Config.pm @@ -12,13 +12,8 @@ use strict; use warnings; use constant NAME => 'UserStory'; -use constant REQUIRED_MODULES => [ - { - package => 'Text-Diff', - module => 'Text::Diff', - version => 0, - }, -]; +use constant REQUIRED_MODULES => + [{package => 'Text-Diff', module => 'Text::Diff', version => 0,},]; use constant OPTIONAL_MODULES => []; __PACKAGE__->NAME; diff --git a/extensions/UserStory/Extension.pm b/extensions/UserStory/Extension.pm index f9fdb3f29..0be43173b 100644 --- a/extensions/UserStory/Extension.pm +++ b/extensions/UserStory/Extension.pm @@ -23,82 +23,82 @@ use Bugzilla::Extension::BMO::FakeBug; use Text::Diff; BEGIN { - *Bugzilla::Bug::user_story_visible = \&_bug_user_story_visible; - *Bugzilla::Extension::BMO::FakeBug::user_story_visible = \&_bug_user_story_visible; + *Bugzilla::Bug::user_story_visible = \&_bug_user_story_visible; + *Bugzilla::Extension::BMO::FakeBug::user_story_visible + = \&_bug_user_story_visible; } sub _bug_user_story_visible { - my ($self) = @_; - if (!exists $self->{user_story_visible}) { - # Visible by default - $self->{user_story_visible} = 1; - my ($product, $component) = ($self->product, $self->component); - my $exclude_components = []; - if (exists USER_STORY_EXCLUDE->{$product}) { - $exclude_components = USER_STORY_EXCLUDE->{$product}; - if (scalar(@$exclude_components) == 0 - || ($component && grep { $_ eq $component } @$exclude_components)) - { - $self->{user_story_visible} = 0; - } - } - $self->{user_story_exclude_components} = $exclude_components; + my ($self) = @_; + if (!exists $self->{user_story_visible}) { + + # Visible by default + $self->{user_story_visible} = 1; + my ($product, $component) = ($self->product, $self->component); + my $exclude_components = []; + if (exists USER_STORY_EXCLUDE->{$product}) { + $exclude_components = USER_STORY_EXCLUDE->{$product}; + if (scalar(@$exclude_components) == 0 + || ($component && grep { $_ eq $component } @$exclude_components)) + { + $self->{user_story_visible} = 0; + } } - return ($self->{user_story_visible}, $self->{user_story_exclude_components}); + $self->{user_story_exclude_components} = $exclude_components; + } + return ($self->{user_story_visible}, $self->{user_story_exclude_components}); } # ensure user is allowed to edit the story sub bug_check_can_change_field { - my ($self, $args) = @_; - my ($bug, $field, $priv_results) = @$args{qw(bug field priv_results)}; - return unless $field eq 'cf_user_story'; - if (!Bugzilla->user->in_group(USER_STORY_GROUP)) { - push (@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED); - } + my ($self, $args) = @_; + my ($bug, $field, $priv_results) = @$args{qw(bug field priv_results)}; + return unless $field eq 'cf_user_story'; + if (!Bugzilla->user->in_group(USER_STORY_GROUP)) { + push(@$priv_results, PRIVILEGES_REQUIRED_EMPOWERED); + } } # store just a diff of the changes in the bugs_activity table sub bug_update_before_logging { - my ($self, $args) = @_; - my $changes = $args->{changes}; - return unless exists $changes->{cf_user_story}; - my $diff = diff( - \$changes->{cf_user_story}->[0], - \$changes->{cf_user_story}->[1], - { - CONTEXT => 0, - }, - ); - $changes->{cf_user_story} = [ '', $diff ]; + my ($self, $args) = @_; + my $changes = $args->{changes}; + return unless exists $changes->{cf_user_story}; + my $diff = diff( + \$changes->{cf_user_story}->[0], + \$changes->{cf_user_story}->[1], + {CONTEXT => 0,}, + ); + $changes->{cf_user_story} = ['', $diff]; } # stop inline-history from displaying changes to the user story sub inline_history_activtiy { - my ($self, $args) = @_; - foreach my $activity (@{ $args->{activity} }) { - foreach my $change (@{ $activity->{changes} }) { - if ($change->{fieldname} eq 'cf_user_story') { - $change->{removed} = ''; - $change->{added} = '(updated)'; - } - } + my ($self, $args) = @_; + foreach my $activity (@{$args->{activity}}) { + foreach my $change (@{$activity->{changes}}) { + if ($change->{fieldname} eq 'cf_user_story') { + $change->{removed} = ''; + $change->{added} = '(updated)'; + } } + } } # create cf_user_story field sub install_update_db { - my ($self, $args) = @_; - return if Bugzilla::Field->new({ name => 'cf_user_story'}); - Bugzilla::Field->create({ - name => 'cf_user_story', - description => 'User Story', - type => FIELD_TYPE_TEXTAREA, - mailhead => 0, - enter_bug => 0, - obsolete => 0, - custom => 1, - buglist => 0, - }); + my ($self, $args) = @_; + return if Bugzilla::Field->new({name => 'cf_user_story'}); + Bugzilla::Field->create({ + name => 'cf_user_story', + description => 'User Story', + type => FIELD_TYPE_TEXTAREA, + mailhead => 0, + enter_bug => 0, + obsolete => 0, + custom => 1, + buglist => 0, + }); } __PACKAGE__->NAME; diff --git a/extensions/UserStory/lib/Constants.pm b/extensions/UserStory/lib/Constants.pm index 6a1c0c449..49f6b0d22 100644 --- a/extensions/UserStory/lib/Constants.pm +++ b/extensions/UserStory/lib/Constants.pm @@ -25,6 +25,6 @@ use constant USER_STORY_GROUP => 'editbugs'; # Don't show User Story on Developer Tools component, visible on all other # Firefox components # 'Firefox' => ['Developer Tools'], -use constant USER_STORY_EXCLUDE => { }; +use constant USER_STORY_EXCLUDE => {}; 1; |