From de0bcf0a8a1b0172c076fa06291a3666e2eb4811 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 | 13 ++++++++++--- catalogue/moredetail.pl | 7 +++++-- .../intranet-tmpl/prog/en/includes/cat-toolbar.inc | 10 +++++----- .../prog/en/modules/catalogue/moredetail.tt | 2 +- 5 files changed, 28 insertions(+), 12 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 878f7cd15a9..e82e9f087c7 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 c6445d4a201..f483caf11b4 100755 --- a/catalogue/detail.pl +++ b/catalogue/detail.pl @@ -47,6 +47,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; @@ -88,11 +89,17 @@ if ( C4::Context->config('enable_plugins') ) { my $activetab = $query->param('activetab'); my $biblionumber = $query->param('biblionumber'); $biblionumber = HTML::Entities::encode($biblionumber); -my $biblio = Koha::Biblios->find($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, + biblio => $biblio, + activetab => $activetab, + is_fast_add => $is_fast_add, ); unless ($biblio) { diff --git a/catalogue/moredetail.pl b/catalogue/moredetail.pl index 78688a925df..3a5975de5c4 100755 --- a/catalogue/moredetail.pl +++ b/catalogue/moredetail.pl @@ -32,6 +32,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; @@ -106,8 +107,9 @@ my $record = $biblio ? $biblio->metadata->record : undef; output_and_exit( $query, $cookie, $template, 'unknown_biblio' ) unless $biblio && $record; -my $fw = GetFrameworkCode($biblionumber); -my $all_items = $biblio->items->search_ordered; +my $fw = GetFrameworkCode($biblionumber); +my $is_fast_add = Koha::BiblioFrameworks->find($fw)->is_fast_add; +my $all_items = $biblio->items->search_ordered; my @items; my $patron = Koha::Patrons->find($loggedinuser); @@ -335,6 +337,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 f760ebc8117..a1067926c16 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -34,11 +34,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 ) %]