View | Details | Raw Unified | Return to bug 29843
Collapse All | Expand All

(-)a/opac/opac-privacy.pl (-23 / +42 lines)
Lines 32-39 if ( ! C4::Context->preference('OPACPrivacy') || ! C4::Context->preference('opac Link Here
32
    exit;
32
    exit;
33
}
33
}
34
34
35
my $dbh   = C4::Context->dbh;
36
37
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
35
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
38
    {
36
    {
39
        template_name   => "opac-privacy.tt",
37
        template_name   => "opac-privacy.tt",
Lines 47-54 my $privacy = $query->param("privacy"); Link Here
47
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
45
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
48
my $privacy_guarantor_fines     = $query->param("privacy_guarantor_fines");
46
my $privacy_guarantor_fines     = $query->param("privacy_guarantor_fines");
49
47
48
my $patron = Koha::Patrons->find( $borrowernumber );;
49
50
if ( $op eq "update_privacy" ) {
50
if ( $op eq "update_privacy" ) {
51
    my $patron = Koha::Patrons->find( $borrowernumber );
52
    if ( $patron ) {
51
    if ( $patron ) {
53
        $patron->set({
52
        $patron->set({
54
            privacy                    => $privacy,
53
            privacy                    => $privacy,
Lines 60-89 if ( $op eq "update_privacy" ) { Link Here
60
}
59
}
61
elsif ( $op eq "delete_record" ) {
60
elsif ( $op eq "delete_record" ) {
62
61
63
    # delete all reading records for items returned
62
    my $holds     = $query->param('holds');
64
    my $rows = eval {
63
    my $checkouts = $query->param('checkouts');
65
        Koha::Patrons->search({ 'me.borrowernumber' => $borrowernumber })->anonymise_issue_history;
64
    my $all       = $query->param('all');
66
    };
65
67
    $template->param(
66
    $template->param( delete_all_quested => 1 )
68
        (
67
      if $all;
69
              $@    ? ( history_not_deleted => 1 )
68
70
            : $rows ? ( deleted             => int($rows) )
69
    if ( $all or $checkouts ) {
71
            :         ( nothing_to_delete => 1 )
70
72
        )
71
        # delete all reading records for items returned
73
    );
72
        my $rows = eval { $patron->old_checkouts->anonymize + 0 };
74
}
75
73
76
# get borrower privacy ....
74
        $template->param(
77
my $borrower = Koha::Patrons->find( $borrowernumber );;
75
            (
76
                  $@    ? ( error_deleting_checkouts_history => 1 )
77
                : $rows ? ( deleted_checkouts => int($rows) )
78
                :         ( no_checkouts_to_delete => 1 )
79
            ),
80
            delete_checkouts_requested => 1,
81
        );
82
    }
83
84
    if ( $all or $holds ) {
85
86
        my $rows = eval { $patron->old_holds->anonymize + 0 };
87
88
        $template->param(
89
            (
90
                  $@    ? ( error_deleting_holds_history => 1 )
91
                : $rows ? ( deleted_holds => int($rows) )
92
                :         ( no_holds_to_delete => 1 )
93
            ),
94
            delete_holds_requested => 1,
95
        );
96
    }
97
}
78
98
79
$template->param(
99
$template->param(
80
    'Ask_data'                       => 1,
100
    'Ask_data'                       => 1,
81
    'privacy' . $borrower->privacy() => 1,
101
    'privacy' . $patron->privacy() => 1,
82
    'privacyview'                    => 1,
102
    'privacyview'                    => 1,
83
    'borrower'                       => $borrower,
103
    'borrower'                       => $patron,
84
    'surname'                        => $borrower->surname,
104
    'surname'                        => $patron->surname,
85
    'firstname'                      => $borrower->firstname,
105
    'firstname'                      => $patron->firstname,
86
    'has_guarantor_flag'             => $borrower->guarantor_relationships->guarantors->_resultset->count
106
    'has_guarantor_flag'             => $patron->guarantor_relationships->guarantors->_resultset->count
87
);
107
);
88
108
89
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
109
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
90
- 

Return to bug 29843