Bugzilla – Attachment 147521 Details for
Bug 12029
Patrons should be able to delete their patron messages
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 12029: Ability for patrons to dismiss OPAC messages
Bug-12029-Ability-for-patrons-to-dismiss-OPAC-mess.patch (text/plain), 9.71 KB, created by
Aleisha Amohia
on 2023-02-28 21:01:03 UTC
(
hide
)
Description:
Bug 12029: Ability for patrons to dismiss OPAC messages
Filename:
MIME Type:
Creator:
Aleisha Amohia
Created:
2023-02-28 21:01:03 UTC
Size:
9.71 KB
patch
obsolete
>From 846cf1fa7e2da49d343af56e65424c6df5335f9e Mon Sep 17 00:00:00 2001 >From: Aleisha Amohia <aleishaamohia@hotmail.com> >Date: Wed, 15 Feb 2023 21:57:08 +1300 >Subject: [PATCH] Bug 12029: Ability for patrons to dismiss OPAC messages > >This enhancement adds the ability for patrons to dismiss an OPAC >message, marking it as read to remove it from their summary page. > >To test: >1) Update database and restart services >2) Log into the staff interface and go to your patron account >3) Click the Add message button >4) Add a message for the OPAC and Save >5) Log into the OPAC. Note there is a message on the homepage saying you >have a message. Go to your user summary and confirm the message >displays. >6) Click the button to dismiss the message. A confirmation box should >pop up - hitting Cancel should stop the action. >7) Dismiss the message again and this time Confirm. Make sure the >message is gone from the OPAC user summary and from the homepage. >8) Confirm tests pass t/db_dependent/Koha/Patron/Messages.t >9) Create a few more messages for the OPAC >10) Log into the OPAC and dismiss one of the messages >11) Confirm the count of unread messages on the OPAC home page is >correct > >Sponsored-by: Koha-US >--- > Koha/Patron/Messages.pm | 23 ++++++++ > .../prog/en/includes/patron_messages.inc | 3 ++ > .../bootstrap/en/includes/opac-note.inc | 9 +++- > .../bootstrap/en/modules/opac-main.tt | 10 ++-- > .../bootstrap/en/modules/opac-user.tt | 4 ++ > opac/opac-dismiss-message.pl | 54 +++++++++++++++++++ > 6 files changed, 96 insertions(+), 7 deletions(-) > create mode 100755 opac/opac-dismiss-message.pl > >diff --git a/Koha/Patron/Messages.pm b/Koha/Patron/Messages.pm >index 7cc729ac86..063c70364b 100644 >--- a/Koha/Patron/Messages.pm >+++ b/Koha/Patron/Messages.pm >@@ -34,6 +34,25 @@ Koha::Patron::Messages - Koha Message Object set class > > =cut > >+=head3 filter_by_unread >+ >+ Returns a resultset of messages that have not been marked read by the patron >+ >+=cut >+ >+sub filter_by_unread { >+ my ( $self, $params ) = @_; >+ >+ $params ||= {}; >+ >+ return $self->search( >+ { >+ patron_read_date => { is => undef }, >+ %$params, >+ } >+ ); >+} >+ > =head3 _type > > =cut >@@ -42,6 +61,10 @@ sub _type { > return 'Message'; > } > >+=head3 object_class >+ >+=cut >+ > sub object_class { > return 'Koha::Patron::Message'; > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc >index db9c3430fc..13e160eefe 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc >@@ -308,6 +308,9 @@ > ( <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=[% patron_message.manager_id | uri %]">[% patron_message.get_column('manager_firstname') | html %] [% patron_message.get_column('manager_surname') | html %]</a> ) > [% END %] > <em>"[% patron_message.message | html %]"</em> >+ [% IF patron_message.patron_read_date %] >+ Read: <em>[% patron_message.patron_read_date | $KohaDates %]</em> >+ [% END %] > </span> > [% IF patron_message.branchcode == Branches.GetLoggedInBranchcode OR Koha.Preference('AllowAllMessageDeletion') %] > [% IF moremember %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc >index 22e6a068ce..6ed5e724f2 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc >@@ -1,12 +1,17 @@ >-[% IF patron_messages.count OR opacnote %] >+[% IF patron_messages.filter_by_unread.count OR opacnote %] > <div class="alert alert-info"> > <h3>Messages for you</h3> > <ul> >- [% FOREACH message IN patron_messages %] >+ [% FOREACH message IN patron_messages.filter_by_unread %] > <li> > <strong>[% message.message | html | html_line_break %]</strong><br> > <em>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) | html %]</em> > </li> >+ <form id="dismiss-message-form" action="/cgi-bin/koha/opac-dismiss-message.pl" method="post"> >+ <input type="hidden" name="message_id" value="[% message.message_id | html %]"> >+ <input type="hidden" name="patron_id" value="[% message.borrowernumber | html %]"> >+ <button type="submit" class="dismiss-message-button btn btn-primary"><i class="fa fa-trash" aria-hidden="true"></i> Dismiss</button> >+ </form> > [% END %] > > [% IF ( opacnote ) %]<li>[% opacnote | html | html_line_break %]</li>[% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >index 4ffbc8e024..cca221a4e0 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt >@@ -283,19 +283,19 @@ > </a> > </li> > [% END %] >- [% IF patron_messages && patron_messages.count > 0 || opacnote %] >+ [% IF patron_messages && patron_messages.filter_by_unread.count > 0 || opacnote %] > [% IF opacnote %] > <li> > <a href="/cgi-bin/koha/opac-user.pl"> >- <span class="count_label">[% patron_messages.count + 1 | html %]</span> >- [% tn('message', 'messages', patron_messages.count + 1 ) | html %] >+ <span class="count_label">[% patron_messages.filter_by_unread.count + 1 | html %]</span> >+ [% tn('message', 'messages', patron_messages.filter_by_unread.count + 1 ) | html %] > </a> > </li> > [% ELSE %] > <li> > <a href="/cgi-bin/koha/opac-user.pl"> >- <span class="count_label">[% patron_messages.count | html %]</span> >- [% tn('message', 'messages', patron_messages.count ) | html %] >+ <span class="count_label">[% patron_messages.filter_by_unread.count | html %]</span> >+ [% tn('message', 'messages', patron_messages.filter_by_unread.count ) | html %] > </a> > </li> > [% END %] >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >index 37d36399ea..c6ce700486 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt >@@ -1292,6 +1292,10 @@ > $("#addNoteTitle").text(""); > $("#addNote").val(""); > }); >+ >+ $(".dismiss-message-button").click(function(e){ >+ return confirmDelete(_("Are you sure you want to dismiss this message?")); >+ }); > }); > > function submitNote( title, issue_id, note ){ >diff --git a/opac/opac-dismiss-message.pl b/opac/opac-dismiss-message.pl >new file mode 100755 >index 0000000000..84c5906b6a >--- /dev/null >+++ b/opac/opac-dismiss-message.pl >@@ -0,0 +1,54 @@ >+#!/usr/bin/perl >+ >+# Copyright 2023 Aleisha Amohia <aleisha@catalyst.net.nz> >+# >+# 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 <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+use CGI qw ( -utf8 ); >+use C4::Koha; >+use C4::Context; >+use C4::Output qw( output_html_with_http_headers ); >+use C4::Auth qw( get_template_and_user ); >+use Koha::DateUtils qw( dt_from_string ); >+use Koha::Patrons; >+ >+my $query = CGI->new; >+ >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { >+ template_name => "opac-user.tt", >+ query => $query, >+ type => "opac", >+ } >+); >+ >+my $patron_id = $query->param('patron_id'); >+my $patron = Koha::Patrons->find( $patron_id ); >+my $message_id = $query->param('message_id'); >+my $message = $patron->messages->find( $message_id ); >+ >+unless ( $message ) { >+ # exit early >+ print $query->redirect("/cgi-bin/koha/opac-user.pl"); >+ exit; >+} >+ >+$message->update({ patron_read_date => dt_from_string }); >+ >+print $query->redirect("/cgi-bin/koha/opac-user.pl"); >+ >+output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; >-- >2.20.1
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 12029
:
130514
|
130515
|
130516
|
132918
|
132949
|
137434
|
137435
|
137518
|
137519
|
137520
|
137521
|
137522
|
137523
|
137646
|
137647
|
137648
|
146706
|
146707
|
146708
|
146709
|
147521
|
147522
|
147523
|
147524
|
147525
|
148607
|
148608
|
148609
|
148610
|
148611