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

(-)a/C4/Auth.pm (-2 / +1 lines)
Lines 238-249 sub get_template_and_user { Link Here
238
    }
238
    }
239
239
240
    my $borrowernumber;
240
    my $borrowernumber;
241
    my $patron;
242
    if ($user) {
241
    if ($user) {
243
242
244
        # It's possible for $user to be the borrowernumber if they don't have a
243
        # It's possible for $user to be the borrowernumber if they don't have a
245
        # userid defined (and are logging in through some other method, such
244
        # userid defined (and are logging in through some other method, such
246
        # as SSL certs against an email address)
245
        # as SSL certs against an email address)
246
        my $patron;
247
        $borrowernumber = getborrowernumber($user) if defined($user);
247
        $borrowernumber = getborrowernumber($user) if defined($user);
248
        if ( !defined($borrowernumber) && defined($user) ) {
248
        if ( !defined($borrowernumber) && defined($user) ) {
249
            $patron = Koha::Patrons->find( $user );
249
            $patron = Koha::Patrons->find( $user );
Lines 610-616 sub get_template_and_user { Link Here
610
            PatronSelfRegistration                => C4::Context->preference("PatronSelfRegistration"),
610
            PatronSelfRegistration                => C4::Context->preference("PatronSelfRegistration"),
611
            PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
611
            PatronSelfRegistrationDefaultCategory => C4::Context->preference("PatronSelfRegistrationDefaultCategory"),
612
            useDischarge                 => C4::Context->preference('useDischarge'),
612
            useDischarge                 => C4::Context->preference('useDischarge'),
613
            routing_lists_exist                   => ( $patron and $patron->get_routinglists ),
614
        );
613
        );
615
614
616
        $template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") );
615
        $template->param( OpacPublic => '1' ) if ( $user || C4::Context->preference("OpacPublic") );
(-)a/Koha/Patron.pm (-5 / +5 lines)
Lines 589-606 sub get_overdues { Link Here
589
    );
589
    );
590
}
590
}
591
591
592
=head3 get_routinglists
592
=head3 get_routing_lists
593
593
594
my @routinglists = $patron->get_routinglists
594
my @routinglists = $patron->get_routing_lists
595
595
596
Returns the routing lists a patron is subscribed to.
596
Returns the routing lists a patron is subscribed to.
597
597
598
=cut
598
=cut
599
599
600
sub get_routinglists {
600
sub get_routing_lists {
601
    my ($self) = @_;
601
    my ($self) = @_;
602
    my @subscribed_routings = Koha::Subscription::Routinglists->search({ borrowernumber => $self->borrowernumber });
602
    my $routing_list_rs = $self->_result->subscriptionroutinglists;
603
    return @subscribed_routings;
603
    return Koha::Subscription::Routinglists->_new_from_dbic($routing_list_rs);
604
}
604
}
605
605
606
=head3 get_age
606
=head3 get_age
(-)a/Koha/Subscription/Routinglist.pm (-1 / +1 lines)
Lines 45-51 Returns the subscription for a routing list. Link Here
45
45
46
sub subscription {
46
sub subscription {
47
    my ( $self ) = @_;
47
    my ( $self ) = @_;
48
    return scalar Koha::Subscriptions->find( $self->subscriptionid );
48
    return Koha::Subscription->_new_from_dbic($self->_result->subscriptionid);
49
}
49
}
50
50
51
=head2 Internal methods
51
=head2 Internal methods
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/includes/usermenu.inc (-1 / +1 lines)
Lines 96-102 Link Here
96
                <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1">your lists</a></li>
96
                <a href="/cgi-bin/koha/opac-shelves.pl?op=list&amp;category=1">your lists</a></li>
97
            [% END %]
97
            [% END %]
98
98
99
            [% IF Koha.Preference( 'RoutingSerials' ) && routing_lists_exist %]
99
            [% IF Koha.Preference( 'RoutingSerials' ) && logged_in_user && logged_in_user.get_routing_lists.count %]
100
                [% IF ( routinglistsview ) %]
100
                [% IF ( routinglistsview ) %]
101
                    <li class="active">
101
                    <li class="active">
102
                [% ELSE %]
102
                [% ELSE %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-routing-lists.tt (-1 / +2 lines)
Lines 32-38 Link Here
32
32
33
                    <h3>Routing lists</h3>
33
                    <h3>Routing lists</h3>
34
34
35
                    [% IF ( routinglists ) %]
35
                    [% SET routinglists = logged_in_user.get_routing_lists %]
36
                    [% IF ( routinglists.count ) %]
36
                        <p id="routing-list-intro">You are subscribed to the routing lists for following serial titles. If you wish to make changes, please contact the library.</p>
37
                        <p id="routing-list-intro">You are subscribed to the routing lists for following serial titles. If you wish to make changes, please contact the library.</p>
37
38
38
                        <table class="table table-bordered table-striped" id="routingtable">
39
                        <table class="table table-bordered table-striped" id="routingtable">
(-)a/opac/opac-routing-lists.pl (-4 / +1 lines)
Lines 41-51 $borrower->{description} = $category->description; Link Here
41
$borrower->{category_type} = $category->category_type;
41
$borrower->{category_type} = $category->category_type;
42
$template->param( BORROWER_INFO => $borrower );
42
$template->param( BORROWER_INFO => $borrower );
43
43
44
my @routinglists = $patron->get_routinglists();
45
46
$template->param(
44
$template->param(
47
    routinglists  => \@routinglists,
45
    routinglistsview => 1,
48
    routinglistview => 1,
49
);
46
);
50
47
51
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
48
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/t/db_dependent/Koha/Patrons.t (-7 / +6 lines)
Lines 529-535 subtest 'checkouts + pending_checkouts + get_overdues + old_checkouts' => sub { Link Here
529
    $module->unmock('userenv');
529
    $module->unmock('userenv');
530
};
530
};
531
531
532
subtest 'get_routinglists' => sub {
532
subtest 'get_routing_lists' => sub {
533
    plan tests => 5;
533
    plan tests => 5;
534
534
535
    my $biblio = Koha::Biblio->new()->store();
535
    my $biblio = Koha::Biblio->new()->store();
Lines 541-547 subtest 'get_routinglists' => sub { Link Here
541
    my $patron = $builder->build( { source => 'Borrower' } );
541
    my $patron = $builder->build( { source => 'Borrower' } );
542
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
542
    $patron = Koha::Patrons->find( $patron->{borrowernumber} );
543
543
544
    is( $patron->get_routinglists, 0, 'Retrieves correct number of routing lists: 0' );
544
    is( $patron->get_routing_lists->count, 0, 'Retrieves correct number of routing lists: 0' );
545
545
546
    my $routinglist_count = Koha::Subscription::Routinglists->count;
546
    my $routinglist_count = Koha::Subscription::Routinglists->count;
547
    my $routinglist = Koha::Subscription::Routinglist->new({
547
    my $routinglist = Koha::Subscription::Routinglist->new({
Lines 550-560 subtest 'get_routinglists' => sub { Link Here
550
        subscriptionid   => $subscription->subscriptionid
550
        subscriptionid   => $subscription->subscriptionid
551
    })->store;
551
    })->store;
552
552
553
    is ($patron->get_routinglists, 1, "Retrieves correct number of routing lists: 1");
553
    is ($patron->get_routing_lists->count, 1, "Retrieves correct number of routing lists: 1");
554
554
555
    my @routinglists = $patron->get_routinglists;
555
    my @routinglists = $patron->get_routing_lists;
556
    is ($routinglists[0]->ranking, 5, "Retrieves ranking: 5");
556
    is ($routinglists[0]->ranking, 5, "Retrieves ranking: 5");
557
    is( ref($routinglists[0]),   'Koha::Subscription::Routinglist', 'get_routinglists returns Koha::Subscription::Routinglist objects' );
557
    is( ref($routinglists[0]),   'Koha::Subscription::Routinglist', 'get_routing_lists returns Koha::Subscription::Routinglist objects' );
558
558
559
    my $subscription2 = Koha::Subscription->new({
559
    my $subscription2 = Koha::Subscription->new({
560
        biblionumber => $biblio->biblionumber,
560
        biblionumber => $biblio->biblionumber,
Lines 566-572 subtest 'get_routinglists' => sub { Link Here
566
        subscriptionid   => $subscription2->subscriptionid
566
        subscriptionid   => $subscription2->subscriptionid
567
    })->store;
567
    })->store;
568
568
569
    is ($patron->get_routinglists, 2, "Retrieves correct number of routing lists: 2");
569
    is ($patron->get_routing_lists->count, 2, "Retrieves correct number of routing lists: 2");
570
570
571
    $patron->delete; # Clean up for later tests
571
    $patron->delete; # Clean up for later tests
572
572
573
- 

Return to bug 20400