When the 'RestrictPatronsWithFailedNotices' syspref is enabled then patrons with email and sms notices which failed sending (have a message_queue.status field of 'failed') have a restriction (debarment) applied to them. Test plan: 1. In the Koha staff client > Tools > Overdue notice/status triggers and create the 'First' rule for all patron categories as: Delay: 1 Letter: Overdue Notice SMS: ticked Ensure you have an SMS notice for the ODUE letter. 2. In the system preferences make sure you enter dummy data into the SMSSendUsername, SMSSendPassword and EmailSMSSendDriverFromAddress sysprefs 2. Find two non-debarred patrons and make sure they have invalid SMS numbers set. The SMS numbers must be INCORRECT, for example "123" as an SMS number. Leaving this field empty will result in the message_transport_type defaulting to 'print' instead of 'sms'. 3. Check one item out to each patron in step 2 4. Jump into the database and run the query: UPDATE issues SET date_due=<2 days before current date> WHERE borrowernumber=<borrower1>; UPDATE issues SET date_due=<2 days before current date> WHERE borrowernumber=<borrower2>; 5. Go to misc/cronjobs directory and enter the Koha shell: sudo koha-shell <instancename> 6. Run: ./overdue_notices.pl 7. Exit the shell and jump back into the database and run the query: SELECT message_transport_type, status FROM message_queue WHERE borrowernumber=<borrower1> OR borrowernumber=<borrower2>; 8. Confirm both new notice records have the message_transport_type is 'sms' and the status of 'pending' 9. Exit the database and re-enter the Koha shell and run the command: ./process_message_queue.pl 10. Jump back into the database re-run the query from step 7 and confirm the status is 'failed' for both 11. Also run the query: SELECT * FROM borrower_debarments WHERE borrowernumber=<borrower1> OR borrowernumber=<borrower2>; Notice there is no added debarment to these two patrons 12. Apply patch, restart memcached and plack. In the installer/data/mysql directory enter the Koha shell and run the command: ./update_database.pl 13. In the Administration > Global System Preferences interface of the staff client notice there is a new system (set to "Don't" by default) named 'RestrictPatronsWithFailedNotices'. Enable it (i.e. select 'Do') 14. Create a new file in the /etc/cron.daily directory named koha-custom and add the following line to it: koha-foreach --chdir --enabled /usr/share/koha/bin/cronjobs/restrict_patrons_with_failed_notices.pl 15. In the misc/cronjobs directory enter the Koha shell and run the command: ./restrict_patrons_with_failed_notices.pl 16. The script should output text saying: There are borrowers with failed SMS or email notices However because you haven't given the script the argument -c it won't apply debarments (restrictions) to any of the patrons with the failed SMS or email notices. 16. Query the borrower_debarments table: SELECT * FROM borrower_debarments WHERE borrowernumber=<borrower1> OR borrowernumber=<borrower2>; Notice they still have no restriction 17. Now in the Koha shell run the command: ./restrict_patrons_with_failed_notices.pl -c 18. Notice the script outputs the text: There are borrowers with failed SMS or email notices Applying restriction to patron <borrowernumber>: <borrower firstname> <borrower surname>; 19. Repeat step 16 and notice both patrons now have 1 restriction each with the borrower_debarments.type=SUSPENSION and comment=SMSnumber invalid and expiration=NULL 20. Query the borrowers table: SELECT debarred, debarredcomment FROM borrowers WHERE borrowernumber=<borrower1> OR borrowernumber=<borrower2>; 21. Notice the values are: debarred= 9999-12-31 debarredcomment= SMS number invalid 22. Repeat step 17 and notice the script outputs: There are borrowers with failed SMS or email notices Patron <borrowernumber>: <borrower firstname> <borrower surname> is currently restricted due to having an invalid SMS number. No new restriction applied" 23. Repeat step 16 and notice no new debarment has been added to those borrowers as they have already been restricted from having a failed SMS notice. 24. In the Koha home directory run the command: prove t/db_dependent/Koha/Notices.t This unit test contains the tests for the new subroutines added to Koha/Notice/Message.pm which are restrict_patron_when_notice_fails() and get_failed_notices() 25. All tests should pass 26. Sign off Sponsored-by: Catalyst IT Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
16 lines
648 B
Perl
Executable file
16 lines
648 B
Perl
Executable file
use Modern::Perl;
|
|
|
|
return {
|
|
bug_number => "23295",
|
|
description => "Automatically debar patrons if SMS or email notice fail",
|
|
up => sub {
|
|
my ($args) = @_;
|
|
my ( $dbh, $out ) = @$args{qw(dbh out)};
|
|
|
|
$dbh->do(
|
|
q{ INSERT IGNORE INTO systempreferences (variable, value, options, explanation, type) VALUES ('RestrictPatronsWithFailedNotices', '0', NULL, 'If enabled then when SMS and email notices fail sending at the Koha level then a debarment will be applied to a patrons account', 'YesNo') }
|
|
);
|
|
|
|
say $out "Added system preference 'RestrictPatronsWithFailedNotices'";
|
|
},
|
|
};
|