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

(-)a/Koha/Schema/Result/Borrower.pm (-2 / +10 lines)
Lines 402-407 __PACKAGE__->table("borrowers"); Link Here
402
  default_value: 1
402
  default_value: 1
403
  is_nullable: 0
403
  is_nullable: 0
404
404
405
=head2 privacy_guarantor_fines
406
407
  data_type: 'tinyint'
408
  default_value: 0
409
  is_nullable: 0
410
405
=head2 privacy_guarantor_checkouts
411
=head2 privacy_guarantor_checkouts
406
412
407
  data_type: 'tinyint'
413
  data_type: 'tinyint'
Lines 619-624 __PACKAGE__->add_columns( Link Here
619
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
625
  { data_type => "integer", is_foreign_key => 1, is_nullable => 1 },
620
  "privacy",
626
  "privacy",
621
  { data_type => "integer", default_value => 1, is_nullable => 0 },
627
  { data_type => "integer", default_value => 1, is_nullable => 0 },
628
  "privacy_guarantor_fines",
629
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
622
  "privacy_guarantor_checkouts",
630
  "privacy_guarantor_checkouts",
623
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
631
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
624
  "checkprevcheckout",
632
  "checkprevcheckout",
Lines 1552-1559 Composing rels: L</aqorder_users> -> ordernumber Link Here
1552
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1560
__PACKAGE__->many_to_many("ordernumbers", "aqorder_users", "ordernumber");
1553
1561
1554
1562
1555
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-17 12:11:31
1563
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-22 04:33:29
1556
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:rb0wEXHaSvYum10aZjbAOA
1564
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:lbMdmIHlRt+zayG5+Rq4/w
1557
1565
1558
__PACKAGE__->add_columns(
1566
__PACKAGE__->add_columns(
1559
    '+anonymized' => { is_boolean => 1 },
1567
    '+anonymized' => { is_boolean => 1 },
(-)a/Koha/Schema/Result/Deletedborrower.pm (-2 / +10 lines)
Lines 399-404 __PACKAGE__->table("deletedborrowers"); Link Here
399
  default_value: 1
399
  default_value: 1
400
  is_nullable: 0
400
  is_nullable: 0
401
401
402
=head2 privacy_guarantor_fines
403
404
  data_type: 'tinyint'
405
  default_value: 0
406
  is_nullable: 0
407
402
=head2 privacy_guarantor_checkouts
408
=head2 privacy_guarantor_checkouts
403
409
404
  data_type: 'tinyint'
410
  data_type: 'tinyint'
Lines 604-609 __PACKAGE__->add_columns( Link Here
604
  { data_type => "integer", is_nullable => 1 },
610
  { data_type => "integer", is_nullable => 1 },
605
  "privacy",
611
  "privacy",
606
  { data_type => "integer", default_value => 1, is_nullable => 0 },
612
  { data_type => "integer", default_value => 1, is_nullable => 0 },
613
  "privacy_guarantor_fines",
614
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
607
  "privacy_guarantor_checkouts",
615
  "privacy_guarantor_checkouts",
608
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
616
  { data_type => "tinyint", default_value => 0, is_nullable => 0 },
609
  "checkprevcheckout",
617
  "checkprevcheckout",
Lines 642-649 __PACKAGE__->add_columns( Link Here
642
);
650
);
643
651
644
652
645
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-17 12:11:31
653
# Created by DBIx::Class::Schema::Loader v0.07046 @ 2019-05-22 04:33:29
646
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:STNFbPgDGWmyrZUFj/n+MA
654
# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:zK1jC6Wawwj8B2ch9KFByw
647
655
648
656
649
# You can replace this text with custom code or comments, and it will be preserved on regeneration
657
# You can replace this text with custom code or comments, and it will be preserved on regeneration
(-)a/api/v1/swagger/definitions/patron.json (+4 lines)
Lines 243-248 Link Here
243
      "type": "integer",
243
      "type": "integer",
244
      "description": "controls if relatives can see this patron's checkouts"
244
      "description": "controls if relatives can see this patron's checkouts"
245
    },
245
    },
246
    "privacy_guarantor_fines": {
247
      "type": "integer",
248
      "description": "controls if relatives can see this patron's fines"
249
    },
246
    "check_previous_checkout": {
250
    "check_previous_checkout": {
247
      "type": "string",
251
      "type": "string",
248
      "description": "produce a warning for this patron if this item has previously been checked out to this patron if 'yes', not if 'no', defer to category setting if 'inherit'"
252
      "description": "produce a warning for this patron if this item has previously been checked out to this patron if 'yes', not if 'no', defer to category setting if 'inherit'"
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 707-712 OPAC: Link Here
707
                  no: "Don't allow"
707
                  no: "Don't allow"
708
            - patrons to choose their own privacy settings for showing the patron's checkouts to the patron's guarantor".
708
            - patrons to choose their own privacy settings for showing the patron's checkouts to the patron's guarantor".
709
        -
709
        -
710
            - pref: AllowPatronToSetFinesVisibilityForGuarantor
711
              default: 0
712
              choices:
713
                  yes: Allow
714
                  no: "Don't allow"
715
            - patrons to choose their own privacy settings for showing the patron's fines to the patron's guarantor".
716
        -
710
            - Use borrowernumber
717
            - Use borrowernumber
711
            - pref: AnonymousPatron
718
            - pref: AnonymousPatron
712
              class: integer
719
              class: integer
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 185-190 Patrons: Link Here
185
               no: "Don't allow"
185
               no: "Don't allow"
186
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
186
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
187
     -
187
     -
188
         - pref: AllowStaffToSetFinesVisibilityForGuarantor
189
           choices:
190
               yes: Allow
191
               no: "Don't allow"
192
         - staff to set the ability for a patron's fines to be viewed by linked patrons in the OPAC.
193
     -
188
         - Card numbers for patrons must be
194
         - Card numbers for patrons must be
189
         - pref: CardnumberLength
195
         - pref: CardnumberLength
190
         - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')."
196
         - "characters long. The length can be a single number to specify an exact length, a range separated by a comma (i.e., 'Min,Max'), or a maximum with no minimum (i.e., ',Max')."
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+15 lines)
Lines 429-434 Link Here
429
                        <div class="hint">Allow guarantors of this patron to view this patron's checkouts from the OPAC</div>
429
                        <div class="hint">Allow guarantors of this patron to view this patron's checkouts from the OPAC</div>
430
                    </li>
430
                    </li>
431
                [% END %]
431
                [% END %]
432
                [% IF relationships && Koha.Preference('AllowStaffToSetFinesVisibilityForGuarantor') %]
433
                    <li>
434
                        <label for="privacy_guarantor_fines">Show fines to guarantors</label>
435
                        <select name="privacy_guarantor_fines" id="privacy_guarantor_fines">
436
                            [% IF privacy_guarantor_fines %]
437
                                <option value="0">No</option>
438
                                <option value="1" selected>Yes</option>
439
                            [% ELSE %]
440
                                <option value="0" selected>No</option>
441
                                <option value="1">Yes</option>
442
                            [% END %]
443
                        </select>
444
                        <div class="hint">Allow guarantors of this patron to view this patron's fines from the OPAC</div>
445
                    </li>
446
                [% END %]
432
            </ol>
447
            </ol>
433
    </fieldset>
448
    </fieldset>
434
[% END %]
449
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (-1 / +10 lines)
Lines 485-491 Link Here
485
485
486
                                        <li id="patron-privacyguarantor">
486
                                        <li id="patron-privacyguarantor">
487
                                            <span class="label">Show checkouts to guarantor</span>
487
                                            <span class="label">Show checkouts to guarantor</span>
488
                                            [% IF privacy_guarantor_checkouts %]
488
                                            [% IF patron.privacy_guarantor_checkouts %]
489
                                                Yes
490
                                            [% ELSE %]
491
                                                No
492
                                            [% END %]
493
                                        </li>
494
495
                                        <li>
496
                                            <span class="label">Show fines to guarantor</span>
497
                                            [% IF patron.privacy_guarantor_fines %]
489
                                                Yes
498
                                                Yes
490
                                            [% ELSE %]
499
                                            [% ELSE %]
491
                                                No
500
                                                No
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-15 / +57 lines)
Lines 100-109 Link Here
100
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
100
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
101
                [% END %]
101
                [% END %]
102
102
103
                [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
103
                [% IF has_guarantor_flag && !Koha.Preference('OPACPrivacy') && ( Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') || Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') ) %]
104
                    <fieldset class="rows" id="memberentry_privacy">
104
                    <fieldset class="rows" id="memberentry_privacy">
105
                        <legend id="privacy_legend">Privacy</legend>
105
                        <legend id="privacy_legend">Privacy</legend>
106
                        <ol>
106
                        <ol>
107
                            [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
107
                            <li>
108
                            <li>
108
                                <label>Allow your guarantor to view your current checkouts?</label>
109
                                <label>Allow your guarantor to view your current checkouts?</label>
109
                                <select id="privacy_guarantor_checkouts">
110
                                <select id="privacy_guarantor_checkouts">
Lines 118-123 Link Here
118
                                    <a id="update_privacy_guarantor_checkouts" href="#" class="btn">Update</a>
119
                                    <a id="update_privacy_guarantor_checkouts" href="#" class="btn">Update</a>
119
                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
120
                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
120
                                </span>
121
                                </span>
122
                            </li>
123
                            [% END %]
124
125
                            [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
126
                            <li>
127
                                <label>Allow your guarantor to view your current fines?</label>
128
                                <select id="privacy_guarantor_fines">
129
                                    <option value="0">No</option>
130
                                    [% IF borrower.privacy_guarantor_fines %]
131
                                        <option value="1" selected="selected">Yes</option>
132
                                    [% ELSE %]
133
                                        <option value="1">Yes</option>
134
                                    [% END %]
135
                                </select>
136
                                <span class="hint">
137
                                    <a id="update_privacy_guarantor_fines" href="#" class="btn">Update</a>
138
                                    <span id="update_privacy_guarantor_fines_message" class="alert" style="display:none"></span>
139
                                </span>
140
                            </li>
141
                            [% END %]
142
143
                            <li>
121
                                <span class="hint">
144
                                <span class="hint">
122
                                    Guaranteed by
145
                                    Guaranteed by
123
                                    [% FOREACH gr IN patron.guarantor_relationships %]
146
                                    [% FOREACH gr IN patron.guarantor_relationships %]
Lines 1019-1038 Link Here
1019
                }
1042
                }
1020
            });
1043
            });
1021
1044
1022
            [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1045
            [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') %]
1023
                $('#update_privacy_guarantor_checkouts').click( function() {
1046
1024
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1047
                [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1025
                     .done(function( data ) {
1048
                    $('#update_privacy_guarantor_checkouts').click( function() {
1026
                         var message;
1049
                        $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1027
                         if ( data.success ) {
1050
                         .done(function( data ) {
1028
                             message = _("Your setting has been updated!");
1051
                            var message;
1029
                         } else {
1052
                            if ( data.success ) {
1030
                             message = _("Unable to update your setting!");
1053
                                message = _("Your setting has been updated!");
1031
                         }
1054
                            } else {
1032
1055
                                message = _("Unable to update your setting!");
1033
                         $('#update_privacy_guarantor_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
1056
                            }
1034
                     });
1057
1035
                });
1058
                            $('#update_privacy_guarantor_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
1059
                        });
1060
                    });
1061
                [% END %]
1062
1063
                [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
1064
                    $('#update_privacy_guarantor_fines').click( function() {
1065
                        $.post( "/cgi-bin/koha/svc/patron/show_fines_to_relatives", { privacy_guarantor_fines: $('#privacy_guarantor_fines').val() }, null, 'json')
1066
                         .done(function( data ) {
1067
                            var message;
1068
                            if ( data.success ) {
1069
                                message = _("Your setting has been updated!");
1070
                            } else {
1071
                                message = _("Unable to update your setting!");
1072
                            }
1073
1074
                            $('#update_privacy_guarantor_fines_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
1075
                        });
1076
                    });
1077
                [% END %]
1036
            [% END %]
1078
            [% END %]
1037
1079
1038
            $(".patron-attributes").on( 'click', '.clear-attribute', function() {
1080
            $(".patron-attributes").on( 'click', '.clear-attribute', function() {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt (-11 / +25 lines)
Lines 71-88 Link Here
71
                                        </select>
71
                                        </select>
72
                                    </div>
72
                                    </div>
73
73
74
                                    [% IF borrower.guarantor_relationships && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
74
                                    [% IF has_guarantor_flag && (Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') || Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') ) %]
75
                                        <div>
75
                                        <div>
76
                                            <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
76
                                            [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
77
                                            <select name="privacy_guarantor_checkouts">
77
                                                <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
78
                                                [% IF borrower.privacy_guarantor_checkouts %]
78
                                                <select name="privacy_guarantor_checkouts">
79
                                                    <option value="0">No</option>
79
                                                    [% IF borrower.privacy_guarantor_checkouts %]
80
                                                    <option value="1" selected>Yes</option>
80
                                                        <option value="0">No</option>
81
                                                [% ELSE %]
81
                                                        <option value="1" selected>Yes</option>
82
                                                    <option value="0" selected>No</option>
82
                                                    [% ELSE %]
83
                                                    <option value="1">Yes</option>
83
                                                        <option value="0" selected>No</option>
84
                                                [% END %]
84
                                                        <option value="1">Yes</option>
85
                                            </select>
85
                                                    [% END %]
86
                                                </select>
87
                                            [% END %]
88
                                            [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
89
                                                <label for="privacy_guarantor_fines">Allow your guarantor to view your current fines?</label>
90
                                                <select name="privacy_guarantor_fines">
91
                                                    [% IF borrower.privacy_guarantor_fines %]
92
                                                        <option value="0">No</option>
93
                                                        <option value="1" selected>Yes</option>
94
                                                    [% ELSE %]
95
                                                        <option value="0" selected>No</option>
96
                                                        <option value="1">Yes</option>
97
                                                    [% END %]
98
                                                </select>
99
                                            [% END %]
86
                                            <span class="hint">
100
                                            <span class="hint">
87
                                                Guaranteed by
101
                                                Guaranteed by
88
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
102
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
(-)a/opac/opac-memberentry.pl (-1 / +3 lines)
Lines 329-339 elsif ( $action eq 'edit' ) { #Display logged in borrower's data Link Here
329
}
329
}
330
330
331
my $captcha = random_string("CCCCC");
331
my $captcha = random_string("CCCCC");
332
my $patron_param = scalar Koha::Patrons->find( $borrowernumber );
332
333
333
$template->param(
334
$template->param(
334
    captcha        => $captcha,
335
    captcha        => $captcha,
335
    captcha_digest => md5_base64($captcha),
336
    captcha_digest => md5_base64($captcha),
336
    patron         => Koha::Patrons->find( $borrowernumber ),
337
    patron         => $patron_param,
338
    has_guarantor_flag => $patron_param->guarantor_relationships->guarantors->_resultset->count
337
);
339
);
338
340
339
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
341
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/opac-privacy.pl (-1 / +4 lines)
Lines 47-59 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
47
my $op                         = $query->param("op");
47
my $op                         = $query->param("op");
48
my $privacy                    = $query->param("privacy");
48
my $privacy                    = $query->param("privacy");
49
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
49
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
50
my $privacy_guarantor_fines     = $query->param("privacy_guarantor_fines");
50
51
51
if ( $op eq "update_privacy" ) {
52
if ( $op eq "update_privacy" ) {
52
    my $patron = Koha::Patrons->find( $borrowernumber );
53
    my $patron = Koha::Patrons->find( $borrowernumber );
53
    if ( $patron ) {
54
    if ( $patron ) {
54
        $patron->set({
55
        $patron->set({
55
            privacy                    => $privacy,
56
            privacy                    => $privacy,
56
            privacy_guarantor_checkouts => $privacy_guarantor_checkouts,
57
            privacy_guarantor_checkouts => defined $privacy_guarantor_checkouts?$privacy_guarantor_checkouts:$patron->privacy_guarantor_checkouts,
58
            privacy_guarantor_fines     => defined $privacy_guarantor_fines?$privacy_guarantor_fines:$patron->privacy_guarantor_fines,
57
        })->store;
59
        })->store;
58
        $template->param( 'privacy_updated' => 1 );
60
        $template->param( 'privacy_updated' => 1 );
59
    }
61
    }
Lines 83-88 $template->param( Link Here
83
    'borrower'                       => $borrower,
85
    'borrower'                       => $borrower,
84
    'surname'                        => $borrower->surname,
86
    'surname'                        => $borrower->surname,
85
    'firstname'                      => $borrower->firstname,
87
    'firstname'                      => $borrower->firstname,
88
    'has_guarantor_flag'             => $borrower->guarantor_relationships->guarantors->_resultset->count
86
);
89
);
87
90
88
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
91
output_html_with_http_headers $query, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/svc/patron/show_fines_to_relatives (-1 / +59 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2014 ByWater Solutions
4
#
5
# This file is part of Koha.
6
#
7
# Koha is free software; you can redistribute it and/or modify it under the
8
# terms of the GNU General Public License as published by the Free Software
9
# Foundation; either version 3 of the License, or (at your option) any later
10
# version.
11
#
12
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
13
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
14
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
15
#
16
# You should have received a copy of the GNU General Public License along
17
# with Koha; if not, write to the Free Software Foundation, Inc.,
18
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
20
use Modern::Perl;
21
22
use CGI;
23
use JSON qw( to_json );
24
25
use C4::Auth;
26
use C4::Context;
27
28
use Koha::Patrons;
29
30
my $cgi = CGI->new();
31
32
my $privacy_guarantor_fines = $cgi->param('privacy_guarantor_fines');
33
34
my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 1, {}, 'opac' );
35
36
my $borrowernumber = C4::Context->userenv ? C4::Context->userenv->{number} : undef;
37
38
my $success = 0;
39
if ( $borrowernumber && defined($privacy_guarantor_fines) ) {
40
    my $patron = Koha::Patrons->find($borrowernumber);
41
42
    if ( $patron ) {
43
        $patron->privacy_guarantor_fines($privacy_guarantor_fines);
44
        $success = $patron->store();
45
    }
46
}
47
48
binmode STDOUT, ":encoding(UTF-8)";
49
print $cgi->header(
50
    -type    => 'application/json',
51
    -charset => 'UTF-8'
52
);
53
54
print to_json(
55
    {
56
        success => $success ? 1 : 0,
57
        privacy_guarantor_fines => $privacy_guarantor_fines,
58
    }
59
);

Return to bug 20691