From 82160999a36eea229c7a380d7455f7103dfd07be Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Fri, 27 Sep 2024 18:07:17 +0000 Subject: [PATCH] Bug 31391: Update the UseRecalls system preference to have choices Options are: * off * opac * staff * opac_and_staff This patch implements this all over the place. All recalls things should still work including the above test plan. Tests should pass: * t/db_dependent/Circulation.t * t/db_dependent/Circulation/transferbook.t * t/db_dependent/Holds.t * t/db_dependent/Koha/Biblio.t * t/db_dependent/Koha/Item.t * t/db_dependent/SIP/Transaction.t * t/db_dependent/Search.t * t/db_dependent/XSLT.t Sponsored-by: Auckland University of Technology Sponsored-by: Catalyst IT --- C4/Circulation.pm | 12 +++++------ C4/Search.pm | 2 +- C4/XSLT.pm | 2 +- Koha/Biblio.pm | 2 +- Koha/Item.pm | 4 ++-- circ/circulation.pl | 4 ++-- circ/returns.pl | 4 ++-- circ/transferstoreceive.pl | 2 +- ...ug_31391_-_add_RecallsInterface_syspref.pl | 16 --------------- .../bug_31391_-_update_UseRecalls_syspref.pl | 19 ++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 3 +-- .../prog/en/includes/biblio-view-menu.inc | 2 +- .../prog/en/includes/circ-menu.inc | 2 +- .../prog/en/includes/circ-nav.inc | 2 +- .../prog/en/includes/holds_table.inc | 6 +++--- .../tables/items/catalogue_detail.inc | 4 ++-- .../en/includes/messaging-preference-form.inc | 2 +- .../prog/en/includes/patron-detail-tabs.inc | 4 ++-- .../admin/preferences/circulation.pref | 20 +++++++------------ .../prog/en/modules/admin/smart-rules.tt | 8 ++++---- .../prog/en/modules/catalogue/results.tt | 2 +- .../prog/en/modules/circ/circulation-home.tt | 2 +- .../prog/en/modules/members/recallshistory.tt | 2 +- .../en/modules/recalls/recalls_old_queue.tt | 2 +- .../en/modules/recalls/recalls_overdue.tt | 2 +- .../prog/en/modules/recalls/recalls_queue.tt | 2 +- .../en/modules/recalls/recalls_to_pull.tt | 2 +- .../en/modules/recalls/recalls_waiting.tt | 2 +- .../prog/en/modules/recalls/request.tt | 6 +++--- .../bootstrap/en/includes/item-status.inc | 4 ++-- .../en/includes/opac-detail-sidebar.inc | 2 +- .../bootstrap/en/includes/usermenu.inc | 2 +- .../bootstrap/en/modules/opac-messaging.tt | 2 +- .../bootstrap/en/modules/opac-recalls.tt | 2 +- .../bootstrap/en/modules/opac-results.tt | 2 +- .../bootstrap/en/modules/opac-shelves.tt | 2 +- .../bootstrap/en/modules/opac-tags.tt | 2 +- .../bootstrap/en/modules/opac-user.tt | 4 ++-- members/moremember.pl | 4 ++-- opac/opac-recall.pl | 2 +- opac/opac-user.pl | 4 ++-- recalls/request.pl | 7 ++----- svc/checkouts | 2 +- t/db_dependent/Circulation.t | 8 ++++---- t/db_dependent/Circulation/transferbook.t | 2 +- t/db_dependent/Holds.t | 2 +- t/db_dependent/Koha/Biblio.t | 4 ++-- t/db_dependent/Koha/Item.t | 8 ++++---- t/db_dependent/SIP/Transaction.t | 2 +- t/db_dependent/Search.t | 2 +- t/db_dependent/XSLT.t | 4 ++-- 51 files changed, 104 insertions(+), 111 deletions(-) delete mode 100755 installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl create mode 100755 installer/data/mysql/atomicupdate/bug_31391_-_update_UseRecalls_syspref.pl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index bd8ecfc58fa..598c791c064 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -386,7 +386,7 @@ sub transferbook { } # find recall - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { my $recall = Koha::Recalls->find({ item_id => $itemnumber, status => 'in_transit' }); if ( defined $recall ) { # do a transfer if the recall branch is different to the item holding branch @@ -1143,7 +1143,7 @@ sub CanBookBeIssued { # CHECK IF ITEM HAS BEEN RECALLED BY ANOTHER PATRON # Only bother doing this if UseRecalls is enabled and the item is recallable # Don't look at recalls that are in transit - if ( C4::Context->preference('UseRecalls') and $item_object->can_be_waiting_recall ) { + if ( C4::Context->preference('UseRecalls') ne "off" and $item_object->can_be_waiting_recall ) { my @recalls = $biblio->recalls({},{ order_by => { -asc => 'created_date' } })->filter_by_current->as_list; foreach my $r ( @recalls ) { @@ -1648,7 +1648,7 @@ sub AddIssue { $item_object->discard_changes; } - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { Koha::Recalls->move_recall( { action => $cancel_recall, @@ -2426,7 +2426,7 @@ sub AddReturn { } # find recalls... - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { # check if this item is recallable first, which includes checking if UseRecalls syspref is enabled my $recall = undef; $recall = $item->check_recalls if $item->can_be_waiting_recall; @@ -2503,7 +2503,7 @@ sub AddReturn { $request->status('RET') if $request; } - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { # all recalls that have triggered a transfer will have an allocated itemnumber my $transfer_recall = Koha::Recalls->find({ item_id => $item->itemnumber, status => 'in_transit' }); if ( $transfer_recall and $transfer_recall->pickup_library_id eq $branch ) { @@ -3061,7 +3061,7 @@ sub CanBookBeRenewed { } - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { my $recall = undef; $recall = $item->check_recalls if $item->can_be_waiting_recall; if ( defined $recall ) { diff --git a/C4/Search.pm b/C4/Search.pm index ca8e79ab0f1..89534c12db3 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1936,7 +1936,7 @@ sub searchResults { ) : ( '', '', '' ); $reservestatus = C4::Reserves::GetReserveStatus( $item->{itemnumber} ); - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { if ( Koha::Recalls->search({ item_id => $item->{itemnumber}, status => 'waiting' })->count ) { $recallstatus = 'Waiting'; } diff --git a/C4/XSLT.pm b/C4/XSLT.pm index 458d732d23c..d0bcc8ff209 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -299,7 +299,7 @@ sub buildKohaItemsNamespace { my $substatus = ''; my $recalls_count; - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { $recalls_count = Koha::Recalls->search({ item_id => $item->itemnumber, status => 'waiting' })->count; } diff --git a/Koha/Biblio.pm b/Koha/Biblio.pm index 9be761d0e19..183b0ae7608 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -1988,7 +1988,7 @@ if hold_convert $param is included, this is to say that this a check to convert sub can_be_recalled { my ( $self, $params ) = @_; - return 0 if !( C4::Context->preference('UseRecalls') ); + return 0 if ( C4::Context->preference('UseRecalls') eq "off" ); my $patron = $params->{patron}; diff --git a/Koha/Item.pm b/Koha/Item.pm index a011c5563ee..1b68b441c22 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2276,7 +2276,7 @@ if hold_convert $param is included, this is to say that this a check to convert sub can_be_recalled { my ( $self, $params ) = @_; - return 0 if !( C4::Context->preference('UseRecalls') ); + return 0 if ( C4::Context->preference('UseRecalls') eq "off" ); # check if this item is not for loan, withdrawn or lost return 0 if ( $self->notforloan != 0 ); @@ -2361,7 +2361,7 @@ At this point the item has already been recalled. We are now at the checkin and sub can_be_waiting_recall { my ( $self ) = @_; - return 0 if !( C4::Context->preference('UseRecalls') ); + return 0 if ( C4::Context->preference('UseRecalls') eq "off" ); # check if this item is not for loan, withdrawn or lost return 0 if ( $self->notforloan != 0 ); diff --git a/circ/circulation.pl b/circ/circulation.pl index 9230347ce01..16051a3bc27 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -500,7 +500,7 @@ if (@$barcodes && $op eq 'cud-checkout') { } unless ($confirm_required) { my $switch_onsite_checkout = exists $messages->{ONSITE_CHECKOUT_WILL_BE_SWITCHED}; - if ( C4::Context->preference('UseRecalls') && !$recall_id ) { + if ( C4::Context->preference('UseRecalls') ne "off" && !$recall_id ) { my $recall = Koha::Recalls->find( { biblio_id => $item->biblionumber, @@ -576,7 +576,7 @@ if ($patron) { WaitingHolds => $waiting_holds, ); - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { my $waiting_recalls = $patron->recalls->search({ status => 'waiting' }); $template->param( recalls => $patron->recalls->filter_by_current->search({},{ order_by => { -asc => 'created_date' } }), diff --git a/circ/returns.pl b/circ/returns.pl index b57e64a9204..0a12b01e1c2 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -262,7 +262,7 @@ if ($transit && $op eq 'cud-transfer') { my $transfer = Koha::Item::Transfers->find($transit); if ( $canceltransfer ) { $transfer->cancel({ reason => 'Manual', force => 1}); - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { my $recall_transfer_deleted = Koha::Recalls->find({ item_id => $itemnumber, status => 'in_transit' }); if ( defined $recall_transfer_deleted ) { $recall_transfer_deleted->revert_transfer; @@ -276,7 +276,7 @@ if ($transit && $op eq 'cud-transfer') { my $item = Koha::Items->find($itemnumber); my $transfer = $item->get_transfer; $transfer->cancel({ reason => 'Manual', force => 1}); - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { my $recall_transfer_deleted = Koha::Recalls->find({ item_id => $itemnumber, status => 'in_transit' }); if ( defined $recall_transfer_deleted ) { $recall_transfer_deleted->revert_transfer; diff --git a/circ/transferstoreceive.pl b/circ/transferstoreceive.pl index 0116278145e..113e54f1457 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -111,7 +111,7 @@ while ( my $library = $libraries->next ) { } # check for a recall for this transfer - if ( C4::Context->preference('UseRecalls') ) { + if ( C4::Context->preference('UseRecalls') ne "off" ) { my $recall = $item->recall; if ( defined $recall ) { $getransf{recall} = $recall; diff --git a/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl b/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl deleted file mode 100755 index 17c0896d332..00000000000 --- a/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl +++ /dev/null @@ -1,16 +0,0 @@ -use Modern::Perl; - -return { - bug_number => "31391", - description => "Staff-side recalls", - up => sub { - my ($args) = @_; - my ( $dbh, $out ) = @$args{qw(dbh out)}; - - $dbh->do( - q{INSERT IGNORE INTO systempreferences (variable,value,options,explanation,type) VALUES ('RecallsInterface','opac','opac|staff|both','The interface that recalls can be placed through','Choice') } - ); - - say $out "Added system preference 'RecallsInterface'"; - }, -}; diff --git a/installer/data/mysql/atomicupdate/bug_31391_-_update_UseRecalls_syspref.pl b/installer/data/mysql/atomicupdate/bug_31391_-_update_UseRecalls_syspref.pl new file mode 100755 index 00000000000..9af3394519f --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31391_-_update_UseRecalls_syspref.pl @@ -0,0 +1,19 @@ +use Modern::Perl; +use Koha::Installer::Output qw(say_warning say_failure say_success say_info); + +return { + bug_number => "31391", + description => "Staff-side recalls", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + try { + $dbh->do(q{UPDATE systempreferences SET value = "off", options = "off|opac|staff|opac_and_staff", type="Choice" WHERE variable = "UseRecalls" AND value = "0"}); + $dbh->do(q{UPDATE systempreferences SET value = "opac", options = "off|opac|staff|opac_and_staff", type="Choice" WHERE variable = "UseRecalls" AND value = "1"}); + say_success( $out, "Updated system preference 'UseRecalls' to include interface choices" ); + } + catch { + say_failure( $out, "Database modification failed with errors: $_" ); + }; + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index d0499a28c5b..3ad73b12c07 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -640,7 +640,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('QuoteOfTheDay','','intranet,opac','Enable or disable display of Quote of the Day on the OPAC and staff interface home page','multiple'), ('RandomizeHoldsQueueWeight','0',NULL,'if ON, the holds queue in circulation will be randomized, either based on all location codes, or by the location codes specified in StaticHoldsQueueWeight','YesNo'), ('RealTimeHoldsQueue', '0', NULL, 'Enable updating the holds queue in real time', 'YesNo'), -('RecallsInterface','opac','opac|staff|both','The interface that recalls can be placed through','Choice'), ('RecallsLog','1',NULL,'If ON, log create/cancel/expire/fulfill actions on recalls','YesNo'), ('RecallsMaxPickUpDelay','7',NULL,'Define the maximum time a recall can be awaiting pickup','Integer'), ('RecordLocalUseOnReturn','0',NULL,'If ON, statistically record returns of unissued items as local use, instead of return','YesNo'), @@ -843,7 +842,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('UseICUStyleQuotes','0','1','Tell Koha whether to use ICU style quotes ({) or default (") when tracing subjects .','YesNo'), ('UseLocationAsAQInSIP', '0', '', 'Use permanent_location instead of homebranch for AQ in SIP response', 'YesNo'), ('UseOCLCEncodingLevels','0',NULL,'If enabled, include OCLC encoding levels in leader value builder dropdown for position 17.','YesNo'), -('UseRecalls','0',NULL,'Enable or disable recalls','YesNo'), +('UseRecalls','off','off|opac|staff|opac_and_staff','Enable or disable recalls','Choice'), ('UseTransportCostMatrix','0','','Use Transport Cost Matrix when filling holds','YesNo'), ('UseWYSIWYGinSystemPreferences','0','','Show WYSIWYG editor when editing certain HTML system preferences.','YesNo'), ('viewISBD','1','','Allow display of ISBD view of bibiographic records','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc index 3e5625eff0a..407f35de3c0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/biblio-view-menu.inc @@ -124,7 +124,7 @@ [%- END -%] - [%- IF ( Koha.Preference('UseRecalls') && CAN_user_recalls ) -%] + [%- IF ( Koha.Preference('UseRecalls') != "off" && CAN_user_recalls ) -%] [%- IF ( recallsview ) -%]
  • [%- ELSE -%] diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc index 56d4e923afa..bb7b7852af8 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -243,7 +243,7 @@ ILL requests history
  • [% END %] - [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %] + [% IF Koha.Preference('UseRecalls') != "off" && CAN_user_recalls %] [% IF recallsview %]
  • [% ELSE %]
  • [% END %] Recalls history
  • diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc index 86ca5d18ce2..60e532cc822 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -70,7 +70,7 @@
    - [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] + [% IF Koha.Preference('UseRecalls') != "off" and CAN_user_recalls %]
    Recalls
    - [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] + [% IF Koha.Preference('UseRecalls') != "off" and CAN_user_recalls %]

    Recalls