From 1ddb796146019397fa16ef7ca723902b0208c004 Mon Sep 17 00:00:00 2001 From: jeremy breuillard Date: Fri, 22 Oct 2021 15:13:36 +0000 Subject: [PATCH] Bug 35028: Add self-registrations alert on staff interface main page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This adds a new system preference PatronSelfRegistrationAlert to enable or disable alerts (disabled by default) Test plan: 1. Create patron category SELFREG 2. Enable PatronSelfRegistration and set PatronSelfRegistrationDefaultCategory to SELFREG and PatronSelfRegistrationAlert to "Show" 3. Go to OPAC, logout if needed, and create a new account. Remember the value you set for home library. 4. Go to staff interface, set the current library to the one you set in step 3. 5. Go to the staff interface main page. You should see at the bottom a message saying "Self-registrations from: All libraries: 1 / : 1" (numbers can vary if you already had self-registered patrons) 6. Click on both links and verify that it shows the correct patrons (or redirect to the patron detail page if there is only one) 7. Set the current library to another one (one that doesn't have self-registered patrons) 8. Go to the staff interface main page. You should see at the bottom a message saying "Self-registrations from: All libraries: 1" (numbers can vary if you already had self-registered patrons) 9. Click on the link and verify that it shows the correct patrons (or redirect to the patron detail page if there is only one) Co-authored-by: Fridolin Somers Co-authored-by: Julian Maurice Sponsored-by: Écoles nationales supérieures d'architecture (ENSA) Signed-off-by: William Lavoie Signed-off-by: Lucas Gass --- installer/data/mysql/atomicupdate/bug-35028.pl | 15 +++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../prog/en/modules/admin/preferences/opac.pref | 6 ++++++ .../prog/en/modules/intranet-main.tt | 15 ++++++++++++++- mainpage.pl | 12 ++++++++++++ 5 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 installer/data/mysql/atomicupdate/bug-35028.pl diff --git a/installer/data/mysql/atomicupdate/bug-35028.pl b/installer/data/mysql/atomicupdate/bug-35028.pl new file mode 100644 index 00000000000..87a8c5348f7 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug-35028.pl @@ -0,0 +1,15 @@ +use Modern::Perl; + +return { + bug_number => '35028', + description => 'Add system preference PatronSelfRegistrationAlert', + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + $dbh->do( " + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo') + " ); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index ede2d4d2755..607e07a41a9 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -612,6 +612,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('PatronSelfModificationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when a patron is editing their information via the OPAC.','free'), ('PatronSelfModificationMandatoryField','',NULL,'Define the required fields when a patron is editing their information via the OPAC','free'), ('PatronSelfRegistration','0',NULL,'If enabled, patrons will be able to register themselves via the OPAC.','YesNo'), +('PatronSelfRegistrationAlert','0',NULL,'If enabled, an alter will be shown on staff interface home page when there are self-registered patrons.','YesNo'), ('PatronSelfRegistrationBorrowerMandatoryField','surname|firstname',NULL,'Choose the mandatory fields for a patron\'s account, when registering via the OPAC.','free'), ('PatronSelfRegistrationBorrowerUnwantedField','',NULL,'Name the fields you don\'t want to display when registering a new patron via the OPAC.','free'), ('PatronSelfRegistrationConfirmEmail', '0', NULL, 'Require users to confirm their email address by entering it twice.', 'YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index 24411cd3437..a17170402b0 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -888,6 +888,12 @@ OPAC: - '
If you choose EmailAddressForPatronRegistrations you have to enter a valid email address: ' - pref: EmailAddressForPatronRegistrations class: email + - + - pref: PatronSelfRegistrationAlert + choices: + 0: "Don't show" + 1: "Show" + - an alert on staff interface home page when there are patrons in the category defined by PatronSelfRegistrationDefaultCategory. Suggestions: - - pref: OpacSuggestionManagedBy diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt index c32de6ab9bf..99f3383b734 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/intranet-main.tt @@ -180,7 +180,7 @@
[%# Following statement must be in one line for translatability %] - [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count || ( holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions ) %] + [% IF ( CAN_user_tools_moderate_comments && pendingcomments ) || ( CAN_user_tools_moderate_tags && pendingtags ) || ( CAN_user_borrowers_edit_borrowers && pending_borrower_modifications ) || ( CAN_user_suggestions_suggestions_manage && ( pendingsuggestions || all_pendingsuggestions )) || ( CAN_user_borrowers_edit_borrowers && pending_discharge_requests ) || pending_article_requests || ( Koha.Preference('AllowCheckoutNotes') && CAN_user_circulate_manage_checkout_notes && pending_checkout_notes.count ) || ( ( Koha.Preference('OpacCatalogConcerns') || Koha.Preference('CatalogConcerns') ) && pending_biblio_tickets && CAN_user_editcatalogue_edit_catalogue ) || ( Koha.Preference('OPACReportProblem') && CAN_user_problem_reports && pending_problem_reports.count ) || already_ran_jobs || new_curbside_pickups.count || ( holds_with_cancellation_requests && CAN_user_circulate_circulate_remaining_permissions ) || self_registered_count %]
[% IF pending_article_requests %]
@@ -275,6 +275,19 @@ [% holds_with_cancellation_requests | html %]
[% END %] + + [% IF self_registered_count %] +
+ Self-registrations from: + All libraries: [% self_registered_count | html %] + + [% IF self_registered_mybranch_count %] + / + [% Branches.GetLoggedInBranchname | html %]: [% self_registered_mybranch_count | html %] + [% END %] +
+ [% END %] +
[% END %] diff --git a/mainpage.pl b/mainpage.pl index d84408538e1..2b78894aaa0 100755 --- a/mainpage.pl +++ b/mainpage.pl @@ -138,6 +138,18 @@ if ( C4::Context->preference('CurbsidePickup') ) { ); } +if ( C4::Context->preference('PatronSelfRegistrationAlert') ) { + my $categorycode = C4::Context->preference('PatronSelfRegistrationDefaultCategory'); + my $branchcode = C4::Context::mybranch(); + + my $rs = Koha::Patrons->search( { categorycode => $categorycode } ); + + $template->param( + self_registered_count => $rs->count, + self_registered_mybranch_count => $rs->search( { branchcode => $branchcode } )->count, + ); +} + $template->param( pendingcomments => $pendingcomments, pendingtags => $pendingtags, -- 2.39.5