Bug 18904: (follow-up) Set indicators and correct js path
[koha.git] / C4 / Letters.pm
index 0b04354..d4664d0 100644 (file)
@@ -458,7 +458,7 @@ sub SendAlerts {
                                     : 'text/plain; charset="utf-8"',
                 }
             );
-            unless( sendmail(%mail) ) {
+            unless( Mail::Sendmail::sendmail(%mail) ) {
                 carp $Mail::Sendmail::error;
                 return { error => $Mail::Sendmail::error };
             }
@@ -603,7 +603,7 @@ sub SendAlerts {
               if C4::Context->preference("ClaimsBccCopy");
         }
 
-        unless ( sendmail(%mail) ) {
+        unless ( Mail::Sendmail::sendmail(%mail) ) {
             carp $Mail::Sendmail::error;
             return { error => $Mail::Sendmail::error };
         }
@@ -652,7 +652,7 @@ sub SendAlerts {
                                 : 'text/plain; charset="utf-8"',
             }
         );
-        unless( sendmail(%mail) ) {
+        unless( Mail::Sendmail::sendmail(%mail) ) {
             carp $Mail::Sendmail::error;
             return { error => $Mail::Sendmail::error };
         }
@@ -1401,7 +1401,7 @@ sub _send_message_by_email {
 
     _update_message_to_address($message->{'message_id'},$to_address) unless $message->{to_address}; #if initial message address was empty, coming here means that a to address was found and queue should be updated
 
-    if ( sendmail( %sendmail_params ) ) {
+    if ( Mail::Sendmail::sendmail( %sendmail_params ) ) {
         _set_message_status( { message_id => $message->{'message_id'},
                 status     => 'sent' } );
         return 1;
@@ -1518,7 +1518,8 @@ sub _process_tt {
 
     my $tt_params = { %{ _get_tt_params( $tables ) }, %{ _get_tt_params( $loops, 'is_a_loop' ) }, %$substitute };
 
-    $content = qq|[% USE KohaDates %]$content|;
+    $content = add_tt_filters( $content );
+    $content = qq|[% USE KohaDates %][% USE Remove_MARC_punctuation %]$content|;
 
     my $output;
     $template->process( \$content, $tt_params, \$output ) || croak "ERROR PROCESSING TEMPLATE: " . $template->error();
@@ -1545,6 +1546,12 @@ sub _get_tt_params {
             plural   => 'biblios',
             pk       => 'biblionumber',
         },
+        biblioitems => {
+            module   => 'Koha::Biblioitems',
+            singular => 'biblioitem',
+            plural   => 'biblioitems',
+            pk       => 'biblioitemnumber',
+        },
         borrowers => {
             module   => 'Koha::Patrons',
             singular => 'borrower',
@@ -1694,6 +1701,23 @@ sub _get_tt_params {
     return $params;
 }
 
+=head3 add_tt_filters
+
+$content = add_tt_filters( $content );
+
+Add TT filters to some specific fields if needed.
+
+For now we only add the Remove_MARC_punctuation TT filter to biblio and biblioitem fields
+
+=cut
+
+sub add_tt_filters {
+    my ( $content ) = @_;
+    $content =~ s|\[%\s*biblio\.(.*?)\s*%\]|[% biblio.$1 \| \$Remove_MARC_punctuation %]|gxms;
+    $content =~ s|\[%\s*biblioitem\.(.*?)\s*%\]|[% biblioitem.$1 \| \$Remove_MARC_punctuation %]|gxms;
+    return $content;
+}
+
 =head2 get_item_content
 
     my $item = Koha::Items->find(...)->unblessed;