@@ -, +, @@ --- .../bootstrap/en/modules/opac-privacy.tt | 52 +++++++++++--- opac/opac-privacy.pl | 71 ++++++++++++------- 2 files changed, 90 insertions(+), 33 deletions(-) --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt @@ -37,12 +37,26 @@

Your privacy management

- [% IF deleted %] -
Your checkout history has been deleted.
- [% ELSIF history_not_deleted %] -
The deletion of your checkout 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
- [% ELSIF nothing_to_delete %] -
No checkout history to delete
+ [% IF delete_all_requested || delete_checkouts_requested || delete_holds_requested %] + [% IF delete_all_requested || delete_checkouts_requested %] + [% IF deleted_checkouts %] +
Your checkout history has been deleted.
+ [% ELSIF error_deleting_checkouts_history %] +
The deletion of your checkout 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
+ [% ELSIF no_checkouts_to_delete %] +
No checkout history to delete
+ [% END %] + [% END %] + + [% IF delete_all_requested || delete_holds_requested %] + [% IF deleted_holds %] +
Your hold history has been deleted.
+ [% ELSIF error_deleting_holds_history %] +
The deletion of your hold history failed. Please help to fix the system by informing your library of this error
+ [% ELSIF no_holds_to_delete %] +
No hold history to delete
+ [% END %] + [% END %] [% END %] [% IF ( privacy_updated ) %] @@ -140,12 +154,32 @@

Immediate deletion

+

Whatever your privacy rule you choose, you can delete all your checkout and hold history immediately by clicking here. BE CAREFUL. Once you've confirmed the deletion, no one can retrieve the list!

+ +
+ Checkout history deletion + + +
+ +
+
+ +
+ Hold history deletion + + +
+ +
+
+
- Immediate deletion + Checkout and hold history deletion -

Whatever your privacy rule you choose, you can delete all your checkout history immediately by clicking here. BE CAREFUL. Once you've confirmed the deletion, no one can retrieve the list!

+
- +
--- a/opac/opac-privacy.pl +++ a/opac/opac-privacy.pl @@ -32,8 +32,6 @@ if ( ! C4::Context->preference('OPACPrivacy') || ! C4::Context->preference('opac exit; } -my $dbh = C4::Context->dbh; - my ( $template, $borrowernumber, $cookie ) = get_template_and_user( { template_name => "opac-privacy.tt", @@ -42,13 +40,14 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user( } ); +my $patron = Koha::Patrons->find( $borrowernumber ); + my $op = $query->param("op"); my $privacy = $query->param("privacy"); my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts"); my $privacy_guarantor_fines = $query->param("privacy_guarantor_fines"); if ( $op eq "update_privacy" ) { - my $patron = Koha::Patrons->find( $borrowernumber ); if ( $patron ) { $patron->set({ privacy => $privacy, @@ -60,30 +59,54 @@ if ( $op eq "update_privacy" ) { } elsif ( $op eq "delete_record" ) { - # delete all reading records for items returned - my $rows = eval { - Koha::Patrons->search({ 'me.borrowernumber' => $borrowernumber })->anonymise_issue_history; - }; - $template->param( - ( - $@ ? ( history_not_deleted => 1 ) - : $rows ? ( deleted => int($rows) ) - : ( nothing_to_delete => 1 ) - ) - ); -} + my $holds = $query->param('holds'); + my $checkouts = $query->param('checkouts'); + my $all = $query->param('all'); + + $template->param( delete_all_quested => 1 ) + if $all; + + if ( $all or $checkouts ) { + + # delete all reading records for items returned + my $rows = eval { + Koha::Patrons->search( { 'me.borrowernumber' => $borrowernumber } ) + ->anonymise_issue_history; + }; -# get borrower privacy .... -my $borrower = Koha::Patrons->find( $borrowernumber );; + $template->param( + ( + $@ ? ( error_deleting_checkouts_history => 1 ) + : $rows ? ( deleted_checkouts => int($rows) ) + : ( no_checkouts_to_delete => 1 ) + ), + delete_checkouts_requested => 1, + ); + } + + if ( $all or $holds ) { + + my $rows = eval { $patron->old_holds->anonymize + 0 }; + + $template->param( + ( + $@ ? ( error_deleting_holds_history => 1 ) + : $rows ? ( deleted_holds => int($rows) ) + : ( no_holds_to_delete => 1 ) + ), + delete_holds_requested => 1, + ); + } +} $template->param( - 'Ask_data' => 1, - 'privacy' . $borrower->privacy() => 1, - 'privacyview' => 1, - 'borrower' => $borrower, - 'surname' => $borrower->surname, - 'firstname' => $borrower->firstname, - 'has_guarantor_flag' => $borrower->guarantor_relationships->guarantors->_resultset->count + 'Ask_data' => 1, + 'privacy' . $patron->privacy() => 1, + 'privacyview' => 1, + 'borrower' => $patron, + 'surname' => $patron->surname, + 'firstname' => $patron->firstname, + 'has_guarantor_flag' => $patron->guarantor_relationships->guarantors->_resultset->count ); output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 }; --