user privacy managing and dealing with AnonymousPatron new syspref
[koha.git] / opac / opac-privacy.pl
1 #!/usr/bin/perl
2 # This script lets the users change their privacy rules
3 #
4 # copyright 2009, BibLibre, paul.poulain@biblibre.com
5 #
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.
10 #
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.
14 #
15 # You should have received a copy of the GNU General Public License along with
16 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
17 # Suite 330, Boston, MA  02111-1307 USA
18
19 use strict;
20 use CGI;
21
22 use C4::Auth;    # checkauth, getborrowernumber.
23 use C4::Context;
24 use C4::Circulation;
25 use C4::Members;
26 use C4::Output;
27
28 my $query = new CGI;
29 my $dbh   = C4::Context->dbh;
30
31 my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
32     {
33         template_name   => "opac-privacy.tmpl",
34         query           => $query,
35         type            => "opac",
36         authnotrequired => 0,
37         flagsrequired   => { borrow => 1 },
38         debug           => 1,
39     }
40 );
41
42 my $op = $query->param("op");
43
44 # get borrower privacy ....
45 my ( $borr ) = GetMemberDetails( $borrowernumber );
46 if ($op eq "update_privacy")
47 {
48     ModPrivacy($borrowernumber,$query->param('privacy'));
49     $template->param('privacy_updated' => 1);
50 }
51 if ($op eq "delete_record") { 
52     # delete all reading records. The hardcoded date should never be reached
53     # even if Koha is a long leaving project ;-)
54     AnonymiseIssueHistory('2999-31-12',$borrowernumber);
55     # confirm the user the deletion has been done
56     $template->param('deleted' => 1);
57 }
58 $template->param( 'Ask_data'       => '1',
59                     'privacy'.$borr->{'privacy'} => 1,
60                     'firstname' => $borr->{'firstname'},
61                     'surname' => $borr->{'surname'},
62                     'privacyview' => 1,
63 );
64
65 output_html_with_http_headers $query, $cookie, $template->output;