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

(-)a/C4/Circulation.pm (-2 / +14 lines)
Lines 3927-3934 sub AnonymizeItemIssueHistory { Link Here
3927
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3927
        { prefetch => 'borrower', order_by => { -desc => 'issue_id' } }
3928
    );
3928
    );
3929
3929
3930
    my $oi = $old_issues_rs->next();
3930
    my $oi;
3931
    if ( $oi->borrower()->privacy() == 2 ) {
3931
    if ( C4::Context->preference('StoreLastBorrower') ) {
3932
3933
        # If storing last borrower, skip the latest old_issue for this item
3934
        $old_issues_rs->next();
3935
        $oi = $old_issues_rs->next();
3936
    }
3937
    else {
3938
3939
        # If *not* storing last borrower, use the latest old_issue for this item
3940
        $oi = $old_issues_rs->next();
3941
    }
3942
3943
    if ( $oi && $oi->borrower()->privacy() == 2 ) {
3932
        $oi->set_column( 'borrowernumber', $a );
3944
        $oi->set_column( 'borrowernumber', $a );
3933
        $oi->update();
3945
        $oi->update();
3934
    }
3946
    }
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 400-405 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
400
('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'),
400
('StatisticsFields','location|itype|ccode', NULL, 'Define Fields (from the items table) used for statistics members','Free'),
401
('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
('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'),
402
('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
('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'),
403
('StoreLastBorrower','0','','If ON, the last borrower to return an item will be stored in items.last_returned_by','YesNo'),
403
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
404
('SubfieldsToUseWhenPrefill','','','Define a list of subfields to use when prefilling items (separated by space)','Free'),
404
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
405
('SubscriptionDuplicateDroppedInput','','','List of fields which must not be rewritten when a subscription is duplicated (Separated by pipe |)','Free'),
405
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
406
('SubscriptionHistory','simplified','simplified|full','Define the display preference for serials issue history in OPAC','Choice'),
(-)a/installer/data/mysql/updatedatabase.pl (+8 lines)
Lines 10192-10197 if ( CheckVersion($DBversion) ) { Link Here
10192
    SetVersion($DBversion);
10192
    SetVersion($DBversion);
10193
}
10193
}
10194
10194
10195
$DBversion = "3.17.00.XXX";
10196
if (C4::Context->preference("Version") < TransformToNum($DBversion)) {
10197
   $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')");
10198
10199
   print "Upgrade to $DBversion done (Bug 9011 - Add the ability to store the last patron to return an item)\n";
10200
   SetVersion($DBversion);
10201
}
10202
10195
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10203
# DEVELOPER PROCESS, search for anything to execute in the db_update directory
10196
# SEE bug 13068
10204
# SEE bug 13068
10197
# if there is anything in the atomicupdate, read and execute it.
10205
# if there is anything in the atomicupdate, read and execute it.
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 594-599 OPAC: Link Here
594
                  track: "Track"
594
                  track: "Track"
595
                  no: "Don't track"
595
                  no: "Don't track"
596
            - links that patrons click on
596
            - links that patrons click on
597
        -
598
            - pref: StoreLastBorrower
599
              default: 0
600
              choices:
601
                  yes: Store
602
                  no: "Don't store"
603
            - the last patron to return an item. This setting is independent of opacreadinghistory/AnonymousPatron.
597
604
598
    Shelf Browser:
605
    Shelf Browser:
599
        -
606
        -
(-)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