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 <?php
$message = htmlentities($data['raw']); $message = htmlentities($data['raw']);
$structure = $data['decoded']; $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"> <tr id="<?php echo $data['num'];?>" class="subject">
<td><?php echo $data['num'];?></td> <td><?php echo $data['num'];?></td>
@ -174,16 +185,13 @@ $messages = $MyMbox->get($sortOrderArr);
<tr id="mail-<?php echo $data['num'];?>" style="display:none"> <tr id="mail-<?php echo $data['num'];?>" style="display:none">
<td></td> <td></td>
<td colspan="4"> <td colspan="4">
<?php if (isset($structure->body)): ?> <?php if ($body !== null): ?>
<?php echo htmlentities($structure->body) ?> <html-email data-content="<?php echo base64_encode($body) ?>">
<?php elseif(isset($structure->parts[1]->body)): ?> </html-email>
<?php echo htmlentities($structure->parts[1]->body) ?>
<?php elseif(isset($structure->parts[0]->body)): ?>
<?php echo htmlentities($structure->parts[0]->body) ?>
<?php else: ?> <?php else: ?>
<?php echo '<div class="alert alert-warning" role="alert"> <div class="alert alert-warning" role="alert">
No valid body found No valid body found
</div>' ?> </div>
<?php endif; ?> <?php endif; ?>
<hr> <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> <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. // Handler for .ready() called.
}); });
</script> </script>
<script src="/assets/js/html-email.js"></script>
</body> </body>
</html> </html>