From 7a9a4fdc72fa194e1921ee157ae7f79507540f1c Mon Sep 17 00:00:00 2001 From: Robert Webb Date: Thu, 1 Sep 2011 13:24:27 -0700 Subject: Bug 683025 - Add a check_for_edit to Bugzilla::Bug to return the bug object if the user can edit the bug r=mkanat, a=mkanat --- Bugzilla/Bug.pm | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'Bugzilla/Bug.pm') diff --git a/Bugzilla/Bug.pm b/Bugzilla/Bug.pm index 7745a9809..23e07979f 100644 --- a/Bugzilla/Bug.pm +++ b/Bugzilla/Bug.pm @@ -403,6 +403,16 @@ sub check { return $self; } +sub check_for_edit { + my $class = shift; + my $bug = $class->check(@_); + + Bugzilla->user->can_edit_product($bug->product_id) + || ThrowUserError("product_edit_denied", { product => $bug->product }); + + return $bug; +} + sub check_is_visible { my $self = shift; my $user = Bugzilla->user; -- cgit v1.2.3-24-g4f1b