diff options
author | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-05-23 07:09:43 +0200 |
---|---|---|
committer | Max Kanat-Alexander <mkanat@bugzilla.org> | 2010-05-23 07:09:43 +0200 |
commit | 5f2a455c24b4b6d4dc2ac2b59fc47f0c0f2e5bc6 (patch) | |
tree | b5aa0cf54dcb9600908e1b51c500bd46e423ced2 | |
parent | 0481e9aa5d957665c206c9de1efc8c7f8c56cb4c (diff) | |
download | bugzilla-5f2a455c24b4b6d4dc2ac2b59fc47f0c0f2e5bc6.tar.gz bugzilla-5f2a455c24b4b6d4dc2ac2b59fc47f0c0f2e5bc6.tar.xz |
Bug 556397: Move the setting of single-bug fields from process_bug.cgi
into Bugzilla::Bug::set_all
r=dkl, a=mkanat
-rw-r--r-- | Bugzilla/Bug.pm | 10 | ||||
-rwxr-xr-x | process_bug.cgi | 51 |
2 files changed, 32 insertions, 29 deletions
diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index dcf3f96da..c1f4dc12f 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -1968,7 +1968,6 @@ sub set_all { $self->set_custom_field($field, $params->{$fname}); } } - } sub set_alias { $_[0]->set('alias', $_[1]); } @@ -1988,6 +1987,15 @@ sub set_cclist_accessible { $_[0]->set('cclist_accessible', $_[1]); } sub set_comment_is_private { my ($self, $comment_id, $isprivate) = @_; return unless Bugzilla->user->is_insider; + + # We also allow people to pass in a hash of comment ids to update. + if (ref $comment_id) { + while (my ($id, $is) = each %$comment_id) { + $self->set_comment_is_private($id, $is); + } + return; + } + my ($comment) = grep($comment_id == $_->id, @{ $self->comments }); ThrowUserError('comment_invalid_isprivate', { id => $comment_id }) if !$comment; diff --git a/process_bug.cgi b/process_bug.cgi index 63fc3209b..3330a6803 100755 --- a/process_bug.cgi +++ b/process_bug.cgi @@ -263,7 +263,8 @@ my @set_fields = qw(op_sys rep_platform priority bug_severity bug_file_loc status_whiteboard short_desc deadline remaining_time estimated_time work_time set_default_assignee set_default_qa_contact - keywords keywordaction); + keywords keywordaction + cclist_accessible reporter_accessible); push(@set_fields, 'assigned_to') if !$cgi->param('set_default_assignee'); push(@set_fields, 'qa_contact') if !$cgi->param('set_default_qa_contact'); my %field_translation = ( @@ -278,7 +279,7 @@ my %field_translation = ( my %set_all_fields; foreach my $field_name (@set_fields) { - if (should_set($field_name)) { + if (should_set($field_name, 1)) { my $param_name = $field_translation{$field_name} || $field_name; $set_all_fields{$param_name} = $cgi->param($field_name); } @@ -308,6 +309,24 @@ foreach my $dep_field (qw(dependson blocked)) { } } } + +# Fields that can only be set on one bug at a time. +if (defined $cgi->param('id')) { + # Since aliases are unique (like bug numbers), they can only be changed + # for one bug at a time. + if (Bugzilla->params->{"usebugaliases"} && defined $cgi->param('alias')) { + $set_all_fields{alias} = $cgi->param('alias'); + } +} + +my %is_private; +foreach my $field (grep(/^defined_isprivate/, $cgi->param())) { + $field =~ /(\d+)$/; + my $comment_id = $1; + $is_private{$comment_id} = $cgi->param("isprivate_$comment_id"); +} +$set_all_fields{comment_is_private} = \%is_private; + my %groups = ( add => [], remove => [] ); my %checked_bit; # Used to avoid adding groups twice (defined_ + actual bit-) foreach my $param_name (grep(/bit-\d+$/, $cgi->param())) { @@ -342,37 +361,13 @@ foreach my $b (@bug_objects) { $b->set_all(\%set_all_fields); } -# Certain changes can only happen on individual bugs, never on mass-changes. if (defined $cgi->param('id')) { # Flags should be set AFTER the bug has been moved into another - # product/component. + # product/component. The structure of flags code doesn't currently + # allow them to be set using set_all. my ($flags, $new_flags) = Bugzilla::Flag->extract_flags_from_cgi( $first_bug, undef, $vars); $first_bug->set_flags($flags, $new_flags); - - # Since aliases are unique (like bug numbers), they can only be changed - # for one bug at a time. - if (Bugzilla->params->{"usebugaliases"} && defined $cgi->param('alias')) { - $first_bug->set_alias($cgi->param('alias')); - } - - # reporter_accessible and cclist_accessible--these are only set if - # the user can change them and they appear on the page. - if (should_set('cclist_accessible', 1)) { - $first_bug->set_cclist_accessible($cgi->param('cclist_accessible')) - } - if (should_set('reporter_accessible', 1)) { - $first_bug->set_reporter_accessible($cgi->param('reporter_accessible')) - } - - # You can only mark/unmark comments as private on single bugs. If - # you're not in the insider group, this code won't do anything. - foreach my $field (grep(/^defined_isprivate/, $cgi->param())) { - $field =~ /(\d+)$/; - my $comment_id = $1; - $first_bug->set_comment_is_private($comment_id, - $cgi->param("isprivate_$comment_id")); - } } # We need to check the addresses involved in a CC change before we touch |