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

(-)a/installer/data/mysql/atomicupdate/bug_24476_opt_out_of_auto_renewal.perl (-8 / +4 lines)
Lines 6-20 if( CheckVersion( $DBversion ) ) { Link Here
6
    unless( column_exists('deletedborrowers','autorenew_checkouts') ){
6
    unless( column_exists('deletedborrowers','autorenew_checkouts') ){
7
        $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
7
        $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
8
    }
8
    }
9
    unless( column_exists('borrower_modifications','autorenew_checkouts') ){
10
        $dbh->do( "ALTER TABLE borrower_modifications ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
11
    }
12
    $dbh->do(q{
9
    $dbh->do(q{
13
        UPDATE systempreferences
10
        INSERT INTO systempreferences
14
        SET value  = CONCAT(value,'|autorenew_checkouts')
11
        ( `variable`, `value`, `options`, `explanation`, `type` )
15
        WHERE variable IN
12
        VALUES
16
        ('PatronSelfModificationBorrowerUnwantedField','PatronSelfRegistrationBorrowerUnwantedField')
13
        ('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account tp choose whether their checkouts are auto renewed or not','YesNo')
17
        AND value NOT LIKE '%autorenew_checkouts%'
18
    });
14
    });
19
    SetVersion( $DBversion );
15
    SetVersion( $DBversion );
20
    print "Upgrade to $DBversion done (Bug 24476 - Allow patrons to opt-out of autorenewal)\n";
16
    print "Upgrade to $DBversion done (Bug 24476 - Allow patrons to opt-out of autorenewal)\n";
(-)a/installer/data/mysql/kohastructure.sql (-1 lines)
Lines 3439-3445 CREATE TABLE IF NOT EXISTS `borrower_modifications` ( Link Here
3439
  `privacy` int(11) DEFAULT NULL,
3439
  `privacy` int(11) DEFAULT NULL,
3440
  `extended_attributes` MEDIUMTEXT DEFAULT NULL,
3440
  `extended_attributes` MEDIUMTEXT DEFAULT NULL,
3441
  `gdpr_proc_consent` datetime, -- data processing consent
3441
  `gdpr_proc_consent` datetime, -- data processing consent
3442
  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
3443
  PRIMARY KEY (`verification_token` (191),`borrowernumber`),
3442
  PRIMARY KEY (`verification_token` (191),`borrowernumber`),
3444
  KEY `verification_token` (`verification_token` (191)),
3443
  KEY `verification_token` (`verification_token` (191)),
3445
  KEY `borrowernumber` (`borrowernumber`)
3444
  KEY `borrowernumber` (`borrowernumber`)
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 34-39 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
34
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
34
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
35
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
35
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
36
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
36
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
37
('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account tp choose whether their checkouts are auto renewed or not','YesNo'),
37
('AllowPatronToSetCheckoutsVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor',  'YesNo'),
38
('AllowPatronToSetCheckoutsVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor',  'YesNo'),
38
('AllowPatronToSetFinesVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set fines to be visible to his or her guarantor',  'YesNo'),
39
('AllowPatronToSetFinesVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set fines to be visible to his or her guarantor',  'YesNo'),
39
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
40
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 251-256 Patrons: Link Here
251
               no: Allow all permitted users
251
               no: Allow all permitted users
252
         - "to access/change superlibrarian privileges."
252
         - "to access/change superlibrarian privileges."
253
         - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
253
         - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
254
     -
255
         - pref: AllowPatronToControlAutorenewal
256
           choices:
257
               yes: Allow patrons
258
               no: Allow only staff
259
         - "to allow/disallow auto-renewal for account. If allowed a patron will be able to update their own account to allow/disallow autorenewals"
254
260
255
    Privacy:
261
    Privacy:
256
     -
262
     -
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-memberentry.tt (-27 lines)
Lines 258-290 Link Here
258
                                        [% END %]
258
                                        [% END %]
259
                                    </li>
259
                                    </li>
260
                                [% END %]
260
                                [% END %]
261
                                [% UNLESS hidden.defined('autorenew_checkouts') %]
262
                                    <li class="lradio">
263
                                        <label for="yes-autorenew_checkouts">
264
                                            Allow auto-renewal:
265
                                        </label>
266
                                            [% IF ( borrower.autorenew_checkouts ) %]
267
                                                <label class="radio inline" for="yes-autorenew_checkouts">
268
                                                    Yes
269
                                                    <input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" checked="checked" />
270
                                                </label>
271
272
                                                <label class="radio inline" for="no-autorenew_checkouts">
273
                                                    No
274
                                                    <input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" />
275
                                                </label>
276
                                            [% ELSE %]
277
                                                <label class="radio inline" for="yes-autorenew_checkouts">
278
                                                    Yes
279
                                                    <input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" />
280
                                                </label>
281
                                                <label class="radio inline" for="no-autorenew_checkouts">
282
                                                    No
283
                                                    <input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" checked="checked" />
284
                                                </label>
285
                                            [% END %]
286
                                    </li>
287
                                [% END %]
288
                            </ol>
261
                            </ol>
289
                        </fieldset>
262
                        </fieldset>
290
                [% END # / defined 'branchcode' %]
263
                [% END # / defined 'branchcode' %]
(-)a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt (+30 lines)
Lines 49-54 Link Here
49
49
50
                    <p><a href="/cgi-bin/koha/opac-main.pl?logout.x=1">Click here if you're not [% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a></p>
50
                    <p><a href="/cgi-bin/koha/opac-main.pl?logout.x=1">Click here if you're not [% INCLUDE 'patron-title.inc' patron = logged_in_user %]</a></p>
51
51
52
                    [% IF Koha.Preference('AllowPatronToControlAutorenewal') %]
53
                    <form id="autorenewal_option" action="/cgi-bin/koha/opac-user.pl" method="post">
54
                            <label for="yes-autorenew_checkouts">
55
                                Allow auto-renewal:
56
                            </label>
57
                                [% IF ( borrower.autorenew_checkouts ) %]
58
                                    <label class="radio inline" for="yes-autorenew_checkouts">
59
                                        Yes
60
                                        <input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" checked="checked" />
61
                                    </label>
62
63
                                    <label class="radio inline" for="no-autorenew_checkouts">
64
                                        No
65
                                        <input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" />
66
                                    </label>
67
                                [% ELSE %]
68
                                    <label class="radio inline" for="yes-autorenew_checkouts">
69
                                        Yes
70
                                        <input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" />
71
                                    </label>
72
                                    <label class="radio inline" for="no-autorenew_checkouts">
73
                                        No
74
                                        <input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" checked="checked" />
75
                                    </label>
76
                                [% END %]
77
                        <input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
78
                        <input type="hidden" name="update_arc" value="1" />
79
                        <input type="submit" value="Update autorenewal preference" />
80
                    </form>
81
                    [% END %]
52
                    [% IF ( patronupdate ) %]<div class="alert alert-info"><h3>Thank you!</h3><p>Your corrections have been submitted to the library, and a staff member will update your record as soon as possible.</p></div>[% END %]
82
                    [% IF ( patronupdate ) %]<div class="alert alert-info"><h3>Thank you!</h3><p>Your corrections have been submitted to the library, and a staff member will update your record as soon as possible.</p></div>[% END %]
53
83
54
                    [% IF failed_holds %]
84
                    [% IF failed_holds %]
(-)a/opac/opac-user.pl (-1 / +16 lines)
Lines 45-50 use Koha::Patrons; Link Here
45
use Koha::Patron::Messages;
45
use Koha::Patron::Messages;
46
use Koha::Patron::Discharge;
46
use Koha::Patron::Discharge;
47
use Koha::Patrons;
47
use Koha::Patrons;
48
use Koha::Token;
48
49
49
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
50
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
50
51
Lines 85-90 $template->param( shibbolethAuthentication => C4::Context->config('useshibboleth Link Here
85
86
86
# get borrower information ....
87
# get borrower information ....
87
my $patron = Koha::Patrons->find( $borrowernumber );
88
my $patron = Koha::Patrons->find( $borrowernumber );
89
90
if( $query->param('update_arc') && C4::Context->preference("AllowPatronToControlAutorenewal") ){
91
    die "Wrong CSRF token"
92
        unless Koha::Token->new->check_csrf({
93
            session_id => scalar $query->cookie('CGISESSID'),
94
            token  => scalar $query->param('csrf_token'),
95
        });
96
97
    my $autorenew_checkouts = $query->param('borrower_autorenew_checkouts');
98
    $patron->autorenew_checkouts( $autorenew_checkouts )->store() if defined $autorenew_checkouts;
99
}
100
88
my $borr = $patron->unblessed;
101
my $borr = $patron->unblessed;
89
# unblessed is a hash vs. object/undef. Hence the use of curly braces here.
102
# unblessed is a hash vs. object/undef. Hence the use of curly braces here.
90
my $borcat = $borr ? $borr->{categorycode} : q{};
103
my $borcat = $borr ? $borr->{categorycode} : q{};
Lines 166-171 $template->param( Link Here
166
                    surname           => $borr->{surname},
179
                    surname           => $borr->{surname},
167
                    RENEW_ERROR       => $renew_error,
180
                    RENEW_ERROR       => $renew_error,
168
                    borrower          => $borr,
181
                    borrower          => $borr,
182
                    csrf_token             => Koha::Token->new->generate_csrf({
183
                        session_id => scalar $query->cookie('CGISESSID'),
184
                    }),
169
                );
185
                );
170
186
171
#get issued items ....
187
#get issued items ....
172
- 

Return to bug 24476