From e790f75c0dedd30b20ce4bf8828954a64a5520e5 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 24 May 2023 21:53:38 +0000 Subject: [PATCH] Bug 28130: Manage subscription alerts on OPAC MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit This patch adds an 'Alert subscriptions' tab to the patron's account on the OPAC, so they can easily view or cancel email alerts they have subscribed to. To test: 1. Subscribe to email alerts for one or more subscriptions via the OPAC 2. Go to your account, notice the new 'Alert subscriptions' menu option, click here 3. Confirm your subscribed alerts show here. Confirm the table sorting works etc (JS enabled). 4. Test unsubscribing from email alerts, make sure the confirmation pop-up works as expected (JS enabled). 5. Confirm that, when unsubscribing, you are redirected back to this page. 6. Confirm the menu option disappears from the left sidebar navigation if you have no alert subscriptions. Sponsored-by: Bibliotheksservice-Zentrum Baden-Wuerttemberg Signed-off-by: Christian Stelzenmüller Signed-off-by: Sam Lau Signed-off-by: Nick Clemens Signed-off-by: Tomas Cohen Arazi --- .../bootstrap/en/includes/usermenu.inc | 9 ++ .../en/modules/opac-alert-subscriptions.tt | 111 ++++++++++++++++++ opac/opac-alert-subscribe.pl | 4 + opac/opac-alert-subscriptions.pl | 53 +++++++++ 4 files changed, 177 insertions(+) create mode 100644 koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt create mode 100755 opac/opac-alert-subscriptions.pl diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc index e53c087de0..caf2277198 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc @@ -157,6 +157,15 @@ Curbside pickups [% END %] + [% IF logged_in_user.alert_subscriptions.count %] + [% IF ( alertsview ) %] +
  • + [% ELSE %] +
  • + [% END %] + Alert subscriptions ([% logged_in_user.alert_subscriptions.count | html %])
  • + [% END %] + [% END %] diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt new file mode 100644 index 0000000000..abcdb9319a --- /dev/null +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-alert-subscriptions.tt @@ -0,0 +1,111 @@ +[% USE Koha %] +[% USE Branches %] +[% USE AuthorisedValues %] +[% USE AdditionalContents %] +[% SET OpacNav = AdditionalContents.get( location => "OpacNav", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] +[% SET OpacNavBottom = AdditionalContents.get( location => "OpacNavBottom", lang => lang, library => logged_in_user.branchcode || default_branch, blocktitle => 0 ) %] +[% INCLUDE 'doc-head-open.inc' %] +Your alert subscriptions › [% IF ( LibraryNameTitle ) %][% LibraryNameTitle | html %][% ELSE %]Koha online[% END %] catalog +[% INCLUDE 'doc-head-close.inc' %] +[% BLOCK cssinclude %][% END %] + +[% INCLUDE 'bodytag.inc' bodyid='opac-alert-subscriptions' %] +[% INCLUDE 'masthead.inc' %] + +
    + + +
    +
    +
    + +
    +
    + +
    +

    Alert subscriptions

    + + [% IF patron.alert_subscriptions.count %] + + + + + + + + + + + + + [% FOREACH sub IN patron.alert_subscriptions %] + + + + + + + + + [% END %] + +
    ISSNTitleLibraryLocationCall numberActions
    + [% IF sub.biblio.biblioitem.issn %][% sub.biblio.biblioitem.issn | html %][% END %] + + [% sub.biblio.title | html %] [% sub.biblio.subtitle | html %] + + [% IF ( sub.branchcode ) %][% Branches.GetName( sub.branchcode ) | html %][% END %] + + [% IF ( sub.location ) %][% AuthorisedValues.GetDescriptionByKohaField( kohafield => 'items.location', authorised_value => sub.location ) | html %][% END %] + + [% IF ( sub.callnumber ) %][% sub.callnumber | html %][% END %] + +
    + + + + + +
    +
    + [% ELSE %] +
    +

    You have not subscribed to email alerts for any subscriptions.

    +
    + [% END %] +
    + +
    +
    +
    +
    + +[% INCLUDE 'opac-bottom.inc' %] +[% BLOCK jsinclude %] +[% INCLUDE 'datatables.inc' %] + +[% END %] diff --git a/opac/opac-alert-subscribe.pl b/opac/opac-alert-subscribe.pl index c35b341e37..1d37d94563 100755 --- a/opac/opac-alert-subscribe.pl +++ b/opac/opac-alert-subscribe.pl @@ -67,6 +67,10 @@ elsif ( $op eq 'cancel_confirmed' ) { print $query->redirect( "opac-serial-issues.pl?biblionumber=$biblionumber"); exit; + } elsif ( $referer eq 'patron' ) { + print $query->redirect( + "/cgi-bin/koha/opac-alert-subscriptions.pl" + ); } else { print $query->redirect( "opac-detail.pl?biblionumber=$biblionumber"); diff --git a/opac/opac-alert-subscriptions.pl b/opac/opac-alert-subscriptions.pl new file mode 100755 index 0000000000..d3a2ccea97 --- /dev/null +++ b/opac/opac-alert-subscriptions.pl @@ -0,0 +1,53 @@ +#!/usr/bin/perl + +# Copyright 2023 Aleisha Amohia +# +# This file is part of Koha. +# +# Koha is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# Koha is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# 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 ); +use C4::Context; +use C4::Output qw( output_html_with_http_headers ); +use Koha::Patrons; +use Koha::Token; + +my $query = CGI->new(); + +my ( $template, $borrowernumber, $cookie ) = get_template_and_user( + { + template_name => 'opac-alert-subscriptions.tt', + query => $query, + type => 'opac', + } +); + +my $patron = Koha::Patrons->find( $borrowernumber ); + +$template->param( + alertsview => 1, + 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, + }), +); + +output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; -- 2.39.5