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 3434-3440 CREATE TABLE IF NOT EXISTS `borrower_modifications` ( Link Here
3434
  `privacy` int(11) DEFAULT NULL,
3434
  `privacy` int(11) DEFAULT NULL,
3435
  `extended_attributes` MEDIUMTEXT DEFAULT NULL,
3435
  `extended_attributes` MEDIUMTEXT DEFAULT NULL,
3436
  `gdpr_proc_consent` datetime, -- data processing consent
3436
  `gdpr_proc_consent` datetime, -- data processing consent
3437
  `autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
3438
  PRIMARY KEY (`verification_token` (191),`borrowernumber`),
3437
  PRIMARY KEY (`verification_token` (191),`borrowernumber`),
3439
  KEY `verification_token` (`verification_token` (191)),
3438
  KEY `verification_token` (`verification_token` (191)),
3440
  KEY `borrowernumber` (`borrowernumber`)
3439
  KEY `borrowernumber` (`borrowernumber`)
(-)a/installer/data/mysql/sysprefs.sql (+1 lines)
Lines 33-38 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
33
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
33
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
34
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
34
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
35
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
35
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
36
('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account tp choose whether their checkouts are auto renewed or not','YesNo'),
36
('AllowPatronToSetCheckoutsVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor',  'YesNo'),
37
('AllowPatronToSetCheckoutsVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor',  'YesNo'),
37
('AllowPatronToSetFinesVisibilityForGuarantor',  '0', NULL, 'If enabled, the patron can set fines 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'),
38
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),
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'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/patrons.pref (+6 lines)
Lines 233-238 Patrons: Link Here
233
               no: Allow all permitted users
233
               no: Allow all permitted users
234
         - "to access/change superlibrarian privileges."
234
         - "to access/change superlibrarian privileges."
235
         - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
235
         - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
236
     -
237
         - pref: AllowPatronToControlAutorenewal
238
           choices:
239
               yes: Allow patrons
240
               no: Allow only staff
241
         - "to allow/disallow auto-renewal for account. If allowed a patron will be able to update their own account to allow/disallow autorenewals"
236
242
237
    Privacy:
243
    Privacy:
238
     -
244
     -
(-)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 161-166 $template->param( Link Here
161
                    surname           => $borr->{surname},
174
                    surname           => $borr->{surname},
162
                    RENEW_ERROR       => $renew_error,
175
                    RENEW_ERROR       => $renew_error,
163
                    borrower          => $borr,
176
                    borrower          => $borr,
177
                    csrf_token             => Koha::Token->new->generate_csrf({
178
                        session_id => scalar $query->cookie('CGISESSID'),
179
                    }),
164
                );
180
                );
165
181
166
#get issued items ....
182
#get issued items ....
167
- 

Return to bug 24476