From fe21bbad2abcacba1091d80a2f75490a8be8ad17 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Fri, 21 Jul 2023 13:00:10 +0000 Subject: [PATCH] Bug 28130: (QA follow-up) Tidy Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- Koha/Patron.pm | 6 ++--- members/alert-subscriptions.pl | 30 ++++++++++++---------- opac/opac-alert-subscribe.pl | 43 ++++++++++++-------------------- opac/opac-alert-subscriptions.pl | 20 ++++++++------- t/db_dependent/Koha/Patron.t | 10 ++++---- 5 files changed, 52 insertions(+), 57 deletions(-) diff --git a/Koha/Patron.pm b/Koha/Patron.pm index 9794b14b1f..7321277234 100644 --- a/Koha/Patron.pm +++ b/Koha/Patron.pm @@ -2708,12 +2708,12 @@ Return a Koha::Subscriptions object containing subscriptions for which the patro =cut sub alert_subscriptions { - my ( $self ) = @_; + my ($self) = @_; - my @alerts = $self->_result->alerts; + my @alerts = $self->_result->alerts; my @subscription_ids = map { $_->externalid } @alerts; - return Koha::Subscriptions->search({ subscriptionid => \@subscription_ids }); + return Koha::Subscriptions->search( { subscriptionid => \@subscription_ids } ); } =head2 Internal methods diff --git a/members/alert-subscriptions.pl b/members/alert-subscriptions.pl index 82fc894e27..f1bd12cffc 100755 --- a/members/alert-subscriptions.pl +++ b/members/alert-subscriptions.pl @@ -28,29 +28,33 @@ use Koha::Patrons; my $input = CGI->new; my ( $template, $loggedinuser, $cookie ) = get_template_and_user( - { template_name => "members/alert-subscriptions.tt", - query => $input, - type => "intranet", - flagsrequired => { serials => '*' }, + { + template_name => "members/alert-subscriptions.tt", + query => $input, + type => "intranet", + flagsrequired => { serials => '*' }, } ); my $borrowernumber = $input->param('borrowernumber'); -my $logged_in_user = Koha::Patrons->find( $loggedinuser ); -my $patron = Koha::Patrons->find( $borrowernumber ); -output_and_exit_if_error( $input, $cookie, $template, { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } ); +my $logged_in_user = Koha::Patrons->find($loggedinuser); +my $patron = Koha::Patrons->find($borrowernumber); +output_and_exit_if_error( + $input, $cookie, $template, + { module => 'members', logged_in_user => $logged_in_user, current_patron => $patron } +); my $subscription_id = $input->param('subscription_id'); -if ( $subscription_id ) { - my $subscription = Koha::Subscriptions->find( $subscription_id ); - $subscription->remove_subscriber( $patron ); - print $input->redirect("/cgi-bin/koha/members/alert-subscriptions.pl?borrowernumber=".$borrowernumber); +if ($subscription_id) { + my $subscription = Koha::Subscriptions->find($subscription_id); + $subscription->remove_subscriber($patron); + print $input->redirect( "/cgi-bin/koha/members/alert-subscriptions.pl?borrowernumber=" . $borrowernumber ); } $template->param( - patron => $patron, - alertsview => 1, + patron => $patron, + alertsview => 1, ); output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-alert-subscribe.pl b/opac/opac-alert-subscribe.pl index 1d37d94563..63c3c679b5 100755 --- a/opac/opac-alert-subscribe.pl +++ b/opac/opac-alert-subscribe.pl @@ -17,7 +17,6 @@ # You should have received a copy of the GNU General Public License # along with Koha; if not, see . - use Modern::Perl; use CGI qw ( -utf8 ); use C4::Auth qw( get_template_and_user ); @@ -25,68 +24,58 @@ use C4::Output qw( output_html_with_http_headers ); use C4::Context; use C4::Serials qw( GetSubscription ); - my $query = CGI->new; my $op = $query->param('op') || ''; my $dbh = C4::Context->dbh; my ( $template, $loggedinuser, $cookie ); my $subscriptionid = $query->param('subscriptionid'); -my $referer = $query->param('referer') || 'detail'; -my $biblionumber = $query->param('biblionumber'); +my $referer = $query->param('referer') || 'detail'; +my $biblionumber = $query->param('biblionumber'); ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "opac-alert-subscribe.tt", query => $query, type => "opac", - authnotrequired => 0, # user must logged in to request - # subscription notifications + authnotrequired => 0, # user must be logged in to request + # subscription notifications } ); -my $subscription = Koha::Subscriptions->find( $subscriptionid ); -my $logged_in_patron = Koha::Patrons->find( $loggedinuser ); +my $subscription = Koha::Subscriptions->find($subscriptionid); +my $logged_in_patron = Koha::Patrons->find($loggedinuser); if ( $op eq 'alert_confirmed' ) { - $subscription->add_subscriber( $logged_in_patron ); + $subscription->add_subscriber($logged_in_patron); if ( $referer eq 'serial' ) { - print $query->redirect( - "opac-serial-issues.pl?biblionumber=$biblionumber"); + print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber"); exit; } else { - print $query->redirect( - "opac-detail.pl?biblionumber=$biblionumber"); + print $query->redirect("opac-detail.pl?biblionumber=$biblionumber"); exit; } -} -elsif ( $op eq 'cancel_confirmed' ) { - $subscription->remove_subscriber( $logged_in_patron ); +} elsif ( $op eq 'cancel_confirmed' ) { + $subscription->remove_subscriber($logged_in_patron); warn "CANCEL confirmed : $loggedinuser, $subscriptionid"; if ( $referer eq 'serial' ) { - print $query->redirect( - "opac-serial-issues.pl?biblionumber=$biblionumber"); + print $query->redirect("opac-serial-issues.pl?biblionumber=$biblionumber"); exit; } elsif ( $referer eq 'patron' ) { - print $query->redirect( - "/cgi-bin/koha/opac-alert-subscriptions.pl" - ); + print $query->redirect("/cgi-bin/koha/opac-alert-subscriptions.pl"); } else { - print $query->redirect( - "opac-detail.pl?biblionumber=$biblionumber"); + print $query->redirect("opac-detail.pl?biblionumber=$biblionumber"); exit; } - -} -else { +} else { my $subscription = &GetSubscription($subscriptionid); $template->param( referer => $referer, "typeissue$op" => 1, bibliotitle => $subscription->{bibliotitle}, notes => $subscription->{notes}, - subscriptionid => $subscriptionid, + subscriptionid => $subscriptionid, biblionumber => $biblionumber, ); } diff --git a/opac/opac-alert-subscriptions.pl b/opac/opac-alert-subscriptions.pl index d3a2ccea97..f6fd488d8e 100755 --- a/opac/opac-alert-subscriptions.pl +++ b/opac/opac-alert-subscriptions.pl @@ -29,25 +29,27 @@ my $query = CGI->new(); my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { - template_name => 'opac-alert-subscriptions.tt', - query => $query, - type => 'opac', + template_name => 'opac-alert-subscriptions.tt', + query => $query, + type => 'opac', } ); -my $patron = Koha::Patrons->find( $borrowernumber ); +my $patron = Koha::Patrons->find($borrowernumber); $template->param( alertsview => 1, - patron => $patron, - referer => 'patron', + patron => $patron, + referer => 'patron', ); my $new_session_id = $query->cookie('CGISESSID'); $template->param( - csrf_token => Koha::Token->new->generate_csrf({ - session_id => $new_session_id, - }), + csrf_token => Koha::Token->new->generate_csrf( + { + session_id => $new_session_id, + } + ), ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; diff --git a/t/db_dependent/Koha/Patron.t b/t/db_dependent/Koha/Patron.t index cde132e550..44c1726a5d 100755 --- a/t/db_dependent/Koha/Patron.t +++ b/t/db_dependent/Koha/Patron.t @@ -1934,13 +1934,13 @@ subtest 'alert_subscriptions tests' => sub { plan tests => 3; - my $patron = $builder->build_object({ class => 'Koha::Patrons' }); + my $patron = $builder->build_object( { class => 'Koha::Patrons' } ); - my $subscription1 = $builder->build_object({ class => 'Koha::Subscriptions' }); - $subscription1->add_subscriber( $patron ); + my $subscription1 = $builder->build_object( { class => 'Koha::Subscriptions' } ); + $subscription1->add_subscriber($patron); - my $subscription2 = $builder->build_object({ class => 'Koha::Subscriptions' }); - $subscription2->add_subscriber( $patron ); + my $subscription2 = $builder->build_object( { class => 'Koha::Subscriptions' } ); + $subscription2->add_subscriber($patron); my @subscriptions = $patron->alert_subscriptions->as_list; -- 2.39.5