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 1625-1630 sub extended_attributes { Link Here
1625
    return Koha::Patron::Attributes->_new_from_dbic($rs)->search;
1626
    return Koha::Patron::Attributes->_new_from_dbic($rs)->search;
1626
}
1627
}
1627
1628
1629
=head3 messages
1630
1631
    my $messages = $patron->messages;
1632
1633
Return the message attached to the patron.
1634
1635
=cut
1636
1637
sub messages {
1638
    my ( $self ) = @_;
1639
    my $messages_rs = $self->_result->messages_borrowernumbers->search;
1640
    return Koha::Patron::Messages->_new_from_dbic($messages_rs);
1641
}
1642
1628
=head3 lock
1643
=head3 lock
1629
1644
1630
    Koha::Patrons->find($id)->lock({ expire => 1, remove => 1 });
1645
    Koha::Patrons->find($id)->lock({ expire => 1, remove => 1 });
(-)a/circ/circulation.pl (-6 / +3 lines)
Lines 50-56 use Koha::Plugins; Link Here
50
use Koha::Database;
50
use Koha::Database;
51
use Koha::BiblioFrameworks;
51
use Koha::BiblioFrameworks;
52
use Koha::Items;
52
use Koha::Items;
53
use Koha::Patron::Messages;
54
use Koha::SearchEngine;
53
use Koha::SearchEngine;
55
use Koha::SearchEngine::Search;
54
use Koha::SearchEngine::Search;
56
use Koha::Patron::Modifications;
55
use Koha::Patron::Modifications;
Lines 522-531 if ( $patron ) { Link Here
522
    }
521
    }
523
}
522
}
524
523
525
my $patron_messages = Koha::Patron::Messages->search(
524
my $patron_messages = $patron->messages->search(
526
    {
525
    {},
527
        'me.borrowernumber' => $borrowernumber,
528
    },
529
    {
526
    {
530
       join => 'manager',
527
       join => 'manager',
531
       '+select' => ['manager.surname', 'manager.firstname' ],
528
       '+select' => ['manager.surname', 'manager.firstname' ],
Lines 578-584 if ($restoreduedatespec || $stickyduedate) { Link Here
578
}
575
}
579
576
580
$template->param(
577
$template->param(
581
    patron_messages           => $patron_messages,
578
    patron_messages   => $patron_messages,
582
    borrowernumber    => $borrowernumber,
579
    borrowernumber    => $borrowernumber,
583
    branch            => $branch,
580
    branch            => $branch,
584
    was_renewed       => scalar $query->param('was_renewed') ? 1 : 0,
581
    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 => 10;
22
use Test::More tests => 11;
23
use Test::Exception;
23
use Test::Exception;
24
use Test::Warn;
24
use Test::Warn;
25
25
Lines 846-848 subtest 'article_requests() tests' => sub { Link Here
846
846
847
    $schema->storage->txn_rollback;
847
    $schema->storage->txn_rollback;
848
};
848
};
849
- 
849
850
subtest 'messages' => sub {
851
    plan tests => 4;
852
853
    $schema->storage->txn_begin;
854
855
    my $patron = $builder->build_object( { class => 'Koha::Patrons' } );
856
    my $messages = $patron->messages;
857
    is( $messages->count, 0, "No message yet" );
858
    my $message_1 = $builder->build_object(
859
        {
860
            class => 'Koha::Patron::Messages',
861
            value => { borrowernumber => $patron->borrowernumber }
862
        }
863
    );
864
    my $message_2 = $builder->build_object(
865
        {
866
            class => 'Koha::Patron::Messages',
867
            value => { borrowernumber => $patron->borrowernumber }
868
        }
869
    );
870
871
    $messages = $patron->messages;
872
    is( $messages->count, 2, "There are two messages for this patron" );
873
    is( $messages->next->message, $message_1->message );
874
    is( $messages->next->message, $message_2->message );
875
876
    $schema->storage->txn_rollback;
877
};

Return to bug 29230