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

(-)a/C4/Reserves.pm (-12 / +1 lines)
Lines 264-281 sub GetReserve { Link Here
264
    my $query = "SELECT * FROM reserves WHERE reserve_id = ?";
264
    my $query = "SELECT * FROM reserves WHERE reserve_id = ?";
265
    my $sth = $dbh->prepare( $query );
265
    my $sth = $dbh->prepare( $query );
266
    $sth->execute( $reserve_id );
266
    $sth->execute( $reserve_id );
267
    my $res = $sth->fetchrow_hashref();
267
    return $sth->fetchrow_hashref();
268
269
    unless ($res) {
270
        $query = "SELECT * FROM old_reserves WHERE reserve_id = ?";
271
        $sth   = $dbh->prepare($query);
272
        $sth->execute($reserve_id);
273
        $res = $sth->fetchrow_hashref();
274
    }
275
276
    carp("No hold for for reserve_id $reserve_id") unless $res;
277
278
    return $res;
279
}
268
}
280
269
281
=head2 GetReservesFromBiblionumber
270
=head2 GetReservesFromBiblionumber
(-)a/installer/data/mysql/sysprefs.sql (+2 lines)
Lines 25-35 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
25
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
25
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
26
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
26
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
27
('AllowOnShelfHolds','0','','Allow hold requests to be placed on items that are not on loan','YesNo'),
27
('AllowOnShelfHolds','0','','Allow hold requests to be placed on items that are not on loan','YesNo'),
28
('AllowPatronToSetRelativesCheckoutsVisibility',  '0', NULL, 'If enabled, the patron can set checkouts to be visible to guarantor from opac-memberentry.pl',  'YesNo'),
28
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
29
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
29
('AllowPurchaseSuggestionBranchChoice','0','1','Allow user to choose branch when making a purchase suggestion','YesNo'),
30
('AllowPurchaseSuggestionBranchChoice','0','1','Allow user to choose branch when making a purchase suggestion','YesNo'),
30
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
31
('AllowRenewalLimitOverride','0',NULL,'if ON, allows renewal limits to be overridden on the circulation screen','YesNo'),
31
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
32
('AllowReturnToBranch','anywhere','anywhere|homebranch|holdingbranch|homeorholdingbranch','Where an item may be returned','Choice'),
32
('AllowSelfCheckReturns','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'),
33
('AllowSelfCheckReturns','0','','If enabled, patrons may return items through the Web-based Self Checkout','YesNo'),
34
('AllowStaffToSetRelativesCheckoutsVisibility','0',NULL,'If enabled, library staff can set a patron''s checkouts to be visible to linked patrons from the opac.',  'YesNo'),
33
('AllowTooManyOverride','1','','If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts','YesNo'),
35
('AllowTooManyOverride','1','','If on, allow staff to override and check out items when the patron has reached the maximum number of allowed checkouts','YesNo'),
34
('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z',NULL,'Alphabet than can be expanded into browse links, e.g. on Home > Patrons','free'),
36
('alphabet','A B C D E F G H I J K L M N O P Q R S T U V W X Y Z',NULL,'Alphabet than can be expanded into browse links, e.g. on Home > Patrons','free'),
35
('AlternateHoldingsField','',NULL,'The MARC field/subfield that contains alternate holdings information for bibs taht do not have items attached (e.g. 852abchi for libraries converting from MARC Magician).','free'),
37
('AlternateHoldingsField','',NULL,'The MARC field/subfield that contains alternate holdings information for bibs taht do not have items attached (e.g. 852abchi for libraries converting from MARC Magician).','free'),
(-)a/installer/data/mysql/updatedatabase.pl (-2 / +37 lines)
Lines 37-42 use Getopt::Long; Link Here
37
use C4::Context;
37
use C4::Context;
38
use C4::Installer;
38
use C4::Installer;
39
use C4::Dates;
39
use C4::Dates;
40
use Koha::Database;
40
41
41
use MARC::Record;
42
use MARC::Record;
42
use MARC::File::XML ( BinaryEncoding => 'utf8' );
43
use MARC::File::XML ( BinaryEncoding => 'utf8' );
Lines 8569-8582 if(CheckVersion($DBversion)) { Link Here
8569
        ALTER TABLE deletedborrowers ADD privacy_relative_checkouts BOOLEAN NOT NULL DEFAULT '0'
8570
        ALTER TABLE deletedborrowers ADD privacy_relative_checkouts BOOLEAN NOT NULL DEFAULT '0'
8570
    });
8571
    });
8571
    $dbh->do(q{
8572
    $dbh->do(q{
8572
        ALTER TABLE old_issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST
8573
        ALTER TABLE old_issues
8574
            DROP PRIMARY KEY,
8575
            ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
8576
            DROP INDEX itemnumber_idx,
8577
            ADD UNIQUE itemnumber_idx (itemnumber);
8573
    });
8578
    });
8574
    $dbh->do(q{
8579
    $dbh->do(q{
8575
        ALTER TABLE issues ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST;
8580
        ALTER TABLE issues
8581
            DROP PRIMARY KEY,
8582
            ADD issue_id INT( 11 ) NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST,
8583
            DROP INDEX itemnumber_idx,
8584
            ADD UNIQUE itemnumber_idx (itemnumber);
8576
    });
8585
    });
8577
    $dbh->do(qq{
8586
    $dbh->do(qq{
8578
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
8587
        UPDATE issues SET issue_id = issue_id + ( SELECT COUNT(*) FROM old_issues ) ORDER BY issue_id DESC
8579
    });
8588
    });
8589
8590
    my $schema = Koha::Database->new()->schema();
8591
    my $max_issue_id = $schema->resultset('Issue')->get_column('issue_id')->max();
8592
    $max_issue_id ||= $schema->resultset('OldIssue')->get_column('issue_id')->max();
8593
    $max_issue_id ||= 0;
8594
    $max_issue_id++;
8595
    $dbh->do(qq{
8596
        ALTER TABLE issues AUTO_INCREMENT = $max_issue_id
8597
    });
8598
8599
    $dbh->do(q{
8600
        INSERT INTO systempreferences (variable, value, options, explanation, type )
8601
        VALUES (
8602
            'AllowStaffToSetRelativesCheckoutsVisibility',  '0', NULL,
8603
            'If enabled, library staff can set a patron''s checkouts to be visible to linked patrons from the opac.',  'YesNo'
8604
        )
8605
    });
8606
8607
    $dbh->do(q{
8608
        INSERT INTO systempreferences (variable, value, options, explanation, type )
8609
        VALUES (
8610
            'AllowPatronToSetRelativesCheckoutsVisibility',  '0', NULL,
8611
            'If enabled, the patron can set checkouts to be visible to guarantor from opac-memberentry.pl',  'YesNo'
8612
        )
8613
    });
8614
8580
    print "Upgrade to $DBversion done (Bug 9303 - relative's checkouts in the opac)\n";
8615
    print "Upgrade to $DBversion done (Bug 9303 - relative's checkouts in the opac)\n";
8581
    SetVersion($DBversion);
8616
    SetVersion($DBversion);
8582
}
8617
}
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref (+7 lines)
Lines 588-593 OPAC: Link Here
588
                  no: "Don't allow"
588
                  no: "Don't allow"
589
            - patrons to choose their own privacy settings for their reading history.  This requires opacreadinghistory and AnonymousPatron
589
            - patrons to choose their own privacy settings for their reading history.  This requires opacreadinghistory and AnonymousPatron
590
        -
590
        -
591
            - pref: AllowPatronToSetRelativesCheckoutsVisibility
592
              default: 0
593
              choices:
594
                  yes: Allow
595
                  no: "Don't allow"
596
            - patrons to choose their own privacy settings for showing checkouts to relatives from "your personal details" reguardless of the setting for OPACPrivacy.
597
        -
591
            - Use borrowernumber
598
            - Use borrowernumber
592
            - pref: AnonymousPatron
599
            - pref: AnonymousPatron
593
              class: integer
600
              class: integer
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 134-139 Patrons: Link Here
134
               no: "Don't"
134
               no: "Don't"
135
         - enable the ability to upload and attach arbitrary files to a borrower record.
135
         - enable the ability to upload and attach arbitrary files to a borrower record.
136
     -
136
     -
137
         - pref: AllowStaffToSetRelativesCheckoutsVisibility
138
           choices:
139
               yes: Allow
140
               no: "Don't allow"
141
         - staff to set the ability for a patron's checkouts to be viewed by linked patrons in the OPAC.
142
     -
137
         - Card numbers for patrons must be
143
         - Card numbers for patrons must be
138
         - pref: CardnumberLength
144
         - pref: CardnumberLength
139
         - "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')."
145
         - "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 (-13 / +16 lines)
Lines 1-5 Link Here
1
[% IF ( opduplicate ) %][% SET focusAction = "clearDupe" %][% END %]
1
[% IF ( opduplicate ) %][% SET focusAction = "clearDupe" %][% END %]
2
[% USE KohaDates %]
2
[% USE KohaDates %]
3
[% USE Koha %]
3
[% INCLUDE 'doc-head-open.inc' %]
4
[% INCLUDE 'doc-head-open.inc' %]
4
<title>Koha &rsaquo; Patrons &rsaquo; 
5
<title>Koha &rsaquo; Patrons &rsaquo; 
5
[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] [% IF ( categoryname ) %] [% categoryname %] patron[% ELSE %][% IF ( I ) %] Organization patron[% END %][% IF ( A ) %] Adult patron[% END %][% IF ( C ) %] Child patron[% END %][% IF ( P ) %] Professional patron[% END %][% IF ( S ) %] Staff patron[% END %][% END %][% UNLESS ( opadd ) %] [% surname %], [% firstname %][% END %]</title>
6
[% IF ( opadd ) %]Add[% ELSIF ( opduplicate ) %]Duplicate[% ELSE %] Modify[% END %] [% IF ( categoryname ) %] [% categoryname %] patron[% ELSE %][% IF ( I ) %] Organization patron[% END %][% IF ( A ) %] Adult patron[% END %][% IF ( C ) %] Child patron[% END %][% IF ( P ) %] Professional patron[% END %][% IF ( S ) %] Staff patron[% END %][% END %][% UNLESS ( opadd ) %] [% surname %], [% firstname %][% END %]</title>
Lines 1170-1188 Link Here
1170
			[% END %]
1171
			[% END %]
1171
	  [% IF ( mandatorypassword ) %]<span class="required">Required</span>[% END %][% IF ( ERROR_password_mismatch ) %]<span class="required">Passwords do not match</span>[% END %]
1172
	  [% IF ( mandatorypassword ) %]<span class="required">Required</span>[% END %][% IF ( ERROR_password_mismatch ) %]<span class="required">Passwords do not match</span>[% END %]
1172
		</li>
1173
		</li>
1173
        <li>
1174
        [% IF Koha.Preference('AllowStaffToSetRelativesCheckoutsVisibility') %]
1174
            <label for="privacy_relative_checkouts">Show checkouts to relatives</label>
1175
            <li>
1175
            <select name="privacy_relative_checkouts" id="privacy_relative_checkouts">
1176
                <label for="privacy_relative_checkouts">Show checkouts to relatives</label>
1176
                [% IF privacy_relative_checkouts %]
1177
                <select name="privacy_relative_checkouts" id="privacy_relative_checkouts">
1177
                    <option value="0">No</option>
1178
                    [% IF privacy_relative_checkouts %]
1178
                    <option value="1" selected>Yes</option>
1179
                        <option value="0">No</option>
1179
                [% ELSE %]
1180
                        <option value="1" selected>Yes</option>
1180
                    <option value="0" selected>No</option>
1181
                    [% ELSE %]
1181
                    <option value="1">Yes</option>
1182
                        <option value="0" selected>No</option>
1182
                [% END %]
1183
                        <option value="1">Yes</option>
1183
            </select>
1184
                    [% END %]
1184
            <div class="hint">Allow linked patron accounts to view this patron's checkouts from the OPAC</div>
1185
                </select>
1185
        </li>
1186
                <div class="hint">Allow linked patron accounts to view this patron's checkouts from the OPAC</div>
1187
            </li>
1188
        [% END %]
1186
		</ol>
1189
		</ol>
1187
		</fieldset>
1190
		</fieldset>
1188
        [% END # hide fieldset %][% END %]
1191
        [% END # hide fieldset %][% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt (+10 lines)
Lines 372-377 function validate1(date) { Link Here
372
         [% IF ( privacy1 ) %]Default[% END %]
372
         [% IF ( privacy1 ) %]Default[% END %]
373
         [% IF ( privacy2 ) %]Never[% END %]
373
         [% IF ( privacy2 ) %]Never[% END %]
374
    </li>[% END %]
374
    </li>[% END %]
375
376
    <li>
377
        <span class="label">Show checkouts to relatives</span>
378
        [% IF privacy_relative_checkouts %]
379
            Yes
380
        [% ELSE %]
381
            No
382
        [% END %]
383
    </li>
384
375
    [% IF ( sort1 ) %]<li><span class="label">Sort field 1:</span>[% lib1 %]</li>[% END %]
385
    [% IF ( sort1 ) %]<li><span class="label">Sort field 1:</span>[% lib1 %]</li>[% END %]
376
    [% IF ( sort2 ) %]<li><span class="label">Sort field 2:</span>[% lib2 %]</li>[% END %]
386
    [% IF ( sort2 ) %]<li><span class="label">Sort field 2:</span>[% lib2 %]</li>[% END %]
377
    <li><span class="label">Username: </span>[% userid %]</li>
387
    <li><span class="label">Username: </span>[% userid %]</li>
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (+39 lines)
Lines 54-59 Link Here
54
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
54
                    <div class="alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
55
                [% END %]
55
                [% END %]
56
56
57
                [% IF Koha.Preference('AllowPatronToSetRelativesCheckoutsVisibility') %]
58
                    <fieldset class="rows" id="memberentry_privacy">
59
                        <legend id="privacy_legend">Privacy</legend>
60
                        <ol>
61
                            <li>
62
                                <label>Allow relatives to view your current checkouts?</label>
63
                                <select id="privacy_relative_checkouts">
64
                                    <option value="0">No</option>
65
                                    [% IF borrower.privacy_relative_checkouts %]
66
                                        <option value="1" selected="selected">Yes</option>
67
                                    [% ELSE %]
68
                                        <option value="1">Yes</option>
69
                                    [% END %]
70
                                </select>
71
                                <span class="hint">
72
                                    <a id="update_privacy_relative_checkouts" href="#" class="btn">Update</a>
73
                                    <span id="update_privacy_relative_checkouts_message" class="alert" style="display:none"></span>
74
                                </span>
75
                            </li>
76
                        </ol>
77
                    </fieldset>
78
                [% END %]
79
57
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form">
80
                <form method="post" action="/cgi-bin/koha/opac-memberentry.pl" id="memberentry-form">
58
81
59
                [% UNLESS hidden.defined('branchcode') %]
82
                [% UNLESS hidden.defined('branchcode') %]
Lines 777-782 Link Here
777
            [% ELSE %]
800
            [% ELSE %]
778
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
801
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
779
            [% END %]
802
            [% END %]
803
804
            [% IF Koha.Preference('AllowPatronToSetRelativesCheckoutsVisibility') %]
805
                $('#update_privacy_relative_checkouts').click( function() {
806
                    $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_relative_checkouts: $('#privacy_relative_checkouts').val() })
807
                     .done(function( data ) {
808
                         var message;
809
                         if ( data.success ) {
810
                             message = _("Your setting has been updated!");
811
                         } else {
812
                             message = _("Unable to update your setting!");
813
                         }
814
815
                         $('#update_privacy_relative_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
816
                     });
817
                });
818
            [% END %]
780
        });
819
        });
781
    //]]>
820
    //]]>
782
    </script>
821
    </script>
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-memberentry.tt (+35 lines)
Lines 20-25 Link Here
20
            [% ELSE %]
20
            [% ELSE %]
21
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
21
                $( "#borrower_dateofbirth" ).datepicker({ yearRange: "c-120:c" });
22
            [% END %]
22
            [% END %]
23
24
            $('#update_privacy_relative_checkouts').click( function() {
25
                $.post( "/cgi-bin/koha/svc/patron/show_checkouts_to_relatives", { privacy_relative_checkouts: $('#privacy_relative_checkouts').val() })
26
                 .done(function( data ) {
27
                     var message;
28
                     if ( data.success ) {
29
                         message = _("Your setting has been updated!");
30
                     } else {
31
                         message = _("Unable to update your setting!");
32
                     }
33
34
                     $('#update_privacy_relative_checkouts_message').fadeIn("slow").text( message ).delay( 5000 ).fadeOut("slow");
35
                 });
36
            });
23
        });
37
        });
24
    //]]>
38
    //]]>
25
    </script>
39
    </script>
Lines 62-67 Link Here
62
                                <div class="dialog alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
76
                                <div class="dialog alert">You typed in the wrong characters in the box before submitting. Please try again.</div>
63
                            [% END %]
77
                            [% END %]
64
78
79
                            <fieldset class="rows" id="memberentry_privacy">
80
                                <legend id="privacy_legend">Privacy</legend>
81
                                <ol>
82
                                    <li>
83
                                        <label>Show checkouts to relatives</label>
84
                                        <select id="privacy_relative_checkouts">
85
                                            <option value="0">No</option>
86
                                            [% IF borrower.privacy_relative_checkouts %]
87
                                                <option value="1" selected="selected">Yes</option>
88
                                            [% ELSE %]
89
                                                <option value="1">Yes</option>
90
                                            [% END %]
91
                                        </select>
92
                                        <span class="hint">
93
                                            <button id="update_privacy_relative_checkouts" onclick="return false;">Update</button>
94
                                            <span id="update_privacy_relative_checkouts_message" class="alert" style="display:none"></span>
95
                                        </span>
96
                                    </li>
97
                                </ol>
98
                            </fieldset>
99
65
                                [% UNLESS
100
                                [% UNLESS
66
                                    hidden.defined('branchcode')
101
                                    hidden.defined('branchcode')
67
                                %]
102
                                %]
(-)a/koha-tmpl/opac-tmpl/prog/en/modules/opac-user.tt (-1 / +1 lines)
Lines 327-333 var MSG_CONFIRM_RESUME_HOLDS = _("Are you sure you want to resume all suspended Link Here
327
        [% END %]
327
        [% END %]
328
    [% END %]
328
    [% END %]
329
329
330
    [% IF relatives %]
330
    [% IF relatives && Koha.Preference('borrowerRelationship') %]
331
        <div id="opac-user-relative-issues">
331
        <div id="opac-user-relative-issues">
332
            <table id="opac-user-relative-issues-table">
332
            <table id="opac-user-relative-issues-table">
333
                <thead>
333
                <thead>
(-)a/members/moremember.pl (+1 lines)
Lines 444-449 $template->param( Link Here
444
#   reserveloop     => \@reservedata,
444
#   reserveloop     => \@reservedata,
445
    samebranch     => $samebranch,
445
    samebranch     => $samebranch,
446
    quickslip		  => $quickslip,
446
    quickslip		  => $quickslip,
447
    privacy_relative_checkouts => $data->{'privacy_relative_checkouts'},
447
    activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
448
    activeBorrowerRelationship => (C4::Context->preference('borrowerRelationship') ne ''),
448
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
449
    AutoResumeSuspendedHolds => C4::Context->preference('AutoResumeSuspendedHolds'),
449
    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
450
    SuspendHoldsIntranet => C4::Context->preference('SuspendHoldsIntranet'),
(-)a/opac/opac-user.pl (-5 / +10 lines)
Lines 374-385 if ( $borr->{'opacnote'} ) { Link Here
374
  );
374
  );
375
}
375
}
376
376
377
my @borrowernumbers = GetMemberRelatives($borrowernumber);
377
if (   C4::Context->preference('AllowPatronToSetRelativesCheckoutsVisibility')
378
if ( @borrowernumbers ) {
378
    || C4::Context->preference('AllowStaffToSetRelativesCheckoutsVisibility') )
379
    my @relatives = Koha::Database->new()->schema()->resultset("Borrower")->search(
379
{
380
        { privacy_relative_checkouts => 1,  'me.borrowernumber' => { -in => \@borrowernumbers, } },
380
    my @relatives =
381
      Koha::Database->new()->schema()->resultset("Borrower")->search(
382
        {
383
            privacy_relative_checkouts => 1,
384
            'me.guarantorid'           => $borrowernumber
385
        },
381
        { prefetch => [ { 'issues' => { 'item' => 'biblio' } } ] }
386
        { prefetch => [ { 'issues' => { 'item' => 'biblio' } } ] }
382
    );
387
      );
383
    $template->param( relatives => \@relatives );
388
    $template->param( relatives => \@relatives );
384
}
389
}
385
390
(-)a/opac/svc/patron/show_checkouts_to_relatives (-1 / +60 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
24
use C4::Auth;
25
use C4::Context;
26
use Koha::Database;
27
28
use JSON qw( to_json );
29
30
my $cgi = CGI->new();
31
32
my $privacy_relative_checkouts = $cgi->param('privacy_relative_checkouts');
33
34
my ( $userid, $cookie, $sessionID, $flags ) = checkauth( $cgi, 1, {}, 'opac' );
35
36
my $borrowernumber =
37
  C4::Context->userenv ? C4::Context->userenv->{number} : undef;
38
39
my $success = 0;
40
if ( $borrowernumber && defined($privacy_relative_checkouts) ) {
41
    my $patron =
42
      Koha::Database->new()->schema()->resultset('Borrower')
43
      ->find($borrowernumber);
44
45
    $success = $patron->update(
46
        { privacy_relative_checkouts => $privacy_relative_checkouts } );
47
}
48
49
binmode STDOUT, ":encoding(UTF-8)";
50
print $cgi->header(
51
    -type    => 'application/json',
52
    -charset => 'UTF-8'
53
);
54
55
print to_json(
56
    {
57
        success => $success ? 1 : 0,
58
        privacy_relative_checkouts => $privacy_relative_checkouts,
59
    }
60
);

Return to bug 9303