From 6e2329ce244dd5f65aa7bfa6856b6120a595acda Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Tue, 20 May 2014 09:37:26 -0400 Subject: [PATCH] Bug 10276 [QA Followup 4] - Fix edit links on catalogue/detail.pl Bug 11746 has been pushed to master, which is good. However, this means that the links displayed in the catalogue/details.pl page are displaying Edit on items which the user should not have edit links for. --- Koha/Template/Plugin/Branches.pm | 9 +++++++++ catalogue/detail.pl | 3 ++- .../prog/en/modules/catalogue/detail.tt | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/Koha/Template/Plugin/Branches.pm b/Koha/Template/Plugin/Branches.pm index 880b2c4..8718999 100644 --- a/Koha/Template/Plugin/Branches.pm +++ b/Koha/Template/Plugin/Branches.pm @@ -22,9 +22,11 @@ use Modern::Perl; use Template::Plugin; use base qw( Template::Plugin ); +use Encode qw( encode decode ); use C4::Koha; use C4::Context; +use C4::Branch qw( GetIndependentGroupModificationRights ); sub GetName { my ( $self, $branchcode ) = @_; @@ -83,4 +85,11 @@ sub all { return $branches; } +sub HasRights { + my( $self, $for ) = @_; + + my $has_rights = GetIndependentGroupModificationRights({ for => $for }); + return $has_rights; +} + 1; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index b7ba9a4..b1dbc73 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -199,7 +199,8 @@ if ($currentbranch and C4::Context->preference('SeparateHoldings')) { my $separatebranch = C4::Context->preference('SeparateHoldingsBranch') || 'homebranch'; foreach my $item (@items) { my $itembranchcode = $item->{$separatebranch}; - $item->{homebranch} = GetBranchName($item->{homebranch}); + $item->{homebranchcode} = $item->{homebranch}; + $item->{homebranch} = GetBranchName( $item->{homebranch} ); # can place holds defaults to yes $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 41730f5..71a10a5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -1,4 +1,5 @@ [% USE Koha %] +[% USE Branches %] [% USE KohaDates %] [% USE AuthorisedValues %] @@ -807,7 +808,11 @@ function verify_images() { [% END %] [% IF ( CAN_user_editcatalogue_edit_items ) %] - Edit + [% IF !Koha.Preference('IndependentBranches') || Branches.HasRights( item.homebranchcode ) %] + Edit + [% ELSE %] +   + [% END %] [% END %] [% END %] -- 1.7.2.5