View | Details | Raw Unified | Return to bug 12029
Collapse All | Expand All

(-)a/Koha/Patron/Messages.pm (-17 / +2 lines)
Lines 1-4 Link Here
1
2
package Koha::Patron::Messages;
1
package Koha::Patron::Messages;
3
2
4
# This file is part of Koha.
3
# This file is part of Koha.
Lines 51-63 sub object_class { Link Here
51
    return 'Koha::Patron::Message';
50
    return 'Koha::Patron::Message';
52
}
51
}
53
52
54
=head3 unread
53
=head3 filter_by_unread
55
54
56
    Returns a result set of messages that haven't been marked read by the patron
55
    Returns a result set of messages that haven't been marked read by the patron
57
56
58
=cut
57
=cut
59
58
60
sub unread {
59
sub filter_by_unread {
61
    # return resultset of messages with an undefined patron_read_date
60
    # return resultset of messages with an undefined patron_read_date
62
    my ($self, $params) = @_;
61
    my ($self, $params) = @_;
63
    $params ||= {};
62
    $params ||= {};
Lines 66-83 sub unread { Link Here
66
        %$params,
65
        %$params,
67
    });
66
    });
68
}
67
}
69
70
=head3 unread_count
71
72
    Returns a count of messages that haven't been marked read by the patron
73
74
=cut
75
76
77
sub unread_count {
78
    # return count of unread
79
    my ($self, $params) = @_;
80
    $params ||= {};
81
    return $self->unread(%$params)->count();
82
}
83
1;
68
1;
(-)a/Koha/Schema/Result/Message.pm (-14 lines)
Lines 79-92 the date and time the message was written Link Here
79
79
80
creator of message
80
creator of message
81
81
82
=head2 patron_read_date
83
84
  data_type: 'timestamp'
85
  datetime_undef_if_invalid: 1
86
  is_nullable: 1
87
88
date and time the patron dismissed the message
89
90
=cut
82
=cut
91
83
92
__PACKAGE__->add_columns(
84
__PACKAGE__->add_columns(
Lines 109-120 __PACKAGE__->add_columns( Link Here
109
  },
101
  },
110
  "manager_id",
102
  "manager_id",
111
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
103
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
112
  "patron_read_date",
113
  {
114
    data_type => "timestamp",
115
    datetime_undef_if_invalid => 1,
116
    is_nullable => 1,
117
  },
118
);
104
);
119
105
120
=head1 PRIMARY KEY
106
=head1 PRIMARY KEY
(-)a/installer/data/mysql/atomicupdate/bug_12029.pl (-1 / +1 lines)
Lines 8-14 return { Link Here
8
        my ($dbh, $out) = @$args{qw(dbh out)};
8
        my ($dbh, $out) = @$args{qw(dbh out)};
9
9
10
        # Do you stuffs here
10
        # Do you stuffs here
11
        my $alteration = qq{
11
        my $alteration = q{
12
            ALTER TABLE messages
12
            ALTER TABLE messages
13
            ADD COLUMN `patron_read_date` timestamp NULL DEFAULT NULL
13
            ADD COLUMN `patron_read_date` timestamp NULL DEFAULT NULL
14
            COMMENT 'date and time patron dismissed message'
14
            COMMENT 'date and time patron dismissed message'
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc (-2 / +2 lines)
Lines 1-8 Link Here
1
[% IF patron_messages.unread_count OR opacnote %]
1
[% IF patron_messages.filter_by_unread.count OR opacnote %]
2
    <div class="alert alert-info">
2
    <div class="alert alert-info">
3
        <h3>Messages for you</h3>
3
        <h3>Messages for you</h3>
4
        <ul>
4
        <ul>
5
            [% FOREACH message IN patron_messages.unread %]
5
            [% FOREACH message IN patron_messages.filter_by_unread %]
6
                <li>
6
                <li>
7
                    <strong>[% message.message | html | html_line_break %]</strong><br>
7
                    <strong>[% message.message | html | html_line_break %]</strong><br>
8
                    &nbsp;&nbsp;&nbsp;<em>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) | html %]</em>
8
                    &nbsp;&nbsp;&nbsp;<em>Written on [% message.message_date | $KohaDates %] by [% Branches.GetName(message.branchcode) | html %]</em>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (-3 / +3 lines)
Lines 261-267 Link Here
261
                                            </a>
261
                                            </a>
262
                                        </li>
262
                                        </li>
263
                                    [% END %]
263
                                    [% END %]
264
                                    [% IF patron_messages && patron_messages.unread_count || opacnote %]
264
                                    [% IF patron_messages && patron_messages.filter_by_unread.count || opacnote %]
265
                                        [% IF opacnote %]
265
                                        [% IF opacnote %]
266
                                            <li>
266
                                            <li>
267
                                                <a href="/cgi-bin/koha/opac-user.pl">
267
                                                <a href="/cgi-bin/koha/opac-user.pl">
Lines 272-279 Link Here
272
                                        [% ELSE %]
272
                                        [% ELSE %]
273
                                            <li>
273
                                            <li>
274
                                                <a href="/cgi-bin/koha/opac-user.pl">
274
                                                <a href="/cgi-bin/koha/opac-user.pl">
275
                                                    <span class="count_label">[% patron_messages.unread_count | html %]</span>
275
                                                    <span class="count_label">[% patron_messages.filter_by_unread.count | html %]</span>
276
                                                    [% tn('message', 'messages', patron_messages.unread_count ) | html %]
276
                                                    [% tn('message', 'messages', patron_messages.filter_by_unread.count ) | html %]
277
                                                </a>
277
                                                </a>
278
                                            </li>
278
                                            </li>
279
                                        [% END %]
279
                                        [% END %]
(-)a/opac/dismiss_message.pl (-12 lines)
Lines 1-6 Link Here
1
#!/usr/bin/perl
1
#!/usr/bin/perl
2
# Copyright 2021 AutoParallel Technologies Inc.
2
# Copyright 2021 AutoParallel Technologies Inc.
3
# Copyright 2009 PTFS Inc.
4
#
3
#
5
# This file is part of Koha.
4
# This file is part of Koha.
6
#
5
#
Lines 97-116 my $result; Link Here
97
try {
96
try {
98
    $cgi = CGI->new;
97
    $cgi = CGI->new;
99
    $result = dismiss_patron_message($cgi);
98
    $result = dismiss_patron_message($cgi);
100
101
    # uncomment assignment below if you want to view environment
102
    # $result->{env} = \%ENV;
103
104
105
}
99
}
106
catch {
100
catch {
107
    my ($exception) = $_;
101
    my ($exception) = $_;
108
102
109
    # no warnings qw/once/;
110
    # my $ig = 'Examine variable $exception';
111
    # push @DB::typeahead, 'x $exception';
112
    # $DB::single++;
113
114
    $result->{exception} = $exception;
103
    $result->{exception} = $exception;
115
    $result->{success} = FALSE;
104
    $result->{success} = FALSE;
116
}
105
}
117
- 

Return to bug 12029