From 02a6e7b1ed68f7cd8f8ad29f0ce7a2969f166cb6 Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Fri, 26 Apr 2019 10:59:17 -0400 Subject: [PATCH] Bug 20256: (QA follow-up) Redirect to record details page if user cannot edit this item --- cataloguing/additem.pl | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 5f2948f2ac..30741e7496 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -413,6 +413,13 @@ my ($template, $loggedinuser, $cookie) # Does the user have a restricted item editing permission? my $patron = Koha::Patrons->find( $loggedinuser ); + +my $item = $itemnumber ? Koha::Items->find( $itemnumber ) : undef; +if ( $item && !$patron->can_edit_item( $item ) ) { + print $input->redirect("/cgi-bin/koha/catalogue/detail.pl?biblionumber=$biblionumber"); + exit; +} + my $uid = $patron->userid; my $restrictededition = $uid ? haspermission($uid, {'editcatalogue' => 'edit_items_restricted'}) : undef; # In case user is a superlibrarian, editing is not restricted @@ -707,7 +714,6 @@ if ($op eq "additem") { if ($exist_itemnumber && $exist_itemnumber != $itemnumber) { push @errors,"barcode_not_unique"; } else { - my $item = Koha::Items->find($itemnumber ); my $newitem = ModItemFromMarc($itemtosave, $biblionumber, $itemnumber); $itemnumber = q{}; my $olditemlost = $item->itemlost; @@ -817,10 +823,10 @@ foreach my $field (@fields) { if ( C4::Context->preference('EasyAnalyticalRecords') ) { foreach my $hostitemnumber (@hostitemnumbers) { - my $item = Koha::Items->find( $hostitemnumber ); + my $hostitem = Koha::Items->find( $hostitemnumber ); if ($this_row{itemnumber} eq $hostitemnumber) { $this_row{hostitemflag} = 1; - $this_row{hostbiblionumber}= $item->biblio->biblionumber; + $this_row{hostbiblionumber}= $hostitem->biblio->biblionumber; last; } } @@ -920,8 +926,6 @@ foreach my $tag ( keys %{$tagslib}){ } @loop_data = sort {$a->{subfield} cmp $b->{subfield} } @loop_data; -my $item = Koha::Items->find($itemnumber); # We certainly want to fetch it earlier - # what's the next op ? it's what we are not in : an add if we're editing, otherwise, and edit. $template->param( biblionumber => $biblionumber, -- 2.20.1 (Apple Git-117)