From a2430b45a3c03b3c9a61a153617dee4a6c3844a7 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 25 Oct 2022 15:26:33 +0100 Subject: [PATCH] Bug 31028: Add email notification of cataloguers on submissions This patch adds an optional cataloger notification to email the cataloging team whenever a new catalog concern is reported. Test plan 1) Enable `OpacCatalogConcerns` 2) Add at least one email address to the new `CatalogerEmails` prefernce (a comma delimited list is also allowed). 3) Confirm that a default template has been added to the Notices management, `TICKET_NOTIFY`. 4) Submit a new concern using the OPAC 5) Confirm that an email is sent to those email addresses listed in CatalogerEmails. --- Koha/Ticket.pm | 26 +++++++++++++++++++ .../data/mysql/atomicupdate/bug_31028.pl | 16 ++++++++++++ .../mysql/en/mandatory/sample_notices.yml | 16 ++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../admin/preferences/cataloguing.pref | 6 +++++ 5 files changed, 65 insertions(+) diff --git a/Koha/Ticket.pm b/Koha/Ticket.pm index b09d097854..354bb71b7e 100644 --- a/Koha/Ticket.pm +++ b/Koha/Ticket.pm @@ -135,6 +135,32 @@ sub store { C4::Letters::SendQueuedMessages( { message_id => $acknowledgement_message_id } ); } + + # Notify cataloger by email + if ( $self->biblio_id && C4::Context->preference('CatalogerEmails') ) { + + # notify the library if a notice exists + my $notify_letter = C4::Letters::GetPreparedLetter( + module => 'catalog', + letter_code => 'TICKET_NOTIFY', + branchcode => $self->reporter->branchcode, + tables => { tickets => $self->id } + ); + + if ($notify_letter) { + my $message_id = C4::Letters::EnqueueLetter( + { + letter => $notify_letter, + message_transport_type => 'email', + to_address => + C4::Context->preference('CatalogerEmails'), + reply_address => $self->reporter->notice_email_address, + } + ); + C4::Letters::SendQueuedMessages( + { message_id => $message_id } ); + } + } } return $self; diff --git a/installer/data/mysql/atomicupdate/bug_31028.pl b/installer/data/mysql/atomicupdate/bug_31028.pl index 169f26806f..030cff5e64 100644 --- a/installer/data/mysql/atomicupdate/bug_31028.pl +++ b/installer/data/mysql/atomicupdate/bug_31028.pl @@ -109,5 +109,21 @@ return { } ); say $out "Added new notice 'TICKET_RESOLVE'"; + + $dbh->do( + q{ + INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES + ('CatalogerEmails', '', '', 'Notify these catalogers by email when a catalog concern is submitted', 'free') + } + ); + say $out "`CatalogerEmails` preference added"; + + $dbh->do( + q{ + INSERT IGNORE INTO letter(module,code,branchcode,name,is_html,title,content,message_transport_type) + VALUES ( 'catalog', 'TICKET_NOTIFY', '', 'Catalog concern notification', '1', 'Catalog concern reported', "Dear cataloger,\r\n\r\n[% INCLUDE 'patron-title.inc' patron => ticket.reporter %] reported the following concern with [% INCLUDE 'biblio-title.inc' biblio=ticket.biblio link = 1 %]\r\n\r\n\r\n\r\n[% ticket.body %]\r\n\r\n\r\n\r\nYou can mark this concern as resolved from the concern management page.", 'email' ); + } + ); + say $out "Added new notice 'TICKET_NOTIFY'"; } } diff --git a/installer/data/mysql/en/mandatory/sample_notices.yml b/installer/data/mysql/en/mandatory/sample_notices.yml index 7648361715..b5337a572f 100644 --- a/installer/data/mysql/en/mandatory/sample_notices.yml +++ b/installer/data/mysql/en/mandatory/sample_notices.yml @@ -97,6 +97,22 @@ tables: - "" - "Thankyou" + - module: catalog + code: TICKET_NOTIFY + branchcode: "" + name: "Concern notification" + is_html: 1 + title: "Catalog concern reported" + message_transport_type: email + lang: default + content: + - "Dear cataloger," + - "[% INCLUDE 'patron-title.inc' patron => ticket.reporter %] reported the following concern with [% INCLUDE 'biblio-title.inc' biblio=ticket.biblio link = 1 %]" + - "" + - "[% ticket.body %]" + - "" + - "You can mark this concern as resolved from the concern management page." + - module: circulation code: ACCOUNT_CREDIT branchcode: "" diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index cb4f23b2f6..851e6b1f30 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -131,6 +131,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('casLogout','0','','Does a logout from Koha should also log the user out of CAS?','YesNo'), ('casServerUrl','https://localhost:8443/cas','','URL of the cas server','Free'), ('casServerVersion','2', '2|3','Version of the CAS server Koha will connect to.','Choice'), +('CatalogerEmails', '', '', 'Notify these catalogers by email when a catalog concern is submitted', 'free'), ('CatalogModuleRelink','0',NULL,'If OFF the linker will never replace the authids that are set in the cataloging module.','YesNo'), ('CataloguingLog','1',NULL,'If ON, log edit/create/delete actions on bibliographic data. WARNING: this feature is very resource consuming.','YesNo'), ('ChargeFinesOnClosedDays','0',NULL,'Charge fines on days the library is closed.','YesNo'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref index b28bf50099..c533548e8e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref @@ -42,6 +42,12 @@ Cataloging: 1: "Allow" 0: "Don't allow" - authorized values to be created within the cataloguing module. Librarian will need the manage_auth_values subpermission. + - + - "Use " + - pref: CatalogerEmails + default: '' + class: email + - " as the notification address for catalog concerns." Spine labels: - -- 2.30.2