-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhistory.php
More file actions
44 lines (44 loc) · 1.65 KB
/
Copy pathhistory.php
File metadata and controls
44 lines (44 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
declare(strict_types=1);
$import = ['auth', 'view', 'html', 'writ', 'user'];
require __DIR__ . '/lib/boot.php';
$u = $app->auth->requireUser();
$wid = (int) ($_GET['w'] ?? 0);
$w = $app->writ->find($wid);
if (!$w) {
$app->redirect('');
}
$mine = (int) $w['writer_id'] === $app->auth->id();
if (!$mine && !$app->auth->atLeast('editor') && !$app->auth->is('observer')) {
$app->redirect('');
}
$sess = (string) ($_SESSION['pw_dash'] ?? '');
$app->view->start('History', $sess === 'editor' ? 'ewrits' : ($sess === 'admin' ? 'blocks' : 'writs'), 'auto');
echo '<h2 class="lt">History — ' . h($w['title']) . '</h2>';
$back = 'writ.php?w=' . $wid;
if ($sess === 'editor') {
$back = 'review.php?w=' . $wid;
}
echo '<p>' . button('Back to writ', 'Open', $back, 'set_gray') . '</p>';
$drafts = json_arr($w['drafts']);
$redrafts = json_arr($w['redrafts']);
echo '<h3 class="lt">Writer drafts</h3>';
if (!$drafts) {
echo '<p class="sans dk">None stored yet.</p>';
}
foreach (array_reverse($drafts) as $i => $d) {
echo '<h4 class="review">' . h($d['at'] ?? '') . ' · ' . (int) ($d['wordcount'] ?? 0) . ' words</h4>';
echo '<section class="writcontent draft">' . nl_text($d['body'] ?? '') . '</section>';
}
echo '<h3 class="lt">Editor redrafts</h3>';
if (!$redrafts) {
echo '<p class="sans dk">None stored yet.</p>';
}
foreach (array_reverse($redrafts) as $d) {
echo '<h4 class="review">' . h($d['at'] ?? '') . '</h4>';
if (!empty($d['notes'])) {
echo '<section class="writcontent remarks">' . nl_text($d['notes']) . '</section>';
}
echo '<section class="writcontent revision">' . nl_text($d['body'] ?? '') . '</section>';
}
$app->view->end();