Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
simplesamlphp
Manage
Activity
Members
Labels
Plan
Jira
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Perun
Perun ProxyIdP
v1
simplesamlphp
Commits
4c6ce956
Commit
4c6ce956
authored
5 years ago
by
Tim van Dijen
Browse files
Options
Downloads
Patches
Plain Diff
Fix EMail-class in a backwards compatible way, without enforcing Twig on oldui
parent
b18397e7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
lib/SimpleSAML/Utils/EMail.php
+36
-13
36 additions, 13 deletions
lib/SimpleSAML/Utils/EMail.php
with
36 additions
and
13 deletions
lib/SimpleSAML/Utils/EMail.php
+
36
−
13
View file @
4c6ce956
...
@@ -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
;
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment