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

(-)a/Koha/Patron.pm (+15 lines)
Lines 44-49 use Koha::Patron::Debarments; Link Here
44
use Koha::Patron::HouseboundProfile;
44
use Koha::Patron::HouseboundProfile;
45
use Koha::Patron::HouseboundRole;
45
use Koha::Patron::HouseboundRole;
46
use Koha::Patron::Images;
46
use Koha::Patron::Images;
47
use Koha::Patron::Messages;
47
use Koha::Patron::Modifications;
48
use Koha::Patron::Modifications;
48
use Koha::Patron::Relationships;
49
use Koha::Patron::Relationships;
49
use Koha::Patrons;
50
use Koha::Patrons;
Lines 1710-1715 sub extended_attributes { Link Here
1710
    return Koha::Patron::Attributes->_new_from_dbic($rs)->search;
1711
    return Koha::Patron::Attributes->_new_from_dbic($rs)->search;
1711
}
1712
}
1712
1713
1714
=head3 messages
1715
1716
    my $messages = $patron->messages;
1717
1718
Return the message attached to the patron.
1719
1720
=cut
1721
1722
sub messages {
1723
    my ( $self ) = @_;
1724
    my $messages_rs = $self->_result->messages_borrowernumbers->search;
1725
    return Koha::Patron::Messages->_new_from_dbic($messages_rs);
1726
}
1727
1713
=head3 lock
1728
=head3 lock
1714
1729
1715
    Koha::Patrons->find($id)->lock({ expire => 1, remove => 1 });
1730
    Koha::Patrons->find($id)->lock({ expire => 1, remove => 1 });
(-)a/circ/circulation.pl (-6 / +3 lines)
Lines 51-57 use Koha::Plugins; Link Here
51
use Koha::Database;
51
use Koha::Database;
52
use Koha::BiblioFrameworks;
52
use Koha::BiblioFrameworks;
53
use Koha::Items;
53
use Koha::Items;
54
use Koha::Patron::Messages;
55
use Koha::SearchEngine;
54
use Koha::SearchEngine;
56
use Koha::SearchEngine::Search;
55
use Koha::SearchEngine::Search;
57
use Koha::Patron::Modifications;
56
use Koha::Patron::Modifications;
Lines 523-532 if ( $patron ) { Link Here
523
    }
522
    }
524
}
523
}
525
524
526
my $patron_messages = Koha::Patron::Messages->search(
525
my $patron_messages = $patron->messages->search(
527
    {
526
    {},
528
        'me.borrowernumber' => $borrowernumber,
529
    },
530
    {
527
    {
531
       join => 'manager',
528
       join => 'manager',
532
       '+select' => ['manager.surname', 'manager.firstname' ],
529
       '+select' => ['manager.surname', 'manager.firstname' ],
Lines 579-585 if ($restoreduedatespec || $stickyduedate) { Link Here
579
}
576
}
580
577
581
$template->param(
578
$template->param(
582
    patron_messages           => $patron_messages,
579
    patron_messages   => $patron_messages,
583
    borrowernumber    => $borrowernumber,
580
    borrowernumber    => $borrowernumber,
584
    branch            => $branch,
581
    branch            => $branch,
585
    was_renewed       => scalar $query->param('was_renewed') ? 1 : 0,
582
    was_renewed       => scalar $query->param('was_renewed') ? 1 : 0,
(-)a/t/db_dependent/Koha/Patron.t (-2 / +30 lines)
Lines 19-25 Link Here
19
19
20
use Modern::Perl;
20
use Modern::Perl;
21
21
22
use Test::More tests => 13;
22
use Test::More tests => 14;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 1021-1023 subtest 'add_article_request_fee_if_needed() tests' => sub { Link Here
1021
1021
1022
    $schema->storage->txn_rollback;
1022
    $schema->storage->txn_rollback;
1023
};
1023
};
1024
- 
1024
1025
subtest 'messages' => sub {
1026
    plan tests => 4;
1027
1028
    $schema->storage->txn_begin;
1029
1030
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
1031
    my $messages = $patron->messages;
1032
    is( $messages->count, 0, "No message yet" );
1033
    my $message_1 = $builder->build_object(
1034
        {
1035
            class => 'Koha::Patron::Messages',
1036
            value => { borrowernumber => $patron->borrowernumber }
1037
        }
1038
    );
1039
    my $message_2 = $builder->build_object(
1040
        {
1041
            class => 'Koha::Patron::Messages',
1042
            value => { borrowernumber => $patron->borrowernumber }
1043
        }
1044
    );
1045
1046
    $messages = $patron->messages;
1047
    is( $messages->count, 2, "There are two messages for this patron" );
1048
    is( $messages->next->message, $message_1->message );
1049
    is( $messages->next->message, $message_2->message );
1050
1051
    $schema->storage->txn_rollback;
1052
};

Return to bug 29230