From bc5b7c08bbd7dccd0403ea1cc2f7bc66db4bbdfd 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 0a8df342638..ee1ea214ec2 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -392,7 +392,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 ) { @@ -1176,7 +1176,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) { @@ -1705,7 +1705,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, @@ -2582,7 +2582,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; @@ -2672,7 +2672,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' } ); @@ -3253,7 +3253,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 12ba64f60fe..105ba5a540d 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 a2d212fe138..8d294182512 100644 --- a/C4/XSLT.pm +++ b/C4/XSLT.pm @@ -369,7 +369,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 84bcf476d0b..9f45b16f030 100644 --- a/Koha/Biblio.pm +++ b/Koha/Biblio.pm @@ -2164,7 +2164,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 8a19b005388..fa618cd5f41 100644 --- a/Koha/Item.pm +++ b/Koha/Item.pm @@ -2473,7 +2473,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 ); @@ -2573,7 +2573,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 dddd2a1f5f9..fb69fc20d2e 100755 --- a/circ/circulation.pl +++ b/circ/circulation.pl @@ -529,7 +529,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, @@ -614,7 +614,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 35c3367ea4b..fba3736c929 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -243,7 +243,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; @@ -257,7 +257,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 46206ce5817..9bd788c19d7 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 598c2ecda2c..5f01a7228bf 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -668,7 +668,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'), @@ -875,7 +874,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 dd32ca07a2d..699206dc236 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 93793177ce5..9f23f9f46fb 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/circ-menu.inc @@ -253,7 +253,7 @@ ILL requests history [% END %] - [% IF Koha.Preference('UseRecalls') && CAN_user_recalls %] + [% IF Koha.Preference('UseRecalls') != "off" && CAN_user_recalls %]
  • Recalls history
  • @@ -291,8 +291,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 07cb781c347..f752e488615 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