Commit 672397b3 authored by Byron Jones's avatar Byron Jones

Bug 301656: Adds a preference to CC flag requestees to bugs

r=LpSolit, a=LpSolit
parent f825a4de
...@@ -282,7 +282,7 @@ sub count { ...@@ -282,7 +282,7 @@ sub count {
sub set_flag { sub set_flag {
my ($class, $obj, $params) = @_; my ($class, $obj, $params) = @_;
my ($bug, $attachment); my ($bug, $attachment, $obj_flag, $requestee_changed);
if (blessed($obj) && $obj->isa('Bugzilla::Attachment')) { if (blessed($obj) && $obj->isa('Bugzilla::Attachment')) {
$attachment = $obj; $attachment = $obj;
$bug = $attachment->bug; $bug = $attachment->bug;
...@@ -320,12 +320,13 @@ sub set_flag { ...@@ -320,12 +320,13 @@ sub set_flag {
($obj_flagtype) = grep { $_->id == $flag->type_id } @{$obj->flag_types}; ($obj_flagtype) = grep { $_->id == $flag->type_id } @{$obj->flag_types};
push(@{$obj_flagtype->{flags}}, $flag); push(@{$obj_flagtype->{flags}}, $flag);
} }
my ($obj_flag) = grep { $_->id == $flag->id } @{$obj_flagtype->{flags}}; ($obj_flag) = grep { $_->id == $flag->id } @{$obj_flagtype->{flags}};
# If the flag has the correct type but cannot be found above, this means # If the flag has the correct type but cannot be found above, this means
# the flag is going to be removed (e.g. because this is a pending request # the flag is going to be removed (e.g. because this is a pending request
# and the attachment is being marked as obsolete). # and the attachment is being marked as obsolete).
return unless $obj_flag; return unless $obj_flag;
($obj_flag, $requestee_changed) =
$class->_validate($obj_flag, $obj_flagtype, $params, $bug, $attachment); $class->_validate($obj_flag, $obj_flagtype, $params, $bug, $attachment);
} }
# Create a new flag. # Create a new flag.
...@@ -358,12 +359,21 @@ sub set_flag { ...@@ -358,12 +359,21 @@ sub set_flag {
} }
} }
($obj_flag, $requestee_changed) =
$class->_validate(undef, $obj_flagtype, $params, $bug, $attachment); $class->_validate(undef, $obj_flagtype, $params, $bug, $attachment);
} }
else { else {
ThrowCodeError('param_required', { function => $class . '->set_flag', ThrowCodeError('param_required', { function => $class . '->set_flag',
param => 'id/type_id' }); param => 'id/type_id' });
} }
if ($obj_flag
&& $requestee_changed
&& $obj_flag->requestee_id
&& $obj_flag->requestee->setting('requestee_cc') eq 'on')
{
$bug->add_cc($obj_flag->requestee);
}
} }
sub _validate { sub _validate {
...@@ -383,23 +393,25 @@ sub _validate { ...@@ -383,23 +393,25 @@ sub _validate {
$obj_flag->_set_status($params->{status}); $obj_flag->_set_status($params->{status});
$obj_flag->_set_requestee($params->{requestee}, $attachment, $params->{skip_roe}); $obj_flag->_set_requestee($params->{requestee}, $attachment, $params->{skip_roe});
# The requestee ID can be undefined.
my $requestee_changed = ($obj_flag->requestee_id || 0) != ($old_requestee_id || 0);
# The setter field MUST NOT be updated if neither the status # The setter field MUST NOT be updated if neither the status
# nor the requestee fields changed. # nor the requestee fields changed.
if (($obj_flag->status ne $old_status) if (($obj_flag->status ne $old_status) || $requestee_changed) {
# The requestee ID can be undefined.
|| (($obj_flag->requestee_id || 0) != ($old_requestee_id || 0)))
{
$obj_flag->_set_setter($params->{setter}); $obj_flag->_set_setter($params->{setter});
} }
# If the flag is deleted, remove it from the list. # If the flag is deleted, remove it from the list.
if ($obj_flag->status eq 'X') { if ($obj_flag->status eq 'X') {
@{$flag_type->{flags}} = grep { $_->id != $obj_flag->id } @{$flag_type->{flags}}; @{$flag_type->{flags}} = grep { $_->id != $obj_flag->id } @{$flag_type->{flags}};
return;
} }
# Add the newly created flag to the list. # Add the newly created flag to the list.
elsif (!$obj_flag->id) { elsif (!$obj_flag->id) {
push(@{$flag_type->{flags}}, $obj_flag); push(@{$flag_type->{flags}}, $obj_flag);
} }
return wantarray ? ($obj_flag, $requestee_changed) : $obj_flag;
} }
=pod =pod
......
...@@ -93,6 +93,8 @@ sub SETTINGS { ...@@ -93,6 +93,8 @@ sub SETTINGS {
# 2011-06-21 glob@mozilla.com -- Bug 589128 # 2011-06-21 glob@mozilla.com -- Bug 589128
email_format => { options => ['html', 'text_only'], email_format => { options => ['html', 'text_only'],
default => 'html' }, default => 'html' },
# 2011-10-11 glob@mozilla.com -- Bug 301656
requestee_cc => { options => ['on', 'off'], default => 'on' },
} }
}; };
......
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
"email_format" => "Preferred email format", "email_format" => "Preferred email format",
"html" => "HTML", "html" => "HTML",
"text_only" => "Text Only", "text_only" => "Text Only",
"requestee_cc" => "Automatically add me to the CC list of $terms.bugs I am requested to review",
} }
%] %]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment