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 <andrew@bywatersolutions.com>
Signed-off-by: Miranda Nero <mnero@oslri.net>
Signed-off-by: Andrew Fuerste Henry <andrew@bywatersolutions.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Brendan Lawlor 2024-11-01 15:17:52 +00:00 committed by Lucas Gass
parent 4007bb3490
commit 5233d589d5
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
9 changed files with 51 additions and 27 deletions

View File

@ -43,6 +43,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;
@ -330,8 +331,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';

View File

@ -46,6 +46,7 @@ use Koha::AuthorisedValues;
use Koha::Biblios;
use Koha::Biblio::ItemGroup::Items;
use Koha::Biblio::ItemGroups;
use Koha::BiblioFrameworks;
use Koha::Controller::Catalogue;
use Koha::CoverImages;
use Koha::DateUtils;
@ -89,11 +90,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) {

View File

@ -31,6 +31,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::Controller::Catalogue;
use Koha::Items;
use Koha::Patrons;
@ -90,7 +91,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;
@ -319,6 +324,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');

View File

@ -515,8 +515,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';
@ -563,7 +568,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(
@ -727,7 +732,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

View File

@ -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(

View File

@ -33,11 +33,11 @@
</div>
[% 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 ) %]
<div class="btn-group">
<button class="btn btn-default dropdown-toggle" data-bs-toggle="dropdown" aria-expanded="false"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</button>
<ul class="dropdown-menu">
[% IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
[% IF CAN_user_editcatalogue_edit_catalogue || ( CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]
[% IF biblio.can_be_edited(logged_in_user) %]
<li><a class="dropdown-item" id="editbiblio" href="/cgi-bin/koha/cataloguing/addbiblio.pl?biblionumber=[% biblionumber | html %]">Edit record</a></li>
[% ELSE %]
@ -57,7 +57,7 @@
</li>
[% END %]
[% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
[% IF CAN_user_editcatalogue_edit_items || ( CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]
<li><a class="dropdown-item" id="manageitems" href="/cgi-bin/koha/cataloguing/additem.pl?biblionumber=[% biblionumber | html %]">Manage items</a></li>
[% END %]
@ -126,7 +126,7 @@
<li><a class="dropdown-item" href="#" id="z3950copy">Replace record via Z39.50/SRU</a></li>
[% END %]
[% IF CAN_user_editcatalogue_edit_catalogue or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
[% IF CAN_user_editcatalogue_edit_catalogue || ( CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]
[% IF ( count ) %]
<li
data-bs-toggle="tooltip"
@ -157,7 +157,7 @@
[% END %]
[% END %]
[% IF CAN_user_editcatalogue_delete_all_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
[% IF CAN_user_editcatalogue_delete_all_items || ( CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]
[% IF ( count ) %]
<li>
<form action="/cgi-bin/koha/cataloguing/additem.pl" method="post">

View File

@ -43,7 +43,7 @@
[% IF ( analyze ) %]<th id="[% tab | html %]_usedin" data-colname="usedin">Used in</th><th></th>[% END %]
[% IF Koha.Preference('UseCourseReserves') %]<th id="[% tab | html %]_course_reserves" data-colname="course_reserves">Course reserves</th>[% END %]
<th id="[% tab | html %]_spinelabel" data-colname="spinelabel" class="no-sort">Spine label</th>
[% IF ( CAN_user_editcatalogue_edit_items ) %]<th id="[% tab | html %]_actions" data-colname="actions" class="no-sort no-export">&nbsp;</th>[% END %]
[% IF ( CAN_user_editcatalogue_edit_items || CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]<th id="[% tab | html %]_actions" data-colname="actions" class="no-sort no-export">&nbsp;</th>[% END %]
</tr>
</thead>
</table>
@ -148,7 +148,7 @@
canreservefromotherbranches: [% Koha.Preference('canreservefromotherbranches') ? 1 : 0 | html %],
});
Koha.addPermissions({
CAN_user_editcatalogue_edit_items: [% CAN_user_editcatalogue_edit_items ? 1 : 0 | html %],
CAN_user_editcatalogue_edit_items: [% (CAN_user_editcatalogue_edit_items || CAN_user_editcatalogue_fast_cataloging && is_fast_add) ? 1 : 0 | html %],
});
const logged_in_branchcode = '[% Branches.GetLoggedInBranchcode() | html %]';

View File

@ -166,7 +166,7 @@
<h4>
Item information
[% UNLESS ( ITEM_DAT.nomod ) %]
[% IF ( CAN_user_editcatalogue_edit_items ) %]
[% IF ( CAN_user_editcatalogue_edit_items || CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]
<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% ITEM_DAT.biblionumber | uri %]&amp;itemnumber=[% ITEM_DAT.itemnumber | uri %]"
><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit item</a
>

View File

@ -909,7 +909,7 @@
[% END %]
<div id="toolbar" class="btn-toolbar sticky">
[% IF CAN_user_editcatalogue_edit_items or ( frameworkcode == 'FA' and CAN_user_editcatalogue_fast_cataloging ) %]
[% IF CAN_user_editcatalogue_edit_items || ( CAN_user_editcatalogue_fast_cataloging && is_fast_add ) %]
[% IF (circborrowernumber) %][%# fast cataloging must lead to items %]
<!-- Action is under fast cataloging - Save button redirecting to items -->
<div class="btn-group"><a href="#" id="saveanditems" class="btn btn-primary"><i class="fa fa-save"></i> Save</a></div>
@ -964,7 +964,7 @@
[% ELSE %]
<i class="fa fa-fw">&nbsp;</i>
[% END %]
[% !framework ? 'Default' : framework.frameworktext | html %]
[% ( !framework ? 'Default' : framework.frameworktext ) | html %]
</a>
</li>
[% END %]
@ -976,7 +976,7 @@
[% END %]
[% END %]
[% IF CAN_user_editcatalogue_fast_cataloging %]
<li><h6 class="dropdown-header">Change Fast Add framework</h6></li>
<li><h6 class="dropdown-header">Change Fast add framework</h6></li>
[% FOREACH framework IN frameworks %]
[% IF framework.is_fast_add %][% INCLUDE framework_link %][% END %]
[% END %]