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

(-)a/C4/Circulation.pm (-3 / +5 lines)
Lines 1967-1972 sub MarkIssueReturned { Link Here
1967
    if ( $privacy == 2) {
1967
    if ( $privacy == 2) {
1968
        # The default of 0 does not work due to foreign key constraints
1968
        # The default of 0 does not work due to foreign key constraints
1969
        # The anonymisation will fail quietly if AnonymousPatron is not a valid entry
1969
        # The anonymisation will fail quietly if AnonymousPatron is not a valid entry
1970
        # FIXME the above is unacceptable - bug 9942 relates
1970
        my $anonymouspatron = (C4::Context->preference('AnonymousPatron')) ? C4::Context->preference('AnonymousPatron') : 0;
1971
        my $anonymouspatron = (C4::Context->preference('AnonymousPatron')) ? C4::Context->preference('AnonymousPatron') : 0;
1971
        my $sth_ano = $dbh->prepare("UPDATE old_issues SET borrowernumber=?
1972
        my $sth_ano = $dbh->prepare("UPDATE old_issues SET borrowernumber=?
1972
                                  WHERE borrowernumber = ?
1973
                                  WHERE borrowernumber = ?
Lines 2821-2827 sub DeleteTransfer { Link Here
2821
2822
2822
=head2 AnonymiseIssueHistory
2823
=head2 AnonymiseIssueHistory
2823
2824
2824
  $rows = AnonymiseIssueHistory($date,$borrowernumber)
2825
  ($rows,$err_history_not_deleted) = AnonymiseIssueHistory($date,$borrowernumber)
2825
2826
2826
This function write NULL instead of C<$borrowernumber> given on input arg into the table issues.
2827
This function write NULL instead of C<$borrowernumber> given on input arg into the table issues.
2827
if C<$borrowernumber> is not set, it will delete the issue history for all borrower older than C<$date>.
2828
if C<$borrowernumber> is not set, it will delete the issue history for all borrower older than C<$date>.
Lines 2829-2835 if C<$borrowernumber> is not set, it will delete the issue history for all borro Link Here
2829
If c<$borrowernumber> is set, it will delete issue history for only that borrower, regardless of their opac privacy
2830
If c<$borrowernumber> is set, it will delete issue history for only that borrower, regardless of their opac privacy
2830
setting (force delete).
2831
setting (force delete).
2831
2832
2832
return the number of affected rows.
2833
return the number of affected rows and a value that evaluates to true if an error occurred deleting the history.
2833
2834
2834
=cut
2835
=cut
2835
2836
Lines 2856-2863 sub AnonymiseIssueHistory { Link Here
2856
    }
2857
    }
2857
    my $sth = $dbh->prepare($query);
2858
    my $sth = $dbh->prepare($query);
2858
    $sth->execute(@bind_params);
2859
    $sth->execute(@bind_params);
2860
    my $anonymisation_err = $dbh->err;
2859
    my $rows_affected = $sth->rows;  ### doublecheck row count return function
2861
    my $rows_affected = $sth->rows;  ### doublecheck row count return function
2860
    return $rows_affected;
2862
    return ($rows_affected, $anonymisation_err);
2861
}
2863
}
2862
2864
2863
=head2 SendCirculationAlert
2865
=head2 SendCirculationAlert
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt (-1 / +3 lines)
Lines 13-21 Link Here
13
13
14
    [% IF ( deleted ) %]
14
    [% IF ( deleted ) %]
15
        <div class="dialog message">Your reading history has been deleted.</div>
15
        <div class="dialog message">Your reading history has been deleted.</div>
16
    [% ELSIF ( err_history_not_deleted ) %]
17
        <div class="dialog error">The deletion of your reading history failed, because there is a problem with the configuration of this feature. Please help to fix the system by informing your library of this error.</div>
16
    [% END %]
18
    [% END %]
17
    [% IF ( privacy_updated ) %]
19
    [% IF ( privacy_updated ) %]
18
        <div class="dialog message">Your privacy rules have been updated</div>
20
        <div class="dialog message">Your privacy rules have been updated.</div>
19
    [% END %]
21
    [% END %]
20
22
21
    <h2>Privacy rule</h2>
23
    <h2>Privacy rule</h2>
(-)a/misc/cronjobs/batch_anonymise.pl (-1 / +3 lines)
Lines 19-24 Link Here
19
19
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
use Carp;
22
23
23
BEGIN {
24
BEGIN {
24
25
Lines 70-76 my ($newyear,$newmonth,$newday) = Add_Delta_Days ($year,$month,$day,(-1)*$days); Link Here
70
my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday;
71
my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday;
71
$verbose and print "Checkouts before $formatdate will be anonymised.\n";
72
$verbose and print "Checkouts before $formatdate will be anonymised.\n";
72
73
73
my $rows = AnonymiseIssueHistory($formatdate);
74
my ($rows, $err_history_not_deleted) = AnonymiseIssueHistory($formatdate);
75
carp "Anonymisation of reading history failed." if ($err_history_not_deleted);
74
$verbose and print "$rows checkouts anonymised.\n";
76
$verbose and print "$rows checkouts anonymised.\n";
75
77
76
exit(0);
78
exit(0);
(-)a/opac/opac-privacy.pl (-2 / +6 lines)
Lines 51-59 if ($op eq "update_privacy") Link Here
51
if ($op eq "delete_record") {
51
if ($op eq "delete_record") {
52
    # delete all reading records for items returned
52
    # delete all reading records for items returned
53
    # uses a hardcoded date ridiculously far in the future
53
    # uses a hardcoded date ridiculously far in the future
54
    AnonymiseIssueHistory('2999-12-12',$borrowernumber);
54
    my ($rows,$err_history_not_deleted) = AnonymiseIssueHistory('2999-12-12',$borrowernumber);
55
    # confirm the user the deletion has been done
55
    # confirm the user the deletion has been done
56
    $template->param('deleted' => 1);
56
    if (! $err_history_not_deleted) {
57
	$template->param('deleted' => 1);
58
    } else {
59
        $template->param('err_history_not_deleted' => 1);
60
    }
57
}
61
}
58
# get borrower privacy ....
62
# get borrower privacy ....
59
my ( $borr ) = GetMemberDetails( $borrowernumber );
63
my ( $borr ) = GetMemberDetails( $borrowernumber );
(-)a/tools/cleanborrowers.pl (-2 / +2 lines)
Lines 145-151 if ( $params->{'step3'} ) { Link Here
145
145
146
    # Anonymising all members
146
    # Anonymising all members
147
    if ($do_anonym) {
147
    if ($do_anonym) {
148
        $totalAno = AnonymiseIssueHistory($filterdate2);
148
        #FIXME: anonymisation errors are not handled
149
        ($totalAno,my $anonymisation_error) = AnonymiseIssueHistory($filterdate2);
149
        $template->param(
150
        $template->param(
150
            filterdate1 => $filterdate2,
151
            filterdate1 => $filterdate2,
151
            do_anonym   => '1',
152
            do_anonym   => '1',
152
- 

Return to bug 6506