From 846cf1fa7e2da49d343af56e65424c6df5335f9e Mon Sep 17 00:00:00 2001 From: Aleisha Amohia 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 @@ ( [% patron_message.get_column('manager_firstname') | html %] [% patron_message.get_column('manager_surname') | html %] ) [% END %] "[% patron_message.message | html %]" + [% IF patron_message.patron_read_date %] + Read: [% patron_message.patron_read_date | $KohaDates %] + [% END %] [% 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 %]

Messages for you