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

(-)a/Koha/Patron.pm (+32 lines)
Lines 266-271 sub is_debarred { Link Here
266
    return;
266
    return;
267
}
267
}
268
268
269
=head2 is_expired
270
271
my $is_expired = $patron->is_expired;
272
273
Returns true if the patron is passed the expiry date, false otherwise
274
275
=cut
276
277
sub is_expired {
278
    my ($self) = @_;
279
280
    return 1 if $self->dateexpiry && dt_from_string( $self->dateexpiry ) < dt_from_string;
281
    return 0;
282
}
283
269
=head2 update_password
284
=head2 update_password
270
285
271
my $updated = $patron->update_password( $userid, $password );
286
my $updated = $patron->update_password( $userid, $password );
Lines 449-454 sub add_enrolment_fee_if_needed { Link Here
449
    return $enrolment_fee || 0;
464
    return $enrolment_fee || 0;
450
}
465
}
451
466
467
=head3 should_block_expired_patron_opac_actions
468
469
=cut
470
471
sub should_block_expired_patron_opac_actions {
472
    my ($self) = @_;
473
474
    my $patron_category = Koha::Patron::Categories->find( $self->categorycode );
475
476
    if ( $patron_category->BlockExpiredPatronOpacActions == -1 ) {
477
        return C4::Context->preference('BlockExpiredPatronOpacActions');
478
    }
479
    else {
480
        return $patron_category->BlockExpiredPatronOpacActions;
481
    }
482
}
483
452
=head3 type
484
=head3 type
453
485
454
=cut
486
=cut
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (-5 / +8 lines)
Lines 12-17 Link Here
12
[% INCLUDE 'bodytag.inc' bodyid='opac-user' bodyclass='scrollto' %]
12
[% INCLUDE 'bodytag.inc' bodyid='opac-user' bodyclass='scrollto' %]
13
[% INCLUDE 'masthead.inc' %]
13
[% INCLUDE 'masthead.inc' %]
14
14
15
[% SET BlockExpiredPatronOpacActions = borrower.should_block_expired_patron_opac_actions %]
16
[% SET IsExpired = borrower.is_expired %]
17
15
<div class="main">
18
<div class="main">
16
    <ul class="breadcrumb">
19
    <ul class="breadcrumb">
17
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
20
        <li><a href="/cgi-bin/koha/opac-main.pl">Home</a> <span class="divider">&rsaquo;</span></li>
Lines 156-162 Using this account is not recommended because some parts of Koha will not functi Link Here
156
                                                    <th>Barcode</th>
159
                                                    <th>Barcode</th>
157
                                                [% END %]
160
                                                [% END %]
158
                                                    <th>Call no.</th>
161
                                                    <th>Call no.</th>
159
                                                [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %]
162
                                                [% IF ( OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %]
160
                                                    <th class="nosort">Renew</th>
163
                                                    <th class="nosort">Renew</th>
161
                                                [% END %]
164
                                                [% END %]
162
                                                [% IF ( OPACFinesTab ) %]
165
                                                [% IF ( OPACFinesTab ) %]
Lines 245-251 Using this account is not recommended because some parts of Koha will not functi Link Here
245
                                                    <span class="tdlabel">Call no.:</span>
248
                                                    <span class="tdlabel">Call no.:</span>
246
                                                    [% ISSUE.itemcallnumber %]
249
                                                    [% ISSUE.itemcallnumber %]
247
                                                </td>
250
                                                </td>
248
                                                [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %]
251
                                                [% IF ( OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %]
249
                                                    <td class="renew">
252
                                                    <td class="renew">
250
                                                    [% IF ISSUE.renewed %]<span class="blabel label-success">Renewed!</span><br />[% END %]
253
                                                    [% IF ISSUE.renewed %]<span class="blabel label-success">Renewed!</span><br />[% END %]
251
                                                    [% IF ( ISSUE.status ) %]
254
                                                    [% IF ( ISSUE.status ) %]
Lines 285-296 Using this account is not recommended because some parts of Koha will not functi Link Here
285
                                        [% END # /FOREACH ISSUES %]
288
                                        [% END # /FOREACH ISSUES %]
286
                                    </tbody>
289
                                    </tbody>
287
                                </table>
290
                                </table>
288
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %]
291
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %]
289
                                    <input type="submit" class="btn" value="Renew selected" />
292
                                    <input type="submit" class="btn" value="Renew selected" />
290
                                [% END %]
293
                                [% END %]
291
                                </form>
294
                                </form>
292
295
293
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %]
296
                                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %]
294
                                <form id="renewall" action="/cgi-bin/koha/opac-renew.pl" method="post">
297
                                <form id="renewall" action="/cgi-bin/koha/opac-renew.pl" method="post">
295
                                    <input type="hidden" name="from" value="opac_user" />
298
                                    <input type="hidden" name="from" value="opac_user" />
296
                                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
299
                                    <input type="hidden" name="borrowernumber" value="[% borrowernumber %]" />
Lines 876-882 Using this account is not recommended because some parts of Koha will not functi Link Here
876
                    e.preventDefault();
879
                    e.preventDefault();
877
                    $("#renewall").submit();
880
                    $("#renewall").submit();
878
                });
881
                });
879
                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %]
882
                [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( IsExpired && BlockExpiredPatronOpacActions ) ) %]
880
                    $("#checkoutst caption").append("<div id=\"renewcontrols\"><a id=\"renewselected_link\" href=\"#\">"+_("Renew selected")+"</a> <a id=\"renewall_link\" href=\"#\">"+_("Renew all")+"</a></div>");
883
                    $("#checkoutst caption").append("<div id=\"renewcontrols\"><a id=\"renewselected_link\" href=\"#\">"+_("Renew selected")+"</a> <a id=\"renewall_link\" href=\"#\">"+_("Renew all")+"</a></div>");
881
                [% END %]
884
                [% END %]
882
            [% END %]
885
            [% END %]
(-)a/t/Patron.t (-1 / +21 lines)
Lines 17-30 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 11;
20
use Test::More tests => 13;
21
use Test::Warn;
21
use Test::Warn;
22
use t::lib::Mocks;
22
use t::lib::Mocks;
23
use t::lib::Mocks qw(mock_preference);
23
24
24
BEGIN {
25
BEGIN {
25
    t::lib::Mocks::mock_dbh;
26
    t::lib::Mocks::mock_dbh;
26
    use_ok('Koha::Object');
27
    use_ok('Koha::Object');
27
    use_ok('Koha::Patron');
28
    use_ok('Koha::Patron');
29
    use_ok('Koha::DateUtils');
28
}
30
}
29
31
30
my $object = Koha::Patron->new( { surname => 'Test Patron' } );
32
my $object = Koha::Patron->new( { surname => 'Test Patron' } );
Lines 324-327 subtest 'Set tests' => sub { Link Here
324
    is( $patron->privacy,             '667789',                           'privacy field set ok' );
326
    is( $patron->privacy,             '667789',                           'privacy field set ok' );
325
};
327
};
326
328
329
subtest 'is_expiry tests' => sub {
330
    plan tests => 4;
331
332
    t::lib::Mocks::mock_preference( "dateformat", "iso" );
333
334
    $patron->dateexpiry(undef);
335
    ok( !$patron->is_expired, "Patron is not expired if expiry date is not set" );
336
337
    $patron->dateexpiry("1900-01-01");
338
    ok( $patron->is_expired, "Patron is expired with expiry date 1900-01-01" );
339
340
    $patron->dateexpiry("9999-01-01");
341
    ok( !$patron->is_expired, "Patron is not expired with expiry date 9999-01-01" );
342
343
    $patron->dateexpiry( dt_from_string->ymd );
344
    ok( $patron->is_expired, "Patron is not expired if the expiration date is today's date" );
345
};
346
327
1;
347
1;
(-)a/t/db_dependent/Patrons.t (-2 / +42 lines)
Lines 17-23 Link Here
17
17
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Test::More tests => 17;
20
use Test::More tests => 18;
21
use Test::Warn;
21
use Test::Warn;
22
22
23
use C4::Context;
23
use C4::Context;
Lines 104-107 foreach my $b ( $patrons->as_list() ) { Link Here
104
    is( $b->categorycode(), $categorycode, "Iteration returns a patron object" );
104
    is( $b->categorycode(), $categorycode, "Iteration returns a patron object" );
105
}
105
}
106
106
107
subtest 'should_block_expired_patron_opac_actions tests' => sub {
108
    plan tests => 2;
109
110
    C4::Context->set_preference( "BlockExpiredPatronOpacActions", "TEST" );
111
112
    my $patron_category_syspref = Koha::Patron::Category->new(
113
        {
114
            categorycode                  => 'FollowPref',
115
            BlockExpiredPatronOpacActions => -1,
116
        }
117
    )->store();
118
119
    my $patron_syspref = Koha::Patron->new(
120
        {
121
            surname      => 'Test',
122
            branchcode   => $branchcode,
123
            categorycode => $patron_category_syspref->categorycode,
124
        }
125
    )->store();
126
127
    my $patron_category_table = Koha::Patron::Category->new(
128
        {
129
            categorycode                  => 'FollowTbl',
130
            BlockExpiredPatronOpacActions => 1,
131
        }
132
    )->store();
133
134
    my $patron_table = Koha::Patron->new(
135
        {
136
            surname      => 'Test',
137
            branchcode   => $branchcode,
138
            categorycode => $patron_category_table->categorycode,
139
        }
140
    )->store();
141
142
    is( $patron_syspref->should_block_expired_patron_opac_actions,
143
        "TEST", "Category is following BlockExpiredPatronOpacActions syspref if category column BlockExpiredPatronOpacActions is set to -1" );
144
145
    is( $patron_table->should_block_expired_patron_opac_actions, 1, "Category returns its' own value because it is not set to -1" );
146
};
147
107
1;
148
1;
108
- 

Return to bug 17522