From fb4fcbc752a20a67ea6a14ce41af4c9238e9dde3 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Sun, 3 Nov 2024 17:44:43 +0000 Subject: [PATCH] Bug 32773: Add editing support for is_fast_add frameworks This patch uses the biblionumber to set is_fast_add on the catalog details page which is used to determine if the Edit button should be rendered in the cataloging toolbar. It updates the Biblio.pm subroutine can_be_edited to check if the biblio frameworkcode is 'FA' or if the biblio framework is_fast_add = 1. To test: 1. Set some biblio frameworks as Fast Add frameworks 2. Login as a user with fast_cataloging permissions only 3. Create and edit different types of Fast Add records 4. Add items and edit items 5. Confirm that you can only edit bibs and items for bibs where the framework is set as a Fast Add framework and the item is from your home library. 6. Log in as a superlibrarian 7. Confirm you can still create and edit records with the Default and other frameworks 8. Change a record's framework from a Fast Add to Default 9. Login as the user with only fast_cataloging confirm that you can no longer edit that record or its items Signed-off-by: Andrew Fuerste Henry --- Koha/Biblio.pm | 8 +++++++- catalogue/detail.pl | 7 +++++++ catalogue/moredetail.pl | 3 +++ .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 10 +++++----- .../prog/en/modules/catalogue/moredetail.tt | 2 +- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 927d7b898e..e94e9d4d23 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -42,6 +42,7 @@ use Koha::Biblio::Metadatas; use Koha::Biblio::Metadata::Extractor; use Koha::Biblio::ItemGroups; use Koha::Biblioitems; +use Koha::BiblioFrameworks; use Koha::Cache::Memory::Lite; use Koha::Bookings; use Koha::Checkouts; @@ -329,8 +330,13 @@ sub can_be_edited { Koha::Exceptions::MissingParameter->throw( error => "The patron parameter is missing or invalid" ) unless $patron && ref($patron) eq 'Koha::Patron'; + my $is_fast_add = + defined $self->frameworkcode && $self->frameworkcode ne '' + ? Koha::BiblioFrameworks->find( $self->frameworkcode )->is_fast_add + : 0; + my $editcatalogue = - $self->frameworkcode eq 'FA' + $self->frameworkcode eq 'FA' || $is_fast_add ? [ 'fast_cataloging', 'edit_catalogue' ] : 'edit_catalogue'; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 7af8010343..13b33818b5 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -48,6 +48,7 @@ use Koha::AuthorisedValues; use Koha::Biblios; use Koha::Biblio::ItemGroup::Items; use Koha::Biblio::ItemGroups; +use Koha::BiblioFrameworks; use Koha::CoverImages; use Koha::DateUtils; use Koha::ILL::Requests; @@ -90,10 +91,16 @@ my $activetab = $query->param('activetab'); my $biblionumber = $query->param('biblionumber'); $biblionumber = HTML::Entities::encode($biblionumber); my $biblio = Koha::Biblios->find( $biblionumber ); +my $frameworkcode = &GetFrameworkCode($biblionumber); +my $is_fast_add = + defined $frameworkcode && $frameworkcode ne '' + ? Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add + : 0; $template->param( biblio => $biblio, activetab => $activetab, + is_fast_add => $is_fast_add, ); unless ( $biblio ) { diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 10a1d4fe0f..f8d67b71ed 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -33,6 +33,7 @@ use C4::Search qw( enabled_staff_search_views z3950_search_args ); use Koha::Acquisition::Booksellers; use Koha::AuthorisedValues; use Koha::Biblios; +use Koha::BiblioFrameworks; use Koha::Items; use Koha::Patrons; @@ -108,6 +109,7 @@ output_and_exit( $query, $cookie, $template, 'unknown_biblio') unless $biblio && $record; my $fw = GetFrameworkCode($biblionumber); +my $is_fast_add = Koha::BiblioFrameworks->find($fw)->is_fast_add; my $all_items = $biblio->items->search_ordered; my @items; @@ -315,6 +317,7 @@ $template->param( itemnumber => $itemnumber, z3950_search_params => C4::Search::z3950_search_args(GetBiblioData($biblionumber)), biblio => $biblio, + is_fast_add => $is_fast_add, ); $template->param(ONLY_ONE => 1) if ( $itemnumber && $showncount != @items ); $template->{'VARS'}->{'searchid'} = $query->param('searchid'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc index d847c33899..0831654282 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -35,11 +35,11 @@ [% END %] -[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %] +[% IF ( CAN_user_editcatalogue_edit_catalogue || CAN_user_editcatalogue_edit_items || CAN_user_tools_items_batchmod || CAN_user_tools_items_batchdel ) or ( frameworkcode == 'FA' || is_fast_add and CAN_user_editcatalogue_fast_cataloging ) %]