Bugzilla – Attachment 176794 Details for
Bug 36273
ILL - Refactor $op in ill-requests.pl
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36273: OPAC: WIP
Bug-36273-OPAC-WIP.patch (text/plain), 11.46 KB, created by
Pedro Amorim
on 2025-01-20 12:52:36 UTC
(
hide
)
Description:
Bug 36273: OPAC: WIP
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-01-20 12:52:36 UTC
Size:
11.46 KB
patch
obsolete
>From 5bea49537a35fe248b70a69f9ab74846dc533bdf Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Date: Mon, 20 Jan 2025 12:50:12 +0000 >Subject: [PATCH] Bug 36273: OPAC: WIP > >This is working, currently built on top of bug 36197 as that was the development that brought this issue to light. > >Refreshing the following URL with unauthenticatedOPACILLRequest enabled would always create a new ILL request. >http://localhost:8080/cgi-bin/koha/opac-illrequests.pl?method=create&stage=form&backend=Standard&type=article&branchcode=CPL&unauthenticated_first_name=Pedro%20Jorge&unauthenticated_last_name=Andrade%20Amorim&unauthenticated_email=pedro.amorim@ptfs-europe.com > >This patch gets rid of using the get_op_param_deprecation method in the OPAC controller. >This creates the needed distinction between 'create' op (show the form) and 'cud-create' op (handle POST form submission) >More testing is required. >--- > .../bootstrap/en/modules/opac-illrequests.tt | 8 +- > opac/opac-illrequests.pl | 120 ++++++++++-------- > 2 files changed, 68 insertions(+), 60 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >index 930bc47c33f..b289cda1f8e 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-illrequests.tt >@@ -33,7 +33,7 @@ > [% WRAPPER breadcrumb_item %] > <a href="/cgi-bin/koha/opac-illrequests.pl">Interlibrary loan requests</a> > [% END %] >- [% IF op == 'cud-create' %] >+ [% IF op == 'create' %] > [% WRAPPER breadcrumb_item bc_active= 1 %] > <span>New interlibrary loan request</span> > [% END %] >@@ -82,7 +82,7 @@ > <div class="alert alert-warning">ILL module configuration problem. Contact your administrator.</div> > [% ELSE %] > <div id="illrequests" class="maincontent"> >- [% IF op == 'cud-create' %] >+ [% IF op == 'create' %] > <h1>New interlibrary loan request</h1> > [% IF stage == 'copyrightclearance' %] > [% INCLUDE messages %] >@@ -129,7 +129,7 @@ > [% IF can_patron_place_ill_in_opac %] > <div id="illrequests-create-button" class="dropdown btn-group"> > [% IF Koha.Preference('AutoILLBackendPriority') %] >- <a id="ill-new" class="btn btn-primary" href="/cgi-bin/koha/opac-illrequests.pl?method=create&backend=Standard"> >+ <a id="ill-new" class="btn btn-primary" href="/cgi-bin/koha/opac-illrequests.pl?op=create&backend=Standard"> > <i class="fa fa-plus" aria-hidden="true"></i> Create a new auto request > </a> > [% ELSIF backends.size > 1 %] >@@ -465,7 +465,7 @@ > </fieldset> > </form> > </div> >- [% END # / IF op == 'cud-create' %] >+ [% END # / IF op == 'create' %] > </div> <!-- / #illrequests --> > [% END # /IF !backends_available %] > </div> <!-- / .col-lg-10/12 --> >diff --git a/opac/opac-illrequests.pl b/opac/opac-illrequests.pl >index 08dd43df840..7dc7d16ec05 100755 >--- a/opac/opac-illrequests.pl >+++ b/opac/opac-illrequests.pl >@@ -51,14 +51,15 @@ if ( ! C4::Context->preference('ILLModule') ) { > exit; > } > >-my $op = Koha::ILL::Request->get_op_param_deprecation( 'opac', $params ); >+my $op = $params->{'op'} || 'list'; > > my ( $template, $loggedinuser, $cookie ) = get_template_and_user({ > template_name => "opac-illrequests.tt", > query => $query, > type => "opac", > authnotrequired => ( >- ( C4::Context->preference("ILLOpacUnauthenticatedRequest") && ( $op eq 'cud-create' || $op eq 'unauth_view' ) ) >+ ( C4::Context->preference("ILLOpacUnauthenticatedRequest") >+ && ( $op eq 'create' || $op eq 'cud-create' || $op eq 'unauth_view' ) ) > ? 1 > : 0 > ) >@@ -117,8 +118,8 @@ if ( $op eq 'list' ) { > . $illrequest_id > . '&message=1' ); > exit; >-} elsif ( $op eq 'cud-create' ) { >- if (!$params->{backend}) { >+} elsif ( $op eq 'create' ) { >+ if (!$params->{backend}) { > my $req = Koha::ILL::Request->new; > $template->param( > backends => $backends >@@ -127,48 +128,64 @@ if ( $op eq 'list' ) { > $params->{backend} = 'Standard' if $params->{backend} eq 'FreeForm'; > my $request = Koha::ILL::Request->new > ->load_backend($params->{backend}); >+ $params->{cardnumber} = $patron->cardnumber if $patron; >+ $params->{branchcode} = $patron->branchcode if $patron; >+ $params->{opac} = 1; >+ $params->{lang} = C4::Languages::getlanguage($query); >+ my $backend_result = $request->backend_create($params); >+ >+ if ($backend_result->{stage} eq 'copyrightclearance') { >+ $template->param( >+ stage => $backend_result->{stage}, >+ whole => $backend_result >+ ); >+ } else { >+ $template->param( >+ types => [ "Book", "Article", "Journal" ], >+ branches => Koha::Libraries->search->unblessed, >+ whole => $backend_result, >+ request => $request >+ ); >+ } >+ } >+} elsif ( $op eq 'cud-create' ) { >+ $params->{backend} = 'Standard' if $params->{backend} eq 'FreeForm'; >+ my $request = Koha::ILL::Request->new->load_backend( $params->{backend} ); > > # Before request creation operations - Preparation >- my $history_check = >- Koha::ILL::Request::Workflow::HistoryCheck->new( $params, 'opac' ); >- my $availability = >- Koha::ILL::Request::Workflow::Availability->new( $params, 'opac' ); >- my $type_disclaimer = >- Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'opac' ); >- my $confirm_auto = >- Koha::ILL::Request::Workflow::ConfirmAuto->new( $params, 'opac' ); >+ my $history_check = Koha::ILL::Request::Workflow::HistoryCheck->new( $params, 'opac' ); >+ my $availability = Koha::ILL::Request::Workflow::Availability->new( $params, 'opac' ); >+ my $type_disclaimer = Koha::ILL::Request::Workflow::TypeDisclaimer->new( $params, 'opac' ); >+ my $confirm_auto = Koha::ILL::Request::Workflow::ConfirmAuto->new( $params, 'opac' ); > > # ILLHistoryCheck operation >- if ($history_check->show_history_check($request)) { >+ if ( $history_check->show_history_check($request) ) { > $op = 'historycheck'; >- $template->param( >- $history_check->history_check_template_params($params) >- ); >+ $template->param( $history_check->history_check_template_params($params) ); > output_html_with_http_headers $query, $cookie, > $template->output, undef, > { force_no_caching => 1 }; > exit; >- # ILLCheckAvailability operation >- } elsif ($availability->show_availability($request)) { >+ >+ # ILLCheckAvailability operation >+ } elsif ( $availability->show_availability($request) ) { > $op = 'availability'; >- $template->param( >- $availability->availability_template_params($params) >- ); >+ $template->param( $availability->availability_template_params($params) ); > output_html_with_http_headers $query, $cookie, > $template->output, undef, > { force_no_caching => 1 }; > exit; >- # ILLModuleDisclaimerByType operation >- } elsif ( $type_disclaimer->show_type_disclaimer($request)) { >+ >+ # ILLModuleDisclaimerByType operation >+ } elsif ( $type_disclaimer->show_type_disclaimer($request) ) { > $op = 'typedisclaimer'; >- $template->param( >- $type_disclaimer->type_disclaimer_template_params($params) >- ); >+ $template->param( $type_disclaimer->type_disclaimer_template_params($params) ); > output_html_with_http_headers $query, $cookie, > $template->output, undef, > { force_no_caching => 1 }; > exit; >- # ConfirmAuto operation >+ >+ # ConfirmAuto operation > } elsif ( $confirm_auto->show_confirm_auto($request) ) { > $op = 'confirmautoill'; > $template->param( $confirm_auto->confirm_auto_template_params($params) ); >@@ -177,43 +194,34 @@ if ( $op eq 'list' ) { > { force_no_caching => 1 }; > exit; > } >- > $params->{cardnumber} = $patron->cardnumber if $patron; > $params->{branchcode} = $patron->branchcode if $patron; > $params->{opac} = 1; > $params->{lang} = C4::Languages::getlanguage($query); > my $backend_result = $request->backend_create($params); >- >- if ($backend_result->{stage} eq 'copyrightclearance') { >- $template->param( >- stage => $backend_result->{stage}, >- whole => $backend_result >- ); >- } else { >+ if ($backend_result->{stage} eq 'commit') { >+ # After creation actions >+ if ( $params->{type_disclaimer_submitted} ) { >+ $type_disclaimer->after_request_created( $params, $request ); >+ } >+ if ( C4::Context->preference('ILLHistoryCheck') ) { >+ $history_check->after_request_created( $params, $request ); >+ } >+ if ( C4::Context->preference('ILLOpacUnauthenticatedRequest') && !$patron ) { >+ $op = 'unauth_view'; >+ } else { >+ print $query->redirect('/cgi-bin/koha/opac-illrequests.pl?message=2'); >+ exit; >+ } >+ }else{ >+ $op = 'create'; > $template->param( >- types => [ "Book", "Article", "Journal" ], >- branches => Koha::Libraries->search->unblessed, >- whole => $backend_result, >- request => $request >+ types => [ "Book", "Article", "Journal" ], >+ branches => Koha::Libraries->search->unblessed, >+ whole => $backend_result, >+ request => $request > ); >- if ($backend_result->{stage} eq 'commit') { >- # After creation actions >- if ( $params->{type_disclaimer_submitted} ) { >- $type_disclaimer->after_request_created( $params, $request ); >- } >- if ( C4::Context->preference('ILLHistoryCheck') ) { >- $history_check->after_request_created( $params, $request ); >- } >- if ( C4::Context->preference('ILLOpacUnauthenticatedRequest') && !$patron ) { >- $op = 'unauth_view'; >- } else { >- print $query->redirect('/cgi-bin/koha/opac-illrequests.pl?message=2'); >- exit; >- } >- } > } >- >- } > } > > $template->param( >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 36273
: 176794