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

(-)a/C4/Members.pm (+1 lines)
Lines 438-443 sub AddMember { Link Here
438
      :                                             undef;
438
      :                                             undef;
439
439
440
    $data{'privacy_guarantor_checkouts'} = 0 unless defined( $data{'privacy_guarantor_checkouts'} );
440
    $data{'privacy_guarantor_checkouts'} = 0 unless defined( $data{'privacy_guarantor_checkouts'} );
441
    $data{'privacy_guarantor_fines'}     = 0 unless defined( $data{'privacy_guarantor_fines'} );
441
442
442
    # Make a copy of the plain text password for later use
443
    # Make a copy of the plain text password for later use
443
    my $plain_text_password = $data{'password'};
444
    my $plain_text_password = $data{'password'};
(-)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 655-660 OPAC: Link Here
655
                  yes: Allow
655
                  yes: Allow
656
                  no: "Don't allow"
656
                  no: "Don't allow"
657
            - patrons to choose their own privacy settings for showing the patron's checkouts to the patron's guarantor".
657
            - patrons to choose their own privacy settings for showing the patron's checkouts to the patron's guarantor".
658
        -
659
            - pref: AllowPatronToSetFinesVisibilityForGuarantor
660
              default: 0
661
              choices:
662
                  yes: Allow
663
                  no: "Don't allow"
664
            - patrons to choose their own privacy settings for showing the patron's fines to the patron's guarantor".
658
        -
665
        -
659
            - Use borrowernumber
666
            - Use borrowernumber
660
            - pref: AnonymousPatron
667
            - pref: AnonymousPatron
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 164-169 Patrons: Link Here
164
               yes: Allow
164
               yes: Allow
165
               no: "Don't allow"
165
               no: "Don't allow"
166
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
166
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
167
     -
168
         - pref: AllowStaffToSetFinesVisibilityForGuarantor
169
           choices:
170
               yes: Allow
171
               no: "Don't allow"
172
         - staff to set the ability for a patron's fines to be viewed by linked patrons in the OPAC.
167
     -
173
     -
168
         - Card numbers for patrons must be
174
         - Card numbers for patrons must be
169
         - pref: CardnumberLength
175
         - pref: CardnumberLength
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt (+16 lines)
Lines 448-453 Link Here
448
                        <div class="hint">Allow guarantors of this patron to view this patron's checkouts from the OPAC</div>
448
                        <div class="hint">Allow guarantors of this patron to view this patron's checkouts from the OPAC</div>
449
                    </li>
449
                    </li>
450
                [% END %]
450
                [% END %]
451
452
                [% IF relationships && Koha.Preference('AllowStaffToSetFinesVisibilityForGuarantor') %]
453
                    <li>
454
                        <label for="privacy_guarantor_fines">Show fines to guarantors</label>
455
                        <select name="privacy_guarantor_fines" id="privacy_guarantor_fines">
456
                            [% IF privacy_guarantor_fines %]
457
                                <option value="0">No</option>
458
                                <option value="1" selected>Yes</option>
459
                            [% ELSE %]
460
                                <option value="0" selected>No</option>
461
                                <option value="1">Yes</option>
462
                            [% END %]
463
                        </select>
464
                        <div class="hint">Allow guarantors of this patron to view this patron's fines from the OPAC</div>
465
                    </li>
466
                [% END %]
451
            </ol>
467
            </ol>
452
        </fieldset>
468
        </fieldset>
453
    </fieldset>
469
    </fieldset>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+9 lines)
Lines 323-328 Link Here
323
        [% END %]
323
        [% END %]
324
    </li>
324
    </li>
325
325
326
    <li>
327
        <span class="label">Show fines to guarantor</span>
328
        [% IF privacy_guarantor_fines %]
329
            Yes
330
        [% ELSE %]
331
            No
332
        [% END %]
333
    </li>
334
326
    [% IF ( patron.sort1 ) %]<li><span class="label">Sort field 1:</span>[% AuthorisedValues.GetByCode('Bsort1', patron.sort1) |html %]</li>[% END %]
335
    [% IF ( patron.sort1 ) %]<li><span class="label">Sort field 1:</span>[% AuthorisedValues.GetByCode('Bsort1', patron.sort1) |html %]</li>[% END %]
327
    [% IF ( patron.sort2 ) %]<li><span class="label">Sort field 2:</span>[% AuthorisedValues.GetByCode('Bsort2', patron.sort2) |html %]</li>[% END %]
336
    [% IF ( patron.sort2 ) %]<li><span class="label">Sort field 2:</span>[% AuthorisedValues.GetByCode('Bsort2', patron.sort2) |html %]</li>[% END %]
328
    <li><span class="label">Username: </span>[% patron.userid |html  %]</li>
337
    <li><span class="label">Username: </span>[% patron.userid |html  %]</li>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-15 / +58 lines)
Lines 99-105 Link Here
99
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
99
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
100
                [% END %]
100
                [% END %]
101
101
102
                [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
102
                [% IF patron.guarantor_relationships
103
                   && !Koha.Preference('OPACPrivacy')
104
                   && ( Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') 
105
                     || Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') )
106
                %]
103
                    <fieldset class="rows" id="memberentry_privacy">
107
                    <fieldset class="rows" id="memberentry_privacy">
104
                        <legend id="privacy_legend">Privacy</legend>
108
                        <legend id="privacy_legend">Privacy</legend>
105
                        <ol>
109
                        <ol>
Lines 117-122 Link Here
117
                                    <a id="update_privacy_guarantor_checkouts" href="#" class="btn">Update</a>
121
                                    <a id="update_privacy_guarantor_checkouts" href="#" class="btn">Update</a>
118
                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
122
                                    <span id="update_privacy_guarantor_checkouts_message" class="alert" style="display:none"></span>
119
                                </span>
123
                                </span>
124
                            </li>
125
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
142
                            <li>
120
                                <span class="hint">
143
                                <span class="hint">
121
                                    Guaranteed by
144
                                    Guaranteed by
122
                                    [% FOREACH gr IN patron.guarantor_relationships %]
145
                                    [% FOREACH gr IN patron.guarantor_relationships %]
Lines 129-134 Link Here
129
                        </ol>
152
                        </ol>
130
                    </fieldset>
153
                    </fieldset>
131
                [% END %]
154
                [% END %]
155
132
                [% IF ( extended_unique_id_failed_code ) %]
156
                [% IF ( extended_unique_id_failed_code ) %]
133
                    <div class="alert" id="extended_unique_id_failed"><a href="#patron-attr-start-[% extended_unique_id_failed_code %]">[% extended_unique_id_failed_description _ ': ' %]</a> Value is already in use ([% extended_unique_id_failed_value %])</div>
157
                    <div class="alert" id="extended_unique_id_failed"><a href="#patron-attr-start-[% extended_unique_id_failed_code %]">[% extended_unique_id_failed_description _ ': ' %]</a> Value is already in use ([% extended_unique_id_failed_value %])</div>
134
                [% END %]
158
                [% END %]
Lines 1002-1021 Link Here
1002
                }
1026
                }
1003
            });
1027
            });
1004
1028
1005
            [% IF borrower.guarantorid && !Koha.Preference('OPACPrivacy') && Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1029
                [% IF patron.guarantor_relationships && !Koha.Preference('OPACPrivacy') %]
1006
                $('#update_privacy_guarantor_checkouts').click( function() {
1030
            
1007
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1031
                [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
1008
                     .done(function( data ) {
1032
                    $('#update_privacy_guarantor_checkouts').click( function() {
1009
                         var message;
1033
                        $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_guarantor_checkouts: $('#privacy_guarantor_checkouts').val() }, null, 'json')
1010
                         if ( data.success ) {
1034
                         .done(function( data ) {
1011
                             message = _("Your setting has been updated!");
1035
                             var message;
1012
                         } else {
1036
                             if ( data.success ) {
1013
                             message = _("Unable to update your setting!");
1037
                                 message = _("Your setting has been updated!");
1014
                         }
1038
                             } else {
1015
1039
                                 message = _("Unable to update your setting!");
1016
                         $('#update_privacy_guarantor_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
1040
                             }
1017
                     });
1041
1018
                });
1042
                             $('#update_privacy_guarantor_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
1043
                         });
1044
                    });
1045
                [% END %]
1046
1047
                [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
1048
                    $('#update_privacy_guarantor_fines').click( function() {
1049
                        $.post( "/cgi-bin/koha/svc/patron/show_fines_to_relatives", { privacy_guarantor_fines: $('#privacy_guarantor_fines').val() }, null, 'json')
1050
                         .done(function( data ) {
1051
                             var message;
1052
                             if ( data.success ) {
1053
                                 message = _("Your setting has been updated!");
1054
                             } else {
1055
                                 message = _("Unable to update your setting!");
1056
                             }
1057
1058
                             $('#update_privacy_guarantor_fines_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
1059
                         });
1060
                    });
1061
                [% END %]
1019
            [% END %]
1062
            [% END %]
1020
1063
1021
            $(".patron-attributes").on( 'click', '.clear-attribute', function() {
1064
            $(".patron-attributes").on( 'click', '.clear-attribute', function() {
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-privacy.tt (-11 / +27 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 borrower.guarantor_relationships && 
75
                                        Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') || Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor')
76
                                    %]
75
                                        <div>
77
                                        <div>
76
                                            <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
78
                                            [% IF Koha.Preference('AllowPatronToSetCheckoutsVisibilityForGuarantor') %]
77
                                            <select name="privacy_guarantor_checkouts">
79
                                                <label for="privacy_guarantor_checkouts">Allow your guarantor to view your current checkouts?</label>
78
                                                [% IF borrower.privacy_guarantor_checkouts %]
80
                                                <select name="privacy_guarantor_checkouts">
79
                                                    <option value="0">No</option>
81
                                                    [% IF borrower.privacy_guarantor_checkouts %]
80
                                                    <option value="1" selected>Yes</option>
82
                                                        <option value="0">No</option>
81
                                                [% ELSE %]
83
                                                        <option value="1" selected>Yes</option>
82
                                                    <option value="0" selected>No</option>
84
                                                    [% ELSE %]
83
                                                    <option value="1">Yes</option>
85
                                                        <option value="0" selected>No</option>
84
                                                [% END %]
86
                                                        <option value="1">Yes</option>
85
                                            </select>
87
                                                    [% END %]
88
                                                </select>
89
                                            [% END %]
90
                                            [% IF Koha.Preference('AllowPatronToSetFinesVisibilityForGuarantor') %]
91
                                                <label for="privacy_guarantor_fines">Allow your guarantor to view your current fines?</label>
92
                                                <select name="privacy_guarantor_fines">
93
                                                    [% IF borrower.privacy_guarantor_fines %]
94
                                                        <option value="0">No</option>
95
                                                        <option value="1" selected>Yes</option>
96
                                                    [% ELSE %]
97
                                                        <option value="0" selected>No</option>
98
                                                        <option value="1">Yes</option>
99
                                                    [% END %]
100
                                                </select>
101
                                            [% END %]
86
                                            <span class="hint">
102
                                            <span class="hint">
87
                                                Guaranteed by
103
                                                Guaranteed by
88
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
104
                                                [% FOREACH gr IN borrower.guarantor_relationships %]
(-)a/opac/opac-memberentry.pl (-1 / +1 lines)
Lines 320-326 my $captcha = random_string("CCCCC"); Link Here
320
$template->param(
320
$template->param(
321
    captcha        => $captcha,
321
    captcha        => $captcha,
322
    captcha_digest => md5_base64($captcha),
322
    captcha_digest => md5_base64($captcha),
323
    patron         => Koha::Patrons->find( $borrowernumber ),
323
    patron         => scalar Koha::Patrons->find( $borrowernumber ),
324
);
324
);
325
325
326
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
326
output_html_with_http_headers $cgi, $cookie, $template->output, undef, { force_no_caching => 1 };
(-)a/opac/opac-privacy.pl (-4 / +6 lines)
Lines 45-59 my ( $template, $borrowernumber, $cookie ) = get_template_and_user( Link Here
45
    }
45
    }
46
);
46
);
47
47
48
my $op                         = $query->param("op");
48
my $op                          = $query->param("op");
49
my $privacy                    = $query->param("privacy");
49
my $privacy                     = $query->param("privacy");
50
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
50
my $privacy_guarantor_checkouts = $query->param("privacy_guarantor_checkouts");
51
my $privacy_guarantor_fines     = $query->param("privacy_guarantor_fines");
51
52
52
if ( $op eq "update_privacy" ) {
53
if ( $op eq "update_privacy" ) {
53
    ModMember(
54
    ModMember(
54
        borrowernumber             => $borrowernumber,
55
        borrowernumber              => $borrowernumber,
55
        privacy                    => $privacy,
56
        privacy                     => $privacy,
56
        privacy_guarantor_checkouts => $privacy_guarantor_checkouts,
57
        privacy_guarantor_checkouts => $privacy_guarantor_checkouts,
58
        privacy_guarantor_fines     => $privacy_guarantor_fines,
57
    );
59
    );
58
    $template->param( 'privacy_updated' => 1 );
60
    $template->param( 'privacy_updated' => 1 );
59
}
61
}
(-)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