Bug 24476: Allow direct editing of autorenew_checkouts by patron

Signed-off-by: Andrew Fuerste-Henry <andrew@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
This commit is contained in:
Nick Clemens 2020-02-28 20:06:32 +00:00 committed by Martin Renvoize
parent e3c6c4beed
commit ec4b769ddb
Signed by: martin.renvoize
GPG key ID: 422B469130441A0F
7 changed files with 57 additions and 36 deletions

View file

@ -6,15 +6,11 @@ if( CheckVersion( $DBversion ) ) {
unless( column_exists('deletedborrowers','autorenew_checkouts') ){ unless( column_exists('deletedborrowers','autorenew_checkouts') ){
$dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" ); $dbh->do( "ALTER TABLE deletedborrowers ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
} }
unless( column_exists('borrower_modifications','autorenew_checkouts') ){
$dbh->do( "ALTER TABLE borrower_modifications ADD COLUMN autorenew_checkouts TINYINT(1) NOT NULL DEFAULT 1" );
}
$dbh->do(q{ $dbh->do(q{
UPDATE systempreferences INSERT INTO systempreferences
SET value = CONCAT(value,'|autorenew_checkouts') ( `variable`, `value`, `options`, `explanation`, `type` )
WHERE variable IN VALUES
('PatronSelfModificationBorrowerUnwantedField','PatronSelfRegistrationBorrowerUnwantedField') ('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account tp choose whether their checkouts are auto renewed or not','YesNo')
AND value NOT LIKE '%autorenew_checkouts%'
}); });
SetVersion( $DBversion ); SetVersion( $DBversion );
print "Upgrade to $DBversion done (Bug 24476 - Allow patrons to opt-out of autorenewal)\n"; print "Upgrade to $DBversion done (Bug 24476 - Allow patrons to opt-out of autorenewal)\n";

View file

@ -3441,7 +3441,6 @@ CREATE TABLE IF NOT EXISTS `borrower_modifications` (
`privacy` int(11) DEFAULT NULL, `privacy` int(11) DEFAULT NULL,
`extended_attributes` MEDIUMTEXT DEFAULT NULL, `extended_attributes` MEDIUMTEXT DEFAULT NULL,
`gdpr_proc_consent` datetime, -- data processing consent `gdpr_proc_consent` datetime, -- data processing consent
`autorenew_checkouts` TINYINT(1) NOT NULL DEFAULT 1, -- flag for allowing auto-renewal
PRIMARY KEY (`verification_token` (191),`borrowernumber`), PRIMARY KEY (`verification_token` (191),`borrowernumber`),
KEY `verification_token` (`verification_token` (191)), KEY `verification_token` (`verification_token` (191)),
KEY `borrowernumber` (`borrowernumber`) KEY `borrowernumber` (`borrowernumber`)

View file

@ -34,6 +34,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `
('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'), ('AllowMultipleIssuesOnABiblio',1,'Allow/Don\'t allow patrons to check out multiple items from one biblio','','YesNo'),
('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'), ('AllowNotForLoanOverride','0','','If ON, Koha will allow the librarian to loan a not for loan item.','YesNo'),
('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'), ('AllowOfflineCirculation','0','','If on, enables HTML5 offline circulation functionality.','YesNo'),
('AllowPatronToControlAutorenewal','0',NULL,'If enabled, patrons will have a field in their account tp choose whether their checkouts are auto renewed or not','YesNo'),
('AllowPatronToSetCheckoutsVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor', 'YesNo'), ('AllowPatronToSetCheckoutsVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set checkouts to be visible to his or her guarantor', 'YesNo'),
('AllowPatronToSetFinesVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set fines to be visible to his or her guarantor', 'YesNo'), ('AllowPatronToSetFinesVisibilityForGuarantor', '0', NULL, 'If enabled, the patron can set fines to be visible to his or her guarantor', 'YesNo'),
('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'), ('AllowPKIAuth','None','None|Common Name|emailAddress','Use the field from a client-side SSL certificate to look a user in the Koha database','Choice'),

View file

@ -251,6 +251,12 @@ Patrons:
no: Allow all permitted users no: Allow all permitted users
- "to access/change superlibrarian privileges." - "to access/change superlibrarian privileges."
- "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)." - "<br><strong>NOTE:</strong> A permitted user needs to have the 'permissions' flag (if no superlibrarian)."
-
- pref: AllowPatronToControlAutorenewal
choices:
yes: Allow patrons
no: Allow only staff
- "to allow/disallow auto-renewal for account. If allowed a patron will be able to update their own account to allow/disallow autorenewals"
Privacy: Privacy:
- -

View file

@ -258,33 +258,6 @@
[% END %] [% END %]
</li> </li>
[% END %] [% END %]
[% UNLESS hidden.defined('autorenew_checkouts') %]
<li class="lradio">
<label for="yes-autorenew_checkouts">
Allow auto-renewal:
</label>
[% IF ( borrower.autorenew_checkouts ) %]
<label class="radio inline" for="yes-autorenew_checkouts">
Yes
<input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" checked="checked" />
</label>
<label class="radio inline" for="no-autorenew_checkouts">
No
<input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" />
</label>
[% ELSE %]
<label class="radio inline" for="yes-autorenew_checkouts">
Yes
<input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" />
</label>
<label class="radio inline" for="no-autorenew_checkouts">
No
<input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" checked="checked" />
</label>
[% END %]
</li>
[% END %]
</ol> </ol>
</fieldset> </fieldset>
[% END # / defined 'branchcode' %] [% END # / defined 'branchcode' %]

View file

@ -49,6 +49,36 @@
<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> <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>
[% IF Koha.Preference('AllowPatronToControlAutorenewal') %]
<form id="autorenewal_option" action="/cgi-bin/koha/opac-user.pl" method="post">
<label for="yes-autorenew_checkouts">
Allow auto-renewal:
</label>
[% IF ( borrower.autorenew_checkouts ) %]
<label class="radio inline" for="yes-autorenew_checkouts">
Yes
<input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" checked="checked" />
</label>
<label class="radio inline" for="no-autorenew_checkouts">
No
<input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" />
</label>
[% ELSE %]
<label class="radio inline" for="yes-autorenew_checkouts">
Yes
<input type="radio" id="yes-autorenew_checkouts" name="borrower_autorenew_checkouts" value="1" />
</label>
<label class="radio inline" for="no-autorenew_checkouts">
No
<input type="radio" id="no-autorenew_checkouts" name="borrower_autorenew_checkouts" value="0" checked="checked" />
</label>
[% END %]
<input type="hidden" name="csrf_token" value="[% csrf_token | html %]" />
<input type="hidden" name="update_arc" value="1" />
<input type="submit" value="Update autorenewal preference" />
</form>
[% END %]
[% 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 %] [% 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 %]
[% IF failed_holds %] [% IF failed_holds %]

View file

@ -43,6 +43,7 @@ use Koha::Patrons;
use Koha::Patron::Messages; use Koha::Patron::Messages;
use Koha::Patron::Discharge; use Koha::Patron::Discharge;
use Koha::Patrons; use Koha::Patrons;
use Koha::Token;
use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE'; use constant ATTRIBUTE_SHOW_BARCODE => 'SHOW_BCODE';
@ -83,6 +84,18 @@ $template->param( shibbolethAuthentication => C4::Context->config('useshibboleth
# get borrower information .... # get borrower information ....
my $patron = Koha::Patrons->find( $borrowernumber ); my $patron = Koha::Patrons->find( $borrowernumber );
if( $query->param('update_arc') && C4::Context->preference("AllowPatronToControlAutorenewal") ){
die "Wrong CSRF token"
unless Koha::Token->new->check_csrf({
session_id => scalar $query->cookie('CGISESSID'),
token => scalar $query->param('csrf_token'),
});
my $autorenew_checkouts = $query->param('borrower_autorenew_checkouts');
$patron->autorenew_checkouts( $autorenew_checkouts )->store() if defined $autorenew_checkouts;
}
my $borr = $patron->unblessed; my $borr = $patron->unblessed;
# unblessed is a hash vs. object/undef. Hence the use of curly braces here. # unblessed is a hash vs. object/undef. Hence the use of curly braces here.
my $borcat = $borr ? $borr->{categorycode} : q{}; my $borcat = $borr ? $borr->{categorycode} : q{};
@ -164,6 +177,9 @@ $template->param(
surname => $borr->{surname}, surname => $borr->{surname},
RENEW_ERROR => $renew_error, RENEW_ERROR => $renew_error,
borrower => $borr, borrower => $borr,
csrf_token => Koha::Token->new->generate_csrf({
session_id => scalar $query->cookie('CGISESSID'),
}),
); );
#get issued items .... #get issued items ....