Skip to content
Snippets Groups Projects
Commit 4c6ce956 authored by Tim van Dijen's avatar Tim van Dijen
Browse files

Fix EMail-class in a backwards compatible way, without enforcing Twig on oldui

parent b18397e7
No related branches found
No related tags found
No related merge requests found
...@@ -252,22 +252,45 @@ class EMail ...@@ -252,22 +252,45 @@ class EMail
*/ */
public function generateBody($template) public function generateBody($template)
{ {
// Force mail template to be rendered by Twig, even when using oldui $config = Configuration::getInstance();
// Replace this with the following line of code in 2.0 $newui = $config->getBoolean('usenewui', false);
// $config = Configuration::getInstance();
$config = Configuration::loadFromArray([ if ($newui === false) {
'usenewui' => true, return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
]); "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
$t = new Template($config, $template); <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
$twig = $t->getTwig(); <head>
if (!isset($twig)) { <meta http-equiv="content-type" content="text/html; charset=utf-8" />
throw new \Exception('Even though we explicitly configure that we want Twig, the Template class does not give us Twig. This is a bug.'); <title>SimpleSAMLphp Email report</title>
} <style type="text/css">
$result = $twig->render($template, [ pre, div.box {
margin: .4em 2em .4em 1em;
padding: 4px;
}
pre {
background: #eee;
border: 1px solid #aaa;
}
</style>
</head>
<body>
<div class="container" style="background: #fafafa; border: 1px solid #eee; margin: 2em; padding: .6em;">
'.$this->text.'
</div>
</body>
</html>';
} else {
$t = new Template($config, $template);
$twig = $t->getTwig();
if (!isset($twig)) {
throw new \Exception('Even though we explicitly configure that we want Twig, the Template class does not give us Twig. This is a bug.');
}
$result = $twig->render($template, [
'subject' => $this->mail->Subject, 'subject' => $this->mail->Subject,
'text' => $this->text, 'text' => $this->text,
'data' => $this->data 'data' => $this->data
]); ]);
return $result; return $result;
}
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment