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

(-)a/C4/Circulation.pm (-2 / +14 lines)
Lines 3908-3915 sub AnonymizeItemIssueHistory { Link Here
3908
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3908
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3909
    );
3909
    );
3910
3910
3911
    my $oi = $old_issues_rs->next();
3911
    my $oi;
3912
    if ( $oi->borrower()->privacy() == 2 ) {
3912
    if ( C4::Context->preference('StoreLastBorrower') ) {
3913
3914
        # If storing last borrower, skip the latest old_issue for this item
3915
        $old_issues_rs->next();
3916
        $oi = $old_issues_rs->next();
3917
    }
3918
    else {
3919
3920
        # If *not* storing last borrower, use the latest old_issue for this item
3921
        $oi = $old_issues_rs->next();
3922
    }
3923
3924
    if ( $oi && $oi->borrower()->privacy() == 2 ) {
3913
        $oi->set_column( 'borrowernumber', $a );
3925
        $oi->set_column( 'borrowernumber', $a );
3914
        $oi->update();
3926
        $oi->update();
3915
    }
3927
    }
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 399-404 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
399
('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'),
399
('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'),
400
('SubfieldsToAllowForRestrictedBatchmod','','Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'),
400
('SubfieldsToAllowForRestrictedBatchmod','','Define a list of subfields for which edition is authorized when items_batchmod_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'),
401
('SubfieldsToAllowForRestrictedEditing','','Define a list of subfields for which edition is authorized when edit_items_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'),
401
('SubfieldsToAllowForRestrictedEditing','','Define a list of subfields for which edition is authorized when edit_items_restricted permission is enabled, separated by spaces. Example: 995\$f 995\$h 995\$j',NULL,'Free'),
402
('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'),
402
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
403
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
403
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
404
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
404
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
405
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+7 lines)
Lines 9895-9900 if(CheckVersion($DBversion)) { Link Here
9895
    SetVersion($DBversion);
9895
    SetVersion($DBversion);
9896
}
9896
}
9897
9897
9898
$DBversion = "3.17.00.XXX";
9899
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
9900
   $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES ('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo')");
9901
9902
   print "Upgrade to $DBversion done (Bug 9011 - Add the ability to store the last patron to return an item)\n";
9903
}
9904
9898
=head1 FUNCTIONS
9905
=head1 FUNCTIONS
9899
9906
9900
=head2 TableExists($table)
9907
=head2 TableExists($table)
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 600-605 OPAC: Link Here
600
                  track: "Track"
600
                  track: "Track"
601
                  no: "Don't track"
601
                  no: "Don't track"
602
            - links that patrons click on
602
            - links that patrons click on
603
        -
604
            - pref: StoreLastBorrower
605
              default: 0
606
              choices:
607
                  yes: Store
608
                  no: "Don't store"
609
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
603
610
604
    Shelf Browser:
611
    Shelf Browser:
605
        -
612
        -
(-)a/t/db_dependent/Circulation_anonymization.t (-3 / +17 lines)
Lines 6-12 use C4::Context; Link Here
6
use C4::Circulation;
6
use C4::Circulation;
7
use Koha::Database;
7
use Koha::Database;
8
8
9
use Test::More tests => 4;
9
use Test::More tests => 6;
10
10
11
BEGIN {
11
BEGIN {
12
    use_ok('C4::Circulation');
12
    use_ok('C4::Circulation');
Lines 132-137 my $userenv = C4::Context->userenv Link Here
132
132
133
#Begin Tests
133
#Begin Tests
134
134
135
C4::Context->set_preference( 'StoreLastBorrower', 0 );
136
135
AddIssue( $borrower_1, 'barcode_1' );
137
AddIssue( $borrower_1, 'barcode_1' );
136
AddReturn('barcode_1');
138
AddReturn('barcode_1');
137
my $old_issue =
139
my $old_issue =
Lines 141-153 ok( $old_issue->borrower()->borrowernumber() == $anonymous_patron->borrowernumbe Link Here
141
143
142
my $next_issue_id = $old_issue->issue_id() + 1;
144
my $next_issue_id = $old_issue->issue_id() + 1;
143
145
144
145
AddIssue( $borrower_2, 'barcode_1' );
146
AddIssue( $borrower_2, 'barcode_1' );
146
AddReturn('barcode_1');
147
AddReturn('barcode_1');
147
$old_issue =
148
$old_issue =
148
  $schema->resultset('OldIssue')->find( $next_issue_id );
149
  $schema->resultset('OldIssue')->find( $next_issue_id );
149
ok( $old_issue->borrower()->borrowernumber() == $borrower2->borrowernumber(), "Patron with privacy of 1 not anonymized" );
150
ok( $old_issue->borrower()->borrowernumber() == $borrower2->borrowernumber(), "Patron with privacy of 1 not anonymized" );
150
151
152
C4::Context->set_preference( 'StoreLastBorrower', 1 );
153
154
$next_issue_id = $old_issue->issue_id() + 1;
155
156
AddIssue( $borrower_1, 'barcode_1' );
157
AddReturn('barcode_1');
158
$old_issue =
159
  $schema->resultset('OldIssue')->find( $next_issue_id );
160
ok( $old_issue->borrower()->borrowernumber() == $borrower1->borrowernumber(), "Patron with privacy of 2 not anonymized with StoreLastBorrower enabled" );
161
AddIssue( $borrower_2, 'barcode_1' );
162
AddReturn('barcode_1');
163
$old_issue =
164
  $schema->resultset('OldIssue')->find( $next_issue_id );
165
ok( $old_issue->borrower()->borrowernumber() == $anonymous_patron->borrowernumber(), "Patron with privacy of 2 anonymized after next return with StoreLastBorrower enabled" );
151
166
152
#End transaction
167
#End transaction
153
$dbh->rollback;
168
$dbh->rollback;
154
- 

Return to bug 9011