From 4c709c600799392eae67f715cff1b5a2e574c042 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 9 Apr 2013 12:08:56 +0200 Subject: [PATCH 1/3] Bug 6506: Followup add warning in the system information tab. Add a warning in the system information tab of the about page. Test plan: Set OPACPrivacy = 1 and AnonymousPatron = 0 and go on the about page, tab 'system information'. Check that the warning appears. Signed-off-by: Kyle M Hall Signed-off-by: Mason James http://bugs.koha-community.org/show_bug.cgi?id=6509 Signed-off-by: Jared Camins-Esakov --- about.pl | 5 +++++ koha-tmpl/intranet-tmpl/prog/en/modules/about.tt | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/about.pl b/about.pl index 96a8b5a683..b9508c6f5d 100755 --- a/about.pl +++ b/about.pl @@ -68,6 +68,10 @@ my $warnPrefBiblioAddsAuthorities = ( $prefAutoCreateAuthorities && ( !$prefBibl my $prefEasyAnalyticalRecords = C4::Context->preference('EasyAnalyticalRecords'); my $prefUseControlNumber = C4::Context->preference('UseControlNumber'); my $warnPrefEasyAnalyticalRecords = ( $prefEasyAnalyticalRecords && $prefUseControlNumber ); +my $warnPrefAnonymousPatron = ( + C4::Context->preference('OPACPrivacy') + and not C4::Context->preference('AnonymousPatron') +); my $errZebraConnection = C4::Context->Zconn("biblioserver",0)->errcode(); @@ -86,6 +90,7 @@ $template->param( prefAutoCreateAuthorities => $prefAutoCreateAuthorities, warnPrefBiblioAddsAuthorities => $warnPrefBiblioAddsAuthorities, warnPrefEasyAnalyticalRecords => $warnPrefEasyAnalyticalRecords, + warnPrefAnonymousPatron => $warnPrefAnonymousPatron, errZebraConnection => $errZebraConnection, warnIsRootUser => $warnIsRootUser, ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt index 258c77a2cc..42ecc6bc46 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/about.tt @@ -104,7 +104,7 @@

Please log in instead with a regular staff account. To create a staff account, create a library, a patron category 'Staff' and add a new patron. Then give this patron permissions from 'More' in the toolbar.

[% END %]

Warnings regarding the system configuration

- [% IF ( (warnPrefBiblioAddsAuthorities) || warnPrefEasyAnalyticalRecords ) %] + [% IF warnPrefBiblioAddsAuthorities || warnPrefEasyAnalyticalRecords || warnPrefAnonymousPatron %] [% IF (warnPrefBiblioAddsAuthorities) %] @@ -113,6 +113,9 @@ [% IF (warnPrefEasyAnalyticalRecords) %] [% END %] + [% IF warnPrefAnonymousPatron %] + + [% END %]
Preferences
Warning System preference 'EasyAnalyticalRecords' set, but UseControlNumber preference is set to 'Use'. Set it to 'Don't use' or else the 'Show analytics' links in the staff client and the OPAC will be broken.
Warning System preference 'OPACPrivacy' set, but AnonymousPatron preference is set to '0'. Set it to a valid borrower number if you want that this feature works correctly.
[% ELSE %]

No warnings

From 571dab9c7cd7f79e936c28fa60d471e6c1288493 Mon Sep 17 00:00:00 2001 From: Peter Crellan Kelly Date: Thu, 28 Mar 2013 21:00:47 +1300 Subject: [PATCH 2/3] Bug 6506: When AnonymousPatron not set, deletion of issue history silently failed. Remedied by: - in Circulation.pm changing AnonymiseIssueHistory so that it returns ($rows, $err_history_not_deleted) instead of $rows - consequential change to misc/cronjobs/batch_anonymise.pl to handle updated return value, and fail if there is an error - consequential change to tools/cleanborrowers.pl although this still fails silently (raised as bug 9944) - update of opac-privacy.pl to check return value and pass on error - update of opac-privacy.tt to display error if appropriate Note bug 9942 remains unfixed, which is a similar issue upon issue return. To test: 1. OPAC - enable privacy mode (preference OpacPrivacy) - leave anonymous patron set to zero (preference AnonymousPatron) - attempt to delete user history - observe error - check history - still there - change anonymous patron to a valid user - attempt to delete user history - observe success message - check history - gone 2. cleanborrowers.pl - test it functions as before. bug 9944 has been raised for it continuing to silently fail. 3. batch_anonymise.pl - enable privacy mode (preference OpacPrivacy) - leave anonymous patron set to zero (preference AnonymousPatron) - run script (I use --days -1 for testing) - script should fail with a Carp message - change anonymous patron to a valid user - run script as before - script returns quietly - check history - gone Signed-off-by: Kyle M Hall Signed-off-by: Mason James Signed-off-by: Jared Camins-Esakov --- C4/Circulation.pm | 8 +++++--- koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt | 4 +++- misc/cronjobs/batch_anonymise.pl | 4 +++- opac/opac-privacy.pl | 9 +++++++-- tools/cleanborrowers.pl | 3 ++- 5 files changed, 20 insertions(+), 8 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index 3fc124f811..1de40e8665 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -1967,6 +1967,7 @@ sub MarkIssueReturned { if ( $privacy == 2) { # The default of 0 does not work due to foreign key constraints # The anonymisation will fail quietly if AnonymousPatron is not a valid entry + # FIXME the above is unacceptable - bug 9942 relates my $anonymouspatron = (C4::Context->preference('AnonymousPatron')) ? C4::Context->preference('AnonymousPatron') : 0; my $sth_ano = $dbh->prepare("UPDATE old_issues SET borrowernumber=? WHERE borrowernumber = ? @@ -2821,7 +2822,7 @@ sub DeleteTransfer { =head2 AnonymiseIssueHistory - $rows = AnonymiseIssueHistory($date,$borrowernumber) + ($rows,$err_history_not_deleted) = AnonymiseIssueHistory($date,$borrowernumber) This function write NULL instead of C<$borrowernumber> given on input arg into the table issues. if C<$borrowernumber> is not set, it will delete the issue history for all borrower older than C<$date>. @@ -2829,7 +2830,7 @@ if C<$borrowernumber> is not set, it will delete the issue history for all borro If c<$borrowernumber> is set, it will delete issue history for only that borrower, regardless of their opac privacy setting (force delete). -return the number of affected rows. +return the number of affected rows and a value that evaluates to true if an error occurred deleting the history. =cut @@ -2856,8 +2857,9 @@ sub AnonymiseIssueHistory { } my $sth = $dbh->prepare($query); $sth->execute(@bind_params); + my $anonymisation_err = $dbh->err; my $rows_affected = $sth->rows; ### doublecheck row count return function - return $rows_affected; + return ($rows_affected, $anonymisation_err); } =head2 SendCirculationAlert diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt index 5245fdfea7..233222b5e2 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt @@ -13,9 +13,11 @@ [% IF ( deleted ) %]
Your reading history has been deleted.
+ [% ELSIF ( err_history_not_deleted ) %] +
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.
[% END %] [% IF ( privacy_updated ) %] -
Your privacy rules have been updated
+
Your privacy rules have been updated.
[% END %]

Privacy rule

diff --git a/misc/cronjobs/batch_anonymise.pl b/misc/cronjobs/batch_anonymise.pl index 857171b968..48a58c61ca 100755 --- a/misc/cronjobs/batch_anonymise.pl +++ b/misc/cronjobs/batch_anonymise.pl @@ -19,6 +19,7 @@ use strict; use warnings; +use Carp; BEGIN { @@ -70,7 +71,8 @@ my ($newyear,$newmonth,$newday) = Add_Delta_Days ($year,$month,$day,(-1)*$days); my $formatdate = sprintf "%4d-%02d-%02d",$newyear,$newmonth,$newday; $verbose and print "Checkouts before $formatdate will be anonymised.\n"; -my $rows = AnonymiseIssueHistory($formatdate); +my ($rows, $err_history_not_deleted) = AnonymiseIssueHistory($formatdate); +carp "Anonymisation of reading history failed." if ($err_history_not_deleted); $verbose and print "$rows checkouts anonymised.\n"; exit(0); diff --git a/opac/opac-privacy.pl b/opac/opac-privacy.pl index bbfb8fc6da..22fe694e58 100755 --- a/opac/opac-privacy.pl +++ b/opac/opac-privacy.pl @@ -51,9 +51,14 @@ if ($op eq "update_privacy") if ($op eq "delete_record") { # delete all reading records for items returned # uses a hardcoded date ridiculously far in the future - AnonymiseIssueHistory('2999-12-12',$borrowernumber); + my ($rows,$err_history_not_deleted) = AnonymiseIssueHistory('2999-12-12',$borrowernumber); # confirm the user the deletion has been done - $template->param('deleted' => 1); + if ( !$err_history_not_deleted ) { + $template->param( 'deleted' => 1 ); + } + else { + $template->param( 'err_history_not_deleted' => 1 ); + } } # get borrower privacy .... my ( $borr ) = GetMemberDetails( $borrowernumber ); diff --git a/tools/cleanborrowers.pl b/tools/cleanborrowers.pl index 65ce8131e2..0d48b99946 100755 --- a/tools/cleanborrowers.pl +++ b/tools/cleanborrowers.pl @@ -145,7 +145,8 @@ if ( $params->{'step3'} ) { # Anonymising all members if ($do_anonym) { - $totalAno = AnonymiseIssueHistory($filterdate2); + #FIXME: anonymisation errors are not handled + ($totalAno,my $anonymisation_error) = AnonymiseIssueHistory($filterdate2); $template->param( filterdate1 => $filterdate2, do_anonym => '1', From 79ea900b2c47caa71e995fa35d65e1a5c78d3a6d Mon Sep 17 00:00:00 2001 From: Peter Crellan Kelly Date: Wed, 10 Apr 2013 07:22:41 +1200 Subject: [PATCH 3/3] Bug 6506: Correct CSS class name. Signed-off-by: Kyle M Hall Signed-off-by: Mason James http://bugs.koha-community.org/show_bug.cgi?id=6509 Signed-off-by: Jared Camins-Esakov --- koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt index 233222b5e2..5bd84bb8ab 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-privacy.tt @@ -14,7 +14,7 @@ [% IF ( deleted ) %]
Your reading history has been deleted.
[% ELSIF ( err_history_not_deleted ) %] -
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.
+
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.
[% END %] [% IF ( privacy_updated ) %]
Your privacy rules have been updated.