Merge pull request #787 from merlijnvanlent/master

Ability to view emails within the intranet dashboard.
This commit is contained in:
cytopia 2021-05-21 15:31:13 +02:00 committed by GitHub
commit fa0c8f5632
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 38 additions and 8 deletions

View File

@ -0,0 +1,21 @@
class HtmlEmail extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: 'open' });
let emailContent;
try {
emailContent = window.atob(this.dataset.content);
} catch (error) {
console.log(error);
return;
}
const container = document.createElement('div');
container.innerHTML = emailContent;
this.shadowRoot.appendChild(container);
}
}
customElements.define('html-email', HtmlEmail);

View File

@ -159,6 +159,17 @@ $messages = $MyMbox->get($sortOrderArr);
<?php
$message = htmlentities($data['raw']);
$structure = $data['decoded'];
$body = null;
if (isset($structure->body)) {
$body = $structure->body;
}
elseif(isset($structure->parts[1]->body)) {
$body = $structure->parts[1]->body;
}
elseif(isset($structure->parts[0]->body)) {
$body = $structure->parts[0]->body;
}
?>
<tr id="<?php echo $data['num'];?>" class="subject">
<td><?php echo $data['num'];?></td>
@ -174,16 +185,13 @@ $messages = $MyMbox->get($sortOrderArr);
<tr id="mail-<?php echo $data['num'];?>" style="display:none">
<td></td>
<td colspan="4">
<?php if (isset($structure->body)): ?>
<?php echo htmlentities($structure->body) ?>
<?php elseif(isset($structure->parts[1]->body)): ?>
<?php echo htmlentities($structure->parts[1]->body) ?>
<?php elseif(isset($structure->parts[0]->body)): ?>
<?php echo htmlentities($structure->parts[0]->body) ?>
<?php if ($body !== null): ?>
<html-email data-content="<?php echo base64_encode($body) ?>">
</html-email>
<?php else: ?>
<?php echo '<div class="alert alert-warning" role="alert">
<div class="alert alert-warning" role="alert">
No valid body found
</div>' ?>
</div>
<?php endif; ?>
<hr>
<p><a class="btn btn-primary" data-toggle="collapse" href="#email-<?php echo $data['num'];?>" aria-expanded="false" aria-controls="email-<?php echo $data['num'];?>">Raw source</a></p>
@ -215,5 +223,6 @@ $messages = $MyMbox->get($sortOrderArr);
// Handler for .ready() called.
});
</script>
<script src="/assets/js/html-email.js"></script>
</body>
</html>