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 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 => 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