Bug 31028: Add email notification of cataloguers on submissions
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Tue, 25 Oct 2022 14:26:33 +0000 (15:26 +0100)
committerTomas Cohen Arazi <tomascohen@theke.io>
Mon, 6 Mar 2023 14:23:17 +0000 (11:23 -0300)
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.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Helen Oliver <HOliver@tavi-port.ac.uk>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Koha/Ticket.pm
installer/data/mysql/atomicupdate/bug_31028.pl
installer/data/mysql/en/mandatory/sample_notices.yml
installer/data/mysql/mandatory/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/cataloguing.pref

index 711bcd9..f716304 100644 (file)
@@ -134,6 +134,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;
index 68015ef..179f835 100644 (file)
@@ -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 <a href='[% Koha.Preference('IntranetBaseURL') %]/cgi-bin/koha/cataloguing/concerns.pl'>page</a>.", 'email' );
+            }
+        );
+        say $out "Added new notice 'TICKET_NOTIFY'";
     }
 }
index 469ee70..261a6df 100644 (file)
@@ -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 <a href='[% Koha.Preference('IntranetBaseURL') %]/cgi-bin/koha/cataloguing/concerns.pl'>page</a>."
+
         - module: circulation
           code: ACCOUNT_CREDIT
           branchcode: ""
index a7fdb86..85a1213 100644 (file)
@@ -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'),
index b28bf50..c533548 100644 (file)
@@ -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:
         -