Bug 9302: Use patron-title.inc
[koha.git] / opac / opac-privacy.pl
blobff0d3282d7afee3a5172e0c28884c9043410ccd9
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
7 # under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # Koha is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with Koha; if not, see <http://www.gnu.org/licenses>.
19 use strict;
20 use CGI qw ( -utf8 );
22 use C4::Auth; # checkauth, getborrowernumber.
23 use C4::Context;
24 use C4::Members;
25 use C4::Output;
26 use Koha::Patrons;
28 my $query = new CGI;
30 # if OPACPrivacy is disabled, leave immediately
31 if ( ! C4::Context->preference('OPACPrivacy') || ! C4::Context->preference('opacreadinghistory') ) {
32 print $query->redirect("/cgi-bin/koha/errors/404.pl");
33 exit;
36 my $dbh = C4::Context->dbh;
38 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
40 template_name => "opac-privacy.tt",
41 query => $query,
42 type => "opac",
43 authnotrequired => 0,
44 debug => 1,
48 my $op = $query->param("op");
49 my $privacy = $query->param("privacy");
50 my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
52 if ( $op eq "update_privacy" ) {
53 ModMember(
54 borrowernumber => $borrowernumber,
55 privacy => $privacy,
56 privacy_guarantor_checkouts => $privacy_guarantor_checkouts,
58 $template->param( 'privacy_updated' => 1 );
60 elsif ( $op eq "delete_record" ) {
62 # delete all reading records for items returned
63 my $rows = eval {
64 Koha::Patrons->search({ 'me.borrowernumber' => $borrowernumber })->anonymise_issue_history;
66 $rows = $@ ? 0 : int($rows);
67 $template->param( 'deleted' => $rows );
70 # get borrower privacy ....
71 my $borrower = Koha::Patrons->find( $borrowernumber );;
73 $template->param(
74 'Ask_data' => 1,
75 'privacy' . $borrower->privacy() => 1,
76 'privacyview' => 1,
77 'borrower' => $borrower,
78 'surname' => $borrower->surname,
79 'firstname' => $borrower->firstname,
82 output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };