@@ -, +, @@ --- Koha/Item.pm | 4 +--- Koha/UI/Table/Builder/Items.pm | 3 +++ catalogue/detail.pl | 8 +------- catalogue/moredetail.pl | 3 +++ cataloguing/additem.pl | 5 ++++- koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc | 2 +- .../intranet-tmpl/prog/en/modules/catalogue/detail.tt | 4 +++- tools/batchMod.pl | 5 +++-- 8 files changed, 19 insertions(+), 15 deletions(-) --- a/Koha/Item.pm +++ a/Koha/Item.pm @@ -281,9 +281,7 @@ sub safe_to_delete { $error = "not_same_branch" if defined C4::Context->userenv - and !C4::Context->IsSuperLibrarian() - and C4::Context->preference("IndependentBranches") - and ( C4::Context->userenv->{branch} ne $self->homebranch ); + and !Koha::Patrons->find( C4::Context->userenv->{number} )->can_edit_item( $self ) ) # check it doesn't have a waiting reserve $error = "book_reserved" --- a/Koha/UI/Table/Builder/Items.pm +++ a/Koha/UI/Table/Builder/Items.pm @@ -72,6 +72,8 @@ Use it with: sub build_table { my ( $self, $params ) = @_; + my $patron = $self->params; + my $items = Koha::Items->search( { itemnumber => $self->{itemnumbers} } ); my @items; @@ -84,6 +86,7 @@ sub build_table { holds => $item->biblio->holds->count, item_holds => $item->holds->count, is_checked_out => $item->checkout || 0, + nomod => $patron ? 0 : $patron->can_edit_item($item), }; push @items, $item_info; } --- a/catalogue/detail.pl +++ a/catalogue/detail.pl @@ -389,13 +389,7 @@ foreach my $item (@items) { $item->{'course_reserves'} = GetItemCourseReservesInfo( itemnumber => $item->{'itemnumber'} ); } - if ( C4::Context->preference('IndependentBranches') ) { - my $userenv = C4::Context->userenv(); - if ( not C4::Context->IsSuperLibrarian() - and $userenv->{branch} ne $item->{homebranch} ) { - $item->{cannot_be_edited} = 1; - } - } + $item->{cannot_be_edited} = !$patron->can_edit_item( $item_object ); if ( C4::Context->preference("LocalCoverImages") == 1 ) { $item->{cover_images} = $item_object->cover_images; --- a/catalogue/moredetail.pl +++ a/catalogue/moredetail.pl @@ -232,6 +232,9 @@ foreach my $item (@items){ $item->{'nomod'}=1; } } + + $item->{nomod} = !$patron->can_edit_item( $item ); + if ($item->{'datedue'}) { $item->{'issue'}= 1; } else { --- a/cataloguing/additem.pl +++ a/cataloguing/additem.pl @@ -124,7 +124,8 @@ my ($template, $loggedinuser, $cookie) # Does the user have a restricted item editing permission? -my $uid = Koha::Patrons->find( $loggedinuser )->userid; +my $patron = Koha::Patrons->find( $loggedinuser ); +my $uid = $patron->userid; my $restrictededition = $uid ? haspermission($uid, {'editcatalogue' => 'edit_items_restricted'}) : undef; # In case user is a superlibrarian, editing is not restricted $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian()); @@ -506,6 +507,8 @@ if ($op) { my @items; for my $item ( $biblio->items->as_list, $biblio->host_items->as_list ) { + my $i = $item->columns_to_str; + $item->{nomod} = 1 unless $patron->can_edit_item($item); push @items, $item->columns_to_str; } --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -246,7 +246,7 @@ [% FOREACH item IN items %] - [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %] + [% SET can_be_edited = !item.nomod && !( Koha.Preference('IndependentBranches') && ! logged_in_user && item.homebranch != Branches.GetLoggedInBranchname() ) %] [% IF checkboxes_edit %] --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -344,7 +344,9 @@ [% IF (StaffDetailItemSelection) %] - + [% UNLESS item.cannot_be_edited %] + + [% END %] [% END %] [% IF Koha.Preference('LocalCoverImages') && ( tab == 'holdings' && itemloop_has_images || tab == 'otherholdings' && otheritemloop_has_images ) %] --- a/tools/batchMod.pl +++ a/tools/batchMod.pl @@ -75,7 +75,8 @@ my ($template, $loggedinuser, $cookie) $template->param( searchid => scalar $input->param('searchid'), ); # Does the user have a restricted item edition permission? -my $uid = $loggedinuser ? Koha::Patrons->find( $loggedinuser )->userid : undef; +my $patron = Koha::Patrons->find( $loggedinuser ); +my $uid = $loggedinuser ? $patron->userid : undef; my $restrictededition = $uid ? haspermission($uid, {'tools' => 'items_batchmod_restricted'}) : undef; # In case user is a superlibrarian, edition is not restricted $restrictededition = 0 if ($restrictededition != 0 && C4::Context->IsSuperLibrarian()); @@ -296,7 +297,7 @@ if ($op eq "show"){ if ( $display_items ) { my $items_table = Koha::UI::Table::Builder::Items->new( { itemnumbers => \@itemnumbers } ) - ->build_table; + ->build_table( { patron => $patron } );; $template->param( items => $items_table->{items}, item_header_loop => $items_table->{headers}, --