v1.0.0.8
Publisium
- <?php
-
- declare(strict_types=1);
-
- $db = Database::site();
- $isAdmin = Auth::hasRoleAtLeast(Auth::ROLE_EDITOR_IN_CHIEF);
-
- $statement = $isAdmin
- ? $db->query('SELECT a.id, a.title, a.trashed_status, a.deleted_at, COALESCE(t.display_name, a.author_name) AS display_name, a.author_id AS owner_id FROM articles a LEFT JOIN team_accounts t ON t.id = a.author_id WHERE a.deleted_at IS NOT NULL ORDER BY a.deleted_at DESC')
- : $db->prepare('SELECT a.id, a.title, a.trashed_status, a.deleted_at, COALESCE(t.display_name, a.author_name) AS display_name, a.author_id AS owner_id FROM articles a LEFT JOIN team_accounts t ON t.id = a.author_id WHERE a.deleted_at IS NOT NULL AND a.author_id = :id ORDER BY a.deleted_at DESC');
-
- if (!$isAdmin) {
- $statement->execute(['id' => $currentUser['id']]);
- }
-
- $trashed = $statement->fetchAll();
-
- ?>
- <div class="dash-header-row">
- <h1 class="dash-title"><?= Icons::icon('trash', 'icon icon-lg') ?>Trash</h1>
- <a href="dashboard.php?view=articles" class="dash-btn"><?= Icons::icon('articles', 'icon icon-sm') ?>Back to articles</a>
- <?php if (!empty($trashed)): ?>
- <form method="post" style="display:inline;" onsubmit="return confirm('Delete everything in the trash for good? You won\'t be able to get it back.');">
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="empty_trash">
- <button type="submit" class="dash-btn dash-btn-danger"><?= Icons::icon('trash', 'icon icon-sm') ?>Empty trash</button>
- </form>
- <?php endif; ?>
- </div>
-
- <table class="dash-table">
- <thead>
- <tr>
- <th><?= Icons::icon('heading', 'icon icon-sm') ?>Title</th>
- <th><?= Icons::icon('user', 'icon icon-sm') ?>Author</th>
- <th><?= Icons::icon('flag', 'icon icon-sm') ?>Status before</th>
- <th><?= Icons::icon('clock', 'icon icon-sm') ?>Deleted</th>
- <th></th>
- </tr>
- </thead>
- <tbody>
- <?php foreach ($trashed as $article): ?>
- <tr>
- <td><?= htmlspecialchars($article['title']) ?></td>
- <td><?= htmlspecialchars((string) ($article['display_name'] ?? 'System')) ?><?php if ($article['owner_id'] === null): ?> <span class="status-pill status-draft" title="The author's account was removed. The article stays on the site under their name.">system</span><?php endif; ?></td>
- <td><?= htmlspecialchars(dashStatusLabel((string) ($article['trashed_status'] ?? 'draft'))) ?></td>
- <td><?= htmlspecialchars($article['deleted_at']) ?></td>
- <td class="dash-table-actions">
- <form method="post" style="display:inline;">
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="restore_article">
- <input type="hidden" name="article_id" value="<?= (int) $article['id'] ?>">
- <button type="submit" class="dash-btn-small dash-btn-success"><?= Icons::icon('refresh', 'icon icon-sm') ?>Restore</button>
- </form>
- <form method="post" style="display:inline;" onsubmit="return confirm('Delete this article for good? You won\'t be able to get it back.');">
- <?= Csrf::field() ?>
- <input type="hidden" name="action" value="purge_article">
- <input type="hidden" name="article_id" value="<?= (int) $article['id'] ?>">
- <button type="submit" class="dash-btn-small dash-btn-danger"><?= Icons::icon('trash', 'icon icon-sm') ?>Delete forever</button>
- </form>
- </td>
- </tr>
- <?php endforeach; ?>
- <?php if (empty($trashed)): ?>
- <tr><td colspan="5">The trash is empty. Deleted articles land here first, so you can still bring them back.</td></tr>
- <?php endif; ?>
- </tbody>
- </table>
-