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

(-)a/Koha/Patron/Messages.pm (+23 lines)
Lines 34-39 Koha::Patron::Messages - Koha Message Object set class Link Here
34
34
35
=cut
35
=cut
36
36
37
=head3 filter_by_unread
38
39
    Returns a resultset of messages that have not been marked read by the patron
40
41
=cut
42
43
sub filter_by_unread {
44
    my ( $self, $params ) = @_;
45
46
    $params ||= {};
47
48
    return $self->search(
49
        {
50
            patron_read_date => { is => undef },
51
            %$params,
52
        }
53
    );
54
}
55
37
=head3 _type
56
=head3 _type
38
57
39
=cut
58
=cut
Lines 42-47 sub _type { Link Here
42
    return 'Message';
61
    return 'Message';
43
}
62
}
44
63
64
=head3 object_class
65
66
=cut
67
45
sub object_class {
68
sub object_class {
46
    return 'Koha::Patron::Message';
69
    return 'Koha::Patron::Message';
47
}
70
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron_messages.inc (+3 lines)
Lines 308-313 Link Here
308
                            ( <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> )
308
                            ( <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> )
309
                        [% END %]
309
                        [% END %]
310
                        <em>"[% patron_message.message | html %]"</em>
310
                        <em>"[% patron_message.message | html %]"</em>
311
                        [% IF patron_message.patron_read_date %]
312
                            Read: <em>[% patron_message.patron_read_date | $KohaDates %]</em>
313
                        [% END %]
311
                    </span>
314
                    </span>
312
                    [% IF patron_message.branchcode == Branches.GetLoggedInBranchcode OR Koha.Preference('AllowAllMessageDeletion') %]
315
                    [% IF patron_message.branchcode == Branches.GetLoggedInBranchcode OR Koha.Preference('AllowAllMessageDeletion') %]
313
                        [% IF moremember %]
316
                        [% IF moremember %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/opac-note.inc (-2 / +7 lines)
Lines 1-12 Link Here
1
[% IF patron_messages.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 %]
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>
9
                </li>
9
                </li>
10
                <form id="dismiss-message-form" action="/cgi-bin/koha/opac-dismiss-message.pl" method="post">
11
                    <input type="hidden" name="message_id" value="[% message.message_id | html %]">
12
                    <input type="hidden" name="patron_id" value="[% message.borrowernumber | html %]">
13
                    <button type="submit" class="dismiss-message-button btn btn-primary"><i class="fa fa-trash" aria-hidden="true"></i> Dismiss</button>
14
                </form>
10
            [% END %]
15
            [% END %]
11
16
12
            [% IF ( opacnote ) %]<li>[% opacnote | html | html_line_break %]</li>[% END %]
17
            [% IF ( opacnote ) %]<li>[% opacnote | html | html_line_break %]</li>[% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-main.tt (-5 / +5 lines)
Lines 283-301 Link Here
283
                                            </a>
283
                                            </a>
284
                                        </li>
284
                                        </li>
285
                                    [% END %]
285
                                    [% END %]
286
                                    [% IF patron_messages && patron_messages.count > 0 || opacnote %]
286
                                    [% IF patron_messages && patron_messages.filter_by_unread.count > 0 || opacnote %]
287
                                        [% IF opacnote %]
287
                                        [% IF opacnote %]
288
                                            <li>
288
                                            <li>
289
                                                <a href="/cgi-bin/koha/opac-user.pl">
289
                                                <a href="/cgi-bin/koha/opac-user.pl">
290
                                                    <span class="count_label">[% patron_messages.count + 1 | html %]</span>
290
                                                    <span class="count_label">[% patron_messages.filter_by_unread.count + 1 | html %]</span>
291
                                                    [% tn('message', 'messages', patron_messages.count + 1 ) | html %]
291
                                                    [% tn('message', 'messages', patron_messages.filter_by_unread.count + 1 ) | html %]
292
                                                </a>
292
                                                </a>
293
                                            </li>
293
                                            </li>
294
                                        [% ELSE %]
294
                                        [% ELSE %]
295
                                            <li>
295
                                            <li>
296
                                                <a href="/cgi-bin/koha/opac-user.pl">
296
                                                <a href="/cgi-bin/koha/opac-user.pl">
297
                                                    <span class="count_label">[% patron_messages.count | html %]</span>
297
                                                    <span class="count_label">[% patron_messages.filter_by_unread.count | html %]</span>
298
                                                    [% tn('message', 'messages', patron_messages.count ) | html %]
298
                                                    [% tn('message', 'messages', patron_messages.filter_by_unread.count ) | html %]
299
                                                </a>
299
                                                </a>
300
                                            </li>
300
                                            </li>
301
                                        [% END %]
301
                                        [% END %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+4 lines)
Lines 1292-1297 Link Here
1292
                $("#addNoteTitle").text("");
1292
                $("#addNoteTitle").text("");
1293
                $("#addNote").val("");
1293
                $("#addNote").val("");
1294
            });
1294
            });
1295
1296
            $(".dismiss-message-button").click(function(e){
1297
                return confirmDelete(_("Are you sure you want to dismiss this message?"));
1298
            });
1295
        });
1299
        });
1296
1300
1297
        function submitNote( title, issue_id, note ){
1301
        function submitNote( title, issue_id, note ){
(-)a/opac/opac-dismiss-message.pl (-1 / +54 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2023 Aleisha Amohia <aleisha@catalyst.net.nz>
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
use CGI qw ( -utf8 );
22
use C4::Koha;
23
use C4::Context;
24
use C4::Output qw( output_html_with_http_headers );
25
use C4::Auth qw( get_template_and_user );
26
use Koha::DateUtils qw( dt_from_string );
27
use Koha::Patrons;
28
29
my $query = CGI->new;
30
31
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32
    {
33
        template_name   => "opac-user.tt",
34
        query           => $query,
35
        type            => "opac",
36
    }
37
);
38
39
my $patron_id = $query->param('patron_id');
40
my $patron = Koha::Patrons->find( $patron_id );
41
my $message_id = $query->param('message_id');
42
my $message = $patron->messages->find( $message_id );
43
44
unless ( $message ) {
45
    # exit early
46
    print $query->redirect("/cgi-bin/koha/opac-user.pl");
47
    exit;
48
}
49
50
$message->update({ patron_read_date => dt_from_string });
51
52
print $query->redirect("/cgi-bin/koha/opac-user.pl");
53
54
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };

Return to bug 12029