From d7b7db604a8209e4271d357658c075e6492e803b 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 Signed-off-by: Pedro Amorim --- 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 | 3 +-- ...ug_31391_-_add_RecallsInterface_syspref.pl | 17 +------------- .../bug_31391_-_update_UseRecalls_syspref.pl | 22 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 3 +-- .../prog/en/includes/biblio-view-menu.inc | 2 +- .../prog/en/includes/circ-menu.inc | 5 ++--- .../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 | 10 ++++----- .../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 | 8 ++----- 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, 111 insertions(+), 117 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_31391_-_update_UseRecalls_syspref.pl diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 48185eb0224..be09c213827 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -391,7 +391,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 ) { @@ -1170,7 +1170,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) { @@ -1697,7 +1697,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, @@ -2518,7 +2518,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; @@ -2605,7 +2605,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' } ); @@ -3188,7 +3188,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 a8c89b4998a..a7791714f19 100644 --- a/C4/Search.pm +++ b/C4/Search.pm @@ -1988,7 +1988,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 422a02b1ea7..4959fa21350 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -321,7 +321,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 a8cacc7aa00..032a5e56fae 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -2172,7 +2172,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 43f275d68d2..07ca8f40f02 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2446,7 +2446,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 ); @@ -2546,7 +2546,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 0a9906028e9..4a723ba358c 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -523,7 +523,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, @@ -602,7 +602,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 901877ef1e5..06e4f5ec420 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -233,7 +233,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; @@ -247,7 +247,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 de03f0d877e..c3590973711 100755 --- a/circ/transferstoreceive.pl +++ b/circ/transferstoreceive.pl @@ -110,7 +110,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; @@ -137,4 +137,3 @@ $template->param( $template->param( fast_cataloging => 1 ) if Koha::BiblioFrameworks->find('FA'); output_html_with_http_headers $input, $cookie, $template->output; - diff --git a/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl b/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl index 17c0896d332..a334f382971 100644 --- a/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl +++ b/installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl @@ -1,16 +1 @@ -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'"; - }, -}; +rm 'installer/data/mysql/atomicupdate/bug_31391_-_add_RecallsInterface_syspref.pl' 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 100644 index 00000000000..d8606fade1c --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_31391_-_update_UseRecalls_syspref.pl @@ -0,0 +1,22 @@ +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 5c3e109e9af..7d439094387 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -666,7 +666,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'), @@ -872,7 +871,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 7d304bceaf2..5bbf33dd22f 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 @@ -91,7 +91,7 @@ [%- END -%] - [%- IF ( Koha.Preference('UseRecalls') && CAN_user_recalls ) -%] + [%- IF ( Koha.Preference('UseRecalls') != "off" && CAN_user_recalls ) -%]
  • Recalls ([% biblio.recalls.search( completed => 0 ).count | html %])
  • 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 9eb64327123..503a4ee057b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -245,7 +245,7 @@ ILL requests history [% END %] - [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %] + [% IF Koha.Preference('UseRecalls') != "off" && CAN_user_recalls %]
  • Recalls history
  • @@ -283,8 +283,7 @@
    [% patron.title | html %] [% patron.firstname | html %] [% patron.surname | html %] does not currently have an image available. To import an image for [% patron.title | html %] [% patron.firstname | html %] - [% patron.surname | html %], - enter the name of an image file to upload. + [% patron.surname | html %], enter the name of an image file to upload.
    [% END # /IF patron.image %]

    Only PNG, GIF, JPEG, XPM formats are supported.

    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 a610def3061..72699e024ef 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-nav.inc @@ -64,7 +64,7 @@ - [% IF Koha.Preference('UseRecalls') and CAN_user_recalls %] + [% IF Koha.Preference('UseRecalls') != "off" and CAN_user_recalls %]
    Recalls