From 1327ff9a6a65b31d9cad315a968b6d3bdab54b89 Mon Sep 17 00:00:00 2001 From: Frédéric Buclin Date: Fri, 21 Mar 2014 11:58:45 +0100 Subject: Bug 294021: Allow requestees to set attachment flags even if they don't have editbugs privs r=gerv a=justdave --- Bugzilla/Attachment.pm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Bugzilla/Attachment.pm') diff --git a/Bugzilla/Attachment.pm b/Bugzilla/Attachment.pm index c90d8ea8e..8aa2c3c63 100644 --- a/Bugzilla/Attachment.pm +++ b/Bugzilla/Attachment.pm @@ -700,28 +700,27 @@ sub get_attachments_by_bug { =pod -=item C +=item C Description: validates if the user is allowed to view and edit the attachment. Only the submitter or someone with editbugs privs can edit it. Only the submitter and users in the insider group can view private attachments. -Params: $attachment - the attachment object being edited. - $product_id - the product ID the attachment belongs to. +Params: none Returns: 1 on success, 0 otherwise. =cut sub validate_can_edit { - my ($attachment, $product_id) = @_; + my $attachment = shift; my $user = Bugzilla->user; # The submitter can edit their attachments. return ($attachment->attacher->id == $user->id || ((!$attachment->isprivate || $user->is_insider) - && $user->in_group('editbugs', $product_id))) ? 1 : 0; + && $user->in_group('editbugs', $attachment->bug->product_id))) ? 1 : 0; } =item C @@ -758,7 +757,7 @@ sub validate_obsolete { || ThrowUserError('invalid_attach_id', $vars); # Check that the user can view and edit this attachment. - $attachment->validate_can_edit($bug->product_id) + $attachment->validate_can_edit || ThrowUserError('illegal_attachment_edit', { attach_id => $attachment->id }); if ($attachment->bug_id != $bug->bug_id) { -- cgit v1.2.3-24-g4f1b