my $timestamp = $dbh->selectrow_array('SELECT LOCALTIMESTAMP(0)');
my $flags = delete $params->{flags};
+ my $comment = delete $params->{comment};
+ my $bug_flags = delete $params->{bug_flags};
+
+ $comment = $comment ? trim($comment) : '';
foreach my $bug (@bugs) {
my $attachment = Bugzilla::Attachment->create({
}
$attachment->update($timestamp);
- my $comment = $params->{comment} || '';
- $attachment->bug->add_comment($comment,
+
+ # The comment has to be added even if it's empty
+ $bug->add_comment($comment,
{ isprivate => $attachment->isprivate,
type => CMT_ATTACHMENT_CREATED,
extra_data => $attachment->id });
+
+ if ($bug_flags) {
+ my ($old_flags, $new_flags) = extract_flags($bug_flags, $bug);
+ $bug->set_flags($old_flags, $new_flags);
+ }
+
push(@created, $attachment);
}
$_->bug->update($timestamp) foreach @created;
my $flags = delete $params->{flags};
my $comment = delete $params->{comment};
+ my $bug_flags = delete $params->{bug_flags};
+
+ $comment = $comment ? trim($comment) : '';
# Update the values
foreach my $attachment (@attachments) {
my @result;
foreach my $attachment (@attachments) {
my $changes = $attachment->update();
+ my $bug = $attachment->bug;
- if ($comment = trim($comment)) {
- $attachment->bug->add_comment($comment,
+ if ($comment) {
+ $bug->add_comment($comment,
{ isprivate => $attachment->isprivate,
type => CMT_ATTACHMENT_UPDATED,
extra_data => $attachment->id });
}
+ if ($bug_flags) {
+ my ($old_flags, $new_flags) = extract_flags($bug_flags, $bug);
+ $bug->set_flags($old_flags, $new_flags);
+ }
+
$changes = translate($changes, ATTACHMENT_MAPPED_RETURNS);
my %hash = (
=back
+=item C<bug_flags>
+
+C<array> An optional array of hashes with flags to add to the attachment's
+bug. See the C<flags> param for the L</update> method for the object format.
+
=back
=item B<Returns>
=back
+=item C<bug_flags>
+
+C<array> An optional array of hashes with changes to the flags of the attachment's
+bug. See the C<flags> param for the L</update> method for the object format.
+
=item B<Returns>
A C<hash> with a single field, "attachment". This points to an array of hashes
not specified.
flags array Flags objects to add to the attachment. The object
format is described in the Flag object below.
+bug_flags array Flag objects to add to the attachment's bug. See the
+ ``flags`` param for :ref:`rest_create_bug` for the
+ object format.
================ ======= ======================================================
Flag object:
otherwise.
flags array An array of Flag objects with changes to the flags. The
object format is described in the Flag object below.
+bug_flags array An optional array of Flag objects with changes to the
+ flags of the attachment's bug. See the ``flags`` param
+ for :ref:`rest_update_bug` for the object format.
============ ======= ==========================================================
Flag object: