implemented admin overview correctly. fixes #58

This commit is contained in:
Chris 2023-11-12 09:53:34 +01:00
parent 2559d0c45d
commit fac68fe552
2 changed files with 8 additions and 0 deletions

View file

@ -191,6 +191,7 @@ class OpenTrashmailBackend{
$emails = getEmailsOfEmail($email);
//var_dump($emails);
return $this->renderTemplate('email-table.html',[
'isadmin'=>($this->settings['ADMIN']==$email),
'email'=>$email,
'emails'=>$emails,
'dateformat'=>$this->settings['DATEFORMAT']

View file

@ -18,6 +18,7 @@
<th scope="col">#</th>
<th scope="col">Date</th>
<th scope="col">From</th>
<?php if($isadmin==true): ?><th scope="col">To</th><?php endif; ?>
<th scope="col">Subject</th>
<th scope="col">Action</th>
</tr>
@ -35,10 +36,16 @@
<th scope="row"><?= ++$i; ?></th>
<td id="date-td-<?= $i ?>"><script>document.getElementById('date-td-<?= $i ?>').innerHTML = moment.unix(parseInt(<?=$unixtime?>/1000)).format('<?= $dateformat; ?>');</script></td>
<td><?= escape($ed['from']) ?></td>
<?php if($isadmin==true): ?><td><?= $ed['email'] ?></td><?php endif; ?>
<td><?= escape($ed['subject']) ?></td>
<td>
<?php if($isadmin==true): ?>
<a href="/read/<?= $ed['email'] ?>/<?= $ed['id'] ?>" hx-get="/api/read/<?= $ed['email'] ?>/<?= $ed['id'] ?>" hx-push-url="/read/<?= $ed['email'] ?>/<?= $ed['id'] ?>" hx-target="#main" role="button">Open</a>
<a href="#" hx-get="/api/delete/<?= $ed['email'] ?>/<?= $ed['id'] ?>" hx-confirm="Are you sure?" hx-target="closest tr" hx-swap="outerHTML swap:1s" role="button">Delete</a>
<?php else: ?>
<a href="/read/<?= $email ?>/<?= $ed['id'] ?>" hx-get="/api/read/<?= $email ?>/<?= $ed['id'] ?>" hx-push-url="/read/<?= $email ?>/<?= $ed['id'] ?>" hx-target="#main" role="button">Open</a>
<a href="#" hx-get="/api/delete/<?= $email ?>/<?= $ed['id'] ?>" hx-confirm="Are you sure?" hx-target="closest tr" hx-swap="outerHTML swap:1s" role="button">Delete</a>
<?php endif; ?>
</td>
</tr>
<?php endforeach; ?>