Bug 13465: Correct the field prefix ambiguity
[koha.git] / opac / opac-privacy.pl
blobfd98e6c1a87110221f37601d3803606042c1636b
1 #!/usr/bin/perl
2 # This script lets the users change their privacy rules
4 # copyright 2009, BibLibre, paul.poulain@biblibre.com
6 # Koha is free software; you can redistribute it and/or modify it under the
7 # terms of the GNU General Public License as published by the Free Software
8 # Foundation; either version 2 of the License, or (at your option) any later
9 # version.
11 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
12 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
13 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License along
16 # with Koha; if not, write to the Free Software Foundation, Inc.,
17 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 use strict;
20 use CGI;
22 use C4::Auth; # checkauth, getborrowernumber.
23 use C4::Context;
24 use C4::Circulation;
25 use C4::Members;
26 use C4::Output;
27 use C4::Dates;
29 my $query = new CGI;
31 # if OPACPrivacy is disabled, leave immediately
32 if ( ! C4::Context->preference('OPACPrivacy') || ! C4::Context->preference('opacreadinghistory') ) {
33 print $query->redirect("/cgi-bin/koha/errors/404.pl");
34 exit;
37 my $dbh = C4::Context->dbh;
39 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
41 template_name => "opac-privacy.tt",
42 query => $query,
43 type => "opac",
44 authnotrequired => 0,
45 flagsrequired => { borrow => 1 },
46 debug => 1,
50 my $op = $query->param("op");
51 my $privacy = $query->param("privacy");
53 if ($op eq "update_privacy")
55 ModPrivacy($borrowernumber,$privacy);
56 $template->param('privacy_updated' => 1);
58 if ($op eq "delete_record") {
59 # delete all reading records for items returned
60 # uses a hardcoded date ridiculously far in the future
61 my ($rows,$err_history_not_deleted) = AnonymiseIssueHistory('2999-12-12',$borrowernumber);
62 # confirm the user the deletion has been done
63 if ( !$err_history_not_deleted ) {
64 $template->param( 'deleted' => 1 );
66 else {
67 $template->param( 'err_history_not_deleted' => 1 );
70 # get borrower privacy ....
71 my ( $borr ) = GetMemberDetails( $borrowernumber );
73 $template->param( 'Ask_data' => '1',
74 'privacy'.$borr->{'privacy'} => 1,
75 'firstname' => $borr->{'firstname'},
76 'surname' => $borr->{'surname'},
77 'privacyview' => 1,
80 output_html_with_http_headers $query, $cookie, $template->output;