From b53c63f5a105a124ae24ebefd460f17364da5871 Mon Sep 17 00:00:00 2001 From: Brendan Lawlor Date: Fri, 1 Nov 2024 15:17:52 +0000 Subject: [PATCH] Bug 32773: Add fast cataloging support for multiple frameworks This set of patches adds a new is_fast_add column to biblio_framework. The Biblio.pm subroutine can_be_edited now checks if the framework is_fast_add. In Admin > MARC bibliographic frameworks admin users can add or edit frameworks to be used as Fast add frameworks. Users with only fast_cataloging permission will be able to add records using those frameworks in the Fast Cataloging module. Test plan: Apply patches, restart_all and updatedatabase 1. Go to Admin > MARC Bibliographic frameworks 2. Edit/create a new framework and check the 'Use as Fast add Framework' box 3. Also edit a framework and uncheck the 'Use as Fast add Framework' box 4. Notice a 'Fast add' badge is displayed in the table 5. Create a staff user with only fast_cataloging permissions 6. Log in as that user and go to Cataloging > Fast Cataloging 7. Confirm you can add a Fast add record and items 8. Use the 'Settings' drop down to Change Fast add framework 9. Confirm you see the frameworks that you set as Fast add earlier 10. Confirm you can add the record and items 11. Log in as a superlibrarian and confirm that you can add records and items using standard frameworks and frameworks set as fast add 12. Set some biblio frameworks as Fast Add frameworks 13. Login as a user with fast_cataloging permissions only 14. Create and edit different types of Fast Add records 15. Add items and edit items 16. 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. 17. Log in as a superlibrarian 18. Confirm you can still create and edit records with the Default and other frameworks 19. Change a record's framework from a Fast add to Default 20. Login as the user with only fast_cataloging confirm that you can no longer edit that record or its items Sponsored-by: CLAMS Signed-off-by: Andrew Fuerste Henry --- Koha/Biblio.pm | 8 +++++++- catalogue/detail.pl | 13 ++++++++++--- catalogue/moredetail.pl | 8 +++++++- cataloguing/addbiblio.pl | 11 ++++++++--- cataloguing/additem.pl | 16 ++++++++-------- .../prog/en/includes/cat-toolbar.inc | 10 +++++----- .../tables/items/catalogue_detail.inc | 4 ++-- .../prog/en/modules/catalogue/moredetail.tt | 2 +- .../prog/en/modules/cataloguing/addbiblio.tt | 6 +++--- 9 files changed, 51 insertions(+), 27 deletions(-) diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 67ea254c63..f935e5b261 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' + $is_fast_add ? [ 'fast_cataloging', 'edit_catalogue' ] : 'edit_catalogue'; diff --git a/catalogue/detail.pl b/catalogue/detail.pl index 05a2d14140..3139ddfa18 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::Database::DataInconsistency; @@ -91,11 +92,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 = $biblio->frameworkcode; +my $is_fast_add = + $frameworkcode eq '' + ? 0 + : Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add; $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 cdd6c09be0..38ae2d0582 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,7 +107,11 @@ my $record = $biblio ? $biblio->metadata->record : undef; output_and_exit( $query, $cookie, $template, 'unknown_biblio' ) unless $biblio && $record; -my $fw = GetFrameworkCode($biblionumber); +my $fw = $biblio->frameworkcode; +my $is_fast_add = + $fw eq '' + ? 0 + : Koha::BiblioFrameworks->find($fw)->is_fast_add; my $all_items = $biblio->items->search_ordered; my @items; @@ -335,6 +340,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/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index a8e2720b5c..8b795bf438 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -510,8 +510,13 @@ $frameworkcode = &GetFrameworkCode($biblionumber) if ( $biblionumber and not( defined $frameworkcode ) and $op ne 'cud-addbiblio' ); $frameworkcode //= ''; +my $fast_cataloging_mode = + $frameworkcode eq '' + ? 0 + : Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add; + my $userflags = - $frameworkcode eq 'FA' + $fast_cataloging_mode ? [ 'fast_cataloging', 'edit_catalogue' ] : 'edit_catalogue'; @@ -558,7 +563,7 @@ if ($biblionumber) { } } -if ( $frameworkcode eq 'FA' ) { +if ($fast_cataloging_mode) { # We need to grab and set some variables in the template for use on the additems screen $template->param( @@ -722,7 +727,7 @@ if ( $op eq "cud-addbiblio" ) { if ( $redirect eq "items" || ( $mode ne "popup" && !$is_a_modif && $redirect ne "view" && $redirect ne "just_save" ) ) { - if ( $frameworkcode eq 'FA' ) { + if ($fast_cataloging_mode) { print $input->redirect( '/cgi-bin/koha/cataloguing/additem.pl?' . 'biblionumber=' . $biblionumber diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 5c3e200512..07d9971bbd 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -142,13 +142,13 @@ my $item_group = $input->param('item_group'); my $item_group_description = $input->param('item_group_description'); my $display_order = $input->param('item_group_display_order'); -our $frameworkcode = &GetFrameworkCode($biblionumber); +our $frameworkcode = $biblio->frameworkcode; # Defining which userflag is needing according to the framework currently used my $fast_cataloging_mode = - defined $input->param('frameworkcode') - ? $input->param('frameworkcode') eq 'FA' - : $frameworkcode eq 'FA'; + $frameworkcode eq '' + ? 0 + : Koha::BiblioFrameworks->find($frameworkcode)->is_fast_add; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { @@ -186,7 +186,7 @@ $restrictededition = 0 if ( $restrictededition != 0 && C4::Context->IsSuperLibra # In case user has fast cataloging permission (and we're in fast cataloging), editing is not restricted $restrictededition = 0 if ( $restrictededition != 0 - && $frameworkcode eq 'FA' + && $fast_cataloging_mode && haspermission( $uid, { 'editcatalogue' => 'fast_cataloging' } ) ); our $tagslib = &GetMarcStructure( 1, $frameworkcode ); @@ -486,7 +486,7 @@ if ( $op eq "cud-additem" ) { undef($current_item); } } - if ( $frameworkcode eq 'FA' && $fa_circborrowernumber ) { + if ( $fast_cataloging_mode && $fa_circborrowernumber ) { print $input->redirect( '/cgi-bin/koha/circ/circulation.pl?' . 'borrowernumber=' . $fa_circborrowernumber @@ -796,7 +796,7 @@ my $subfields = } ); -if ( $frameworkcode eq 'FA' ) { +if ($fast_cataloging_mode) { my ($barcode_field) = grep { $_->{kohafield} eq 'items.barcode' } @$subfields; $barcode_field->{marc_value}->{value} ||= $input->param('barcode'); } @@ -826,7 +826,7 @@ $template->param( ); $template->{'VARS'}->{'searchid'} = $searchid; -if ( $frameworkcode eq 'FA' ) { +if ($fast_cataloging_mode) { # fast cataloguing datas $template->param( 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 daf247f812..b18c252081 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/cat-toolbar.inc @@ -33,11 +33,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 ) || ( CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]