From 0c9ed1f161bf780d9b05da55d9bc4f41e7d4e95d Mon Sep 17 00:00:00 2001 From: Hayley Pelham Date: Mon, 4 Apr 2022 01:50:24 +0000 Subject: [PATCH] Bug 12029: (follow-up) Adhering to coding guidelines This is a follow-up patch which (based on comment #19) does the following: 1) Removes newline from top of Koha/Patron/Messages.pm 2) Changes method Koha::Patron::Messages->unread to ->filter_by_unread 3) Removes method Koha::Patron::Messages->unread_count 4) (Will address tests in separate patch) 5) Removes changes to Koha/Schema/Result/Message.pm 6) Changes atomicupdate from qq{} to q{} 7) (Left for RM) 8) Removes extra copyright statement in opac/dismiss_message.pl 9) Removes extra comments from opac/dismiss_message.pl 10) (Left for now) 11) (Left for now) Sponsored-by: Horowhenua Library Trust Signed-off-by: Owen Leonard --- Koha/Patron/Messages.pm | 19 ++----------------- Koha/Schema/Result/Message.pm | 14 -------------- .../data/mysql/atomicupdate/bug_12029.pl | 2 +- .../bootstrap/en/includes/opac-note.inc | 4 ++-- .../bootstrap/en/modules/opac-main.tt | 6 +++--- opac/dismiss_message.pl | 11 ----------- 6 files changed, 8 insertions(+), 48 deletions(-) diff --git a/Koha/Patron/Messages.pm b/Koha/Patron/Messages.pm index c9cf646d59..d0acf6bceb 100644 --- a/Koha/Patron/Messages.pm +++ b/Koha/Patron/Messages.pm @@ -1,4 +1,3 @@ - package Koha::Patron::Messages; # This file is part of Koha. @@ -51,13 +50,13 @@ sub object_class { return 'Koha::Patron::Message'; } -=head3 unread +=head3 filter_by_unread Returns a result set of messages that haven't been marked read by the patron =cut -sub unread { +sub filter_by_unread { # return resultset of messages with an undefined patron_read_date my ($self, $params) = @_; $params ||= {}; @@ -66,18 +65,4 @@ sub unread { %$params, }); } - -=head3 unread_count - - Returns a count of messages that haven't been marked read by the patron - -=cut - - -sub unread_count { - # return count of unread - my ($self, $params) = @_; - $params ||= {}; - return $self->unread(%$params)->count(); -} 1; diff --git a/Koha/Schema/Result/Message.pm b/Koha/Schema/Result/Message.pm index 1779e89ed6..1ed5b0e16c 100644 --- a/Koha/Schema/Result/Message.pm +++ b/Koha/Schema/Result/Message.pm @@ -79,14 +79,6 @@ the date and time the message was written creator of message -=head2 patron_read_date - - data_type: 'timestamp' - datetime_undef_if_invalid: 1 - is_nullable: 1 - -date and time the patron dismissed the message - =cut __PACKAGE__->add_columns( @@ -109,12 +101,6 @@ __PACKAGE__->add_columns( }, "manager_id", { data_type => "integer", is_foreign_key => 1, is_nullable => 1 }, - "patron_read_date", - { - data_type => "timestamp", - datetime_undef_if_invalid => 1, - is_nullable => 1, - }, ); =head1 PRIMARY KEY diff --git a/installer/data/mysql/atomicupdate/bug_12029.pl b/installer/data/mysql/atomicupdate/bug_12029.pl index f352a66edf..5637d6b658 100755 --- a/installer/data/mysql/atomicupdate/bug_12029.pl +++ b/installer/data/mysql/atomicupdate/bug_12029.pl @@ -8,7 +8,7 @@ return { my ($dbh, $out) = @$args{qw(dbh out)}; # Do you stuffs here - my $alteration = qq{ + my $alteration = q{ ALTER TABLE messages ADD COLUMN `patron_read_date` timestamp NULL DEFAULT NULL COMMENT 'date and time patron dismissed message' 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 8b2c39f861..bae94785ea 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc +++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc @@ -1,8 +1,8 @@ -[% IF patron_messages.unread_count OR opacnote %] +[% IF patron_messages.filter_by_unread.count OR opacnote %]

Messages for you

    - [% FOREACH message IN patron_messages.unread %] + [% FOREACH message IN patron_messages.filter_by_unread %]
  • [% message.message | html | html_line_break %]
       Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) | html %] 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 ccf6909565..0e6f757da7 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt +++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt @@ -261,7 +261,7 @@
  • [% END %] - [% IF patron_messages && patron_messages.unread_count || opacnote %] + [% IF patron_messages && patron_messages.filter_by_unread.count || opacnote %] [% IF opacnote %]
  • @@ -272,8 +272,8 @@ [% ELSE %]
  • - [% patron_messages.unread_count | html %] - [% tn('message', 'messages', patron_messages.unread_count ) | html %] + [% patron_messages.filter_by_unread.count | html %] + [% tn('message', 'messages', patron_messages.filter_by_unread.count ) | html %]
  • [% END %] diff --git a/opac/dismiss_message.pl b/opac/dismiss_message.pl index 3096e7c7f2..0bda2b3289 100755 --- a/opac/dismiss_message.pl +++ b/opac/dismiss_message.pl @@ -1,6 +1,5 @@ #!/usr/bin/perl # Copyright 2021 AutoParallel Technologies Inc. -# Copyright 2009 PTFS Inc. # # This file is part of Koha. # @@ -97,20 +96,10 @@ my $result; try { $cgi = CGI->new; $result = dismiss_patron_message($cgi); - - # uncomment assignment below if you want to view environment - # $result->{env} = \%ENV; - - } catch { my ($exception) = $_; - # no warnings qw/once/; - # my $ig = 'Examine variable $exception'; - # push @DB::typeahead, 'x $exception'; - # $DB::single++; - $result->{exception} = $exception; $result->{success} = FALSE; } -- 2.20.1