From 89903f068f2198d97a3ff34295faf4dbc8aa88e5 Mon Sep 17 00:00:00 2001
From: Guillaume Rousse <guillaume.rousse@renater.fr>
Date: Tue, 7 Nov 2017 09:26:41 +0100
Subject: [PATCH] pass templates directory to function

---
 bin/account-manager.pl.in           | 1 +
 lib/IdPAccountManager/Tools.pm      | 5 ++++-
 lib/IdPAccountManager/WebRequest.pm | 1 +
 3 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/bin/account-manager.pl.in b/bin/account-manager.pl.in
index 793ebc4..db27ca1 100755
--- a/bin/account-manager.pl.in
+++ b/bin/account-manager.pl.in
@@ -348,6 +348,7 @@ sub send_notice {
     die "Failed to send mail notice to $options{email_address}\n"
         unless IdPAccountManager::Tools::mail_notice(
             template            => 'templates/mail/notification_generic_error.tt2.eml',
+            templates_dir       => $configuration->{templates_dir},
             data                => {},
             to                  => $options{email_address},
             logger              => $logger,
diff --git a/lib/IdPAccountManager/Tools.pm b/lib/IdPAccountManager/Tools.pm
index ff1c86b..089b76e 100644
--- a/lib/IdPAccountManager/Tools.pm
+++ b/lib/IdPAccountManager/Tools.pm
@@ -153,7 +153,10 @@ sub mail_notice {
       . $args{notice_from}
       . " $notice_email";
 
-    my $tt2 = Template->new(FILTERS => { qencode => [ \qencode, 0 ] });
+    my $tt2 = Template->new({
+        FILTERS      => { qencode => [ \qencode, 0 ] },
+        INCLUDE_PATH => $args{templates_dir}
+    });
     unless ($tt2->process($tt2_file, $mail_data, \*SENDMAIL)) {
         $logger->errorf("Error TT2 : %s", $tt2->error());
     }
diff --git a/lib/IdPAccountManager/WebRequest.pm b/lib/IdPAccountManager/WebRequest.pm
index 333eca0..774b0d8 100755
--- a/lib/IdPAccountManager/WebRequest.pm
+++ b/lib/IdPAccountManager/WebRequest.pm
@@ -187,6 +187,7 @@ sub respond {
         $self->{out}->{subject} = 'Error notification - web interface';
         IdPAccountManager::Tools::mail_notice(
             template            => 'mail/notification_generic_error.tt2.eml',
+            templates_dir       => $self->{configuration}->{templates_dir},
             data                => $self->{out},
             logger              => $self->{logger},
             conf                => $self->{configuration},
-- 
GitLab