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

(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt (-9 / +43 lines)
Lines 37-48 Link Here
37
                <div id="userprivacy" class="maincontent">
37
                <div id="userprivacy" class="maincontent">
38
                    <h1>Your privacy management</h1>
38
                    <h1>Your privacy management</h1>
39
39
40
                    [% IF deleted %]
40
                    [% IF delete_all_requested || delete_checkouts_requested || delete_holds_requested %]
41
                        <div class="alert alert-success">Your checkout history has been deleted.</div>
41
                        [% IF delete_all_requested || delete_checkouts_requested %]
42
                    [% ELSIF history_not_deleted %]
42
                            [% IF deleted_checkouts %]
43
                        <div class="alert alert-warning">The deletion of your checkout 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</div>
43
                                <div class="alert alert-success">Your checkout history has been deleted.</div>
44
                    [% ELSIF nothing_to_delete %]
44
                            [% ELSIF error_deleting_checkouts_history %]
45
                        <div class="alert alert-warning">No checkout history to delete</div>
45
                                <div class="alert alert-warning">The deletion of your checkout 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</div>
46
                            [% ELSIF no_checkouts_to_delete %]
47
                                <div class="alert alert-warning">No checkout history to delete</div>
48
                            [% END %]
49
                        [% END %]
50
51
                        [% IF delete_all_requested || delete_holds_requested %]
52
                            [% IF deleted_holds %]
53
                                <div class="alert alert-success">Your hold history has been deleted.</div>
54
                            [% ELSIF error_deleting_holds_history %]
55
                                <div class="alert alert-warning">The deletion of your hold history failed. Please help to fix the system by informing your library of this error</div>
56
                            [% ELSIF no_holds_to_delete %]
57
                                <div class="alert alert-warning">No hold history to delete</div>
58
                            [% END %]
59
                        [% END %]
46
                    [% END %]
60
                    [% END %]
47
61
48
                    [% IF ( privacy_updated ) %]
62
                    [% IF ( privacy_updated ) %]
Lines 140-151 Link Here
140
154
141
                        <h2>Immediate deletion</h2>
155
                        <h2>Immediate deletion</h2>
142
156
157
                        <p>Whatever your privacy rule you choose, you can delete all your checkout and hold history immediately by clicking here. <strong>BE CAREFUL</strong>. Once you've confirmed the deletion, no one can retrieve the list!</p>
158
159
                        <form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
160
                            <legend class="sr-only">Checkout history deletion</legend>
161
                            <input type="hidden" name="op" value="delete_record" />
162
                            <input type="hidden" name="checkouts" value="1" />
163
                            <fieldset class="action">
164
                                <input type="submit" value="Checkout history" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
165
                            </fieldset>
166
                        </form>
167
168
                        <form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
169
                            <legend class="sr-only">Hold history deletion</legend>
170
                            <input type="hidden" name="op" value="delete_record" />
171
                            <input type="hidden" name="holds" value="1" />
172
                            <fieldset class="action">
173
                                <input type="submit" value="Hold history" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
174
                            </fieldset>
175
                        </form>
176
143
                        <form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
177
                        <form action="/cgi-bin/koha/opac-privacy.pl" method="post" id="opac-privacy-delete-form">
144
                            <legend class="sr-only">Immediate deletion</legend>
178
                            <legend class="sr-only">Checkout and hold history deletion</legend>
145
                            <input type="hidden" name="op" value="delete_record" />
179
                            <input type="hidden" name="op" value="delete_record" />
146
                            <p>Whatever your privacy rule you choose, you can delete all your checkout history immediately by clicking here. <strong>BE CAREFUL</strong>. Once you've confirmed the deletion, no one can retrieve the list!</p>
180
                            <input type="hidden" name="all" value="1" />
147
                            <fieldset class="action">
181
                            <fieldset class="action">
148
                                <input type="submit" value="Immediate deletion" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
182
                                <input type="submit" value="Checkout and hold history" class="btn btn-danger" onclick="return confirmDelete(MSG_CONFIRM_AGAIN);" />
149
                            </fieldset>
183
                            </fieldset>
150
                        </form>
184
                        </form>
151
185
(-)a/opac/opac-privacy.pl (-25 / +47 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 42-54 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
42
    }
40
    }
43
);
41
);
44
42
43
my $patron = Koha::Patrons->find( $borrowernumber );
44
45
my $op                         = $query->param("op");
45
my $op                         = $query->param("op");
46
my $privacy                    = $query->param("privacy");
46
my $privacy                    = $query->param("privacy");
47
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
47
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
48
my $privacy_guarantor_fines     = $query->param("privacy_guarantor_fines");
48
my $privacy_guarantor_fines     = $query->param("privacy_guarantor_fines");
49
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 {
74
}
73
            Koha::Patrons->search( { 'me.borrowernumber' => $borrowernumber } )
74
              ->anonymise_issue_history;
75
        };
75
76
76
# get borrower privacy ....
77
        $template->param(
77
my $borrower = Koha::Patrons->find( $borrowernumber );;
78
            (
79
                  $@    ? ( error_deleting_checkouts_history => 1 )
80
                : $rows ? ( deleted_checkouts => int($rows) )
81
                :         ( no_checkouts_to_delete => 1 )
82
            ),
83
            delete_checkouts_requested => 1,
84
        );
85
    }
86
87
    if ( $all or $holds ) {
88
89
        my $rows = eval { $patron->old_holds->anonymize + 0 };
90
91
        $template->param(
92
            (
93
                  $@    ? ( error_deleting_holds_history => 1 )
94
                : $rows ? ( deleted_holds => int($rows) )
95
                :         ( no_holds_to_delete => 1 )
96
            ),
97
            delete_holds_requested => 1,
98
        );
99
    }
100
}
78
101
79
$template->param(
102
$template->param(
80
    'Ask_data'                       => 1,
103
    'Ask_data'                     => 1,
81
    'privacy' . $borrower->privacy() => 1,
104
    'privacy' . $patron->privacy() => 1,
82
    'privacyview'                    => 1,
105
    'privacyview'                  => 1,
83
    'borrower'                       => $borrower,
106
    'borrower'                     => $patron,
84
    'surname'                        => $borrower->surname,
107
    'surname'                      => $patron->surname,
85
    'firstname'                      => $borrower->firstname,
108
    'firstname'                    => $patron->firstname,
86
    'has_guarantor_flag'             => $borrower->guarantor_relationships->guarantors->_resultset->count
109
    'has_guarantor_flag'           => $patron->guarantor_relationships->guarantors->_resultset->count
87
);
110
);
88
111
89
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
112
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
90
- 

Return to bug 29526