WebOrbiton
v2.0.0.1

Publisium

83 lines · 3.1 KB
  1. <?php
  2. ​
  3. declare(strict_types=1);
  4. ​
  5. if (!AuthorProfile::isEnabled()) {
  6. echo '<p>Author pages are turned off. An administrator can enable them in Settings → Layout.</p>';
  7. return;
  8. }
  9. ​
  10. if (!Auth::canModerate()) {
  11. echo '<p>Only editors can review author pages.</p>';
  12. return;
  13. }
  14. ​
  15. $statement = Database::site()->query(
  16. "SELECT p.*, t.display_name, t.avatar_path
  17. FROM author_profiles p
  18. JOIN team_accounts t ON t.id = p.account_id
  19. WHERE p.status = 'pending'
  20. ORDER BY p.updated_at ASC"
  21. );
  22. $pendingProfiles = $statement->fetchAll();
  23. $wasPosted = $_SERVER['REQUEST_METHOD'] === 'POST' && ($_POST['action'] ?? '') === 'review_profile';
  24. ​
  25. ?>
  26. <h1 class="dash-title"><?= Icons::icon('user', 'icon icon-lg') ?>Artist reviews</h1>
  27. ​
  28. <?php if (empty($pendingProfiles)): ?>
  29. <p>No author pages are waiting for review.</p>
  30. <?php endif; ?>
  31. ​
  32. <?php foreach ($pendingProfiles as $pending): ?>
  33. <?php
  34. $accountId = (int) $pending['account_id'];
  35. $isPostedOne = $wasPosted && (int) ($_POST['account_id'] ?? 0) === $accountId;
  36. $form = $isPostedOne
  37. ? [
  38. 'headline' => (string) ($_POST['headline'] ?? ''),
  39. 'bio' => (string) ($_POST['bio'] ?? ''),
  40. 'website_url' => (string) ($_POST['website_url'] ?? ''),
  41. ]
  42. : AuthorProfile::formValues($pending);
  43. ?>
  44. <div class="sidebar-box" style="max-width:720px;margin-bottom:20px;">
  45. <p style="display:flex;align-items:center;gap:10px;margin-bottom:12px;">
  46. <?= Avatar::html($pending, 'dash-user-avatar') ?>
  47. <strong><?= htmlspecialchars($pending['display_name']) ?></strong>
  48. <span class="status-pill status-pending_review"><?= htmlspecialchars(AuthorProfile::statusLabel('pending')) ?></span>
  49. </p>
  50. ​
  51. <?php if ((int) $pending['is_public'] === 1): ?>
  52. <details style="margin-bottom:12px;">
  53. <summary>What’s live right now</summary>
  54. <p><strong><?= htmlspecialchars((string) $pending['headline']) ?></strong></p>
  55. <p><?= nl2br(htmlspecialchars((string) $pending['bio'])) ?></p>
  56. </details>
  57. <?php endif; ?>
  58. ​
  59. <form method="post">
  60. <?= Csrf::field() ?>
  61. <input type="hidden" name="action" value="review_profile">
  62. <input type="hidden" name="account_id" value="<?= $accountId ?>">
  63. ​
  64. <label>Headline</label>
  65. <input type="text" name="headline" maxlength="<?= AuthorProfile::HEADLINE_MAX ?>" value="<?= htmlspecialchars($form['headline']) ?>">
  66. ​
  67. <label>Bio (you can edit it before approving)</label>
  68. <textarea name="bio" rows="8" maxlength="<?= AuthorProfile::BIO_MAX ?>"><?= htmlspecialchars($form['bio']) ?></textarea>
  69. ​
  70. <label>Website</label>
  71. <input type="url" name="website_url" maxlength="<?= AuthorProfile::URL_MAX ?>" value="<?= htmlspecialchars($form['website_url']) ?>" placeholder="https://">
  72. ​
  73. <label>Note for the author (only if you send it back)</label>
  74. <input type="text" name="rejection_reason" maxlength="<?= AuthorProfile::REASON_MAX ?>" value="">
  75. ​
  76. <div class="publish-actions">
  77. <button type="submit" name="decision" value="approve" class="dash-btn dash-btn-primary"><?= Icons::icon('check', 'icon icon-sm') ?>Approve and publish</button>
  78. <button type="submit" name="decision" value="reject" class="dash-btn dash-btn-danger"><?= Icons::icon('x', 'icon icon-sm') ?>Send back</button>
  79. </div>
  80. </form>
  81. </div>
  82. <?php endforeach; ?>
  83. ​