blob: 5022d4aaaee724208174558f78dbf0e74456dece (
plain)
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
|
<?php
use mystic\forum\orm\UserPermissions;
use mystic\forum\orm\Attachment;
$fileAttachments = array_filter($attachments, fn(Attachment $a) => !str_starts_with($a->mimeType, "image/"));
$imageAttachments = array_filter($attachments, fn(Attachment $a) => str_starts_with($a->mimeType, "image/"));
$canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false;
$canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST))
|| ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST));
$hide_actions ??= false;
$hide_pfp ??= false;
$your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
?>
<?php if ($post->deleted): ?>
<div class="media" id="post-<?= htmlentities($post->id) ?>">
<div class="media-left hidden-sm hidden-xs">
<div class="media-object" style="width:64px"></div>
</div>
<div class="media-body">
<div class="well icon-well text-warning">
<span class="glyphicon glyphicon-exclamation-sign color-warning" aria-hidden="true"></span>
<em>This post has been deleted</em>
</div>
</div>
</div>
<?php else: ?>
<div class="media" id="post-<?= htmlentities($post->id) ?>">
<?php if (!$hide_pfp): ?>
<div class="media-left hidden-sm hidden-xs">
<?php if ($postAuthor): ?>
<?php if ($hide_actions): ?>
<img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" alt="" width="64" height="64">
<?php else: ?>
<a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>">
<img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" alt="" width="64" height="64">
</a>
<?php endif; ?>
<?php else: ?>
<div class="media-object" style="width:64px;height:64px"></div>
<?php endif; ?>
</div>
<?php endif; ?>
<div class="media-body">
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<?php if (!$hide_actions): ?>
<div class="pull-right">
<?php if ($canReply): ?>
<a href="#post-<?= htmlentities(urlencode($post->id)) ?>" class="btn btn-default"><span class="glyphicon glyphicon-link" aria-hidden="true"></span><span class="sr-only">Permalink</span></a>
<button data-text="<?= htmlentities($post->content) ?>" class="btn btn-default js-only _reply-post"><span class="glyphicon glyphicon-share-alt" aria-hidden="true"></span><span class="sr-only">Reply to post</span></button>
<?php endif; ?>
<?php if ($canDelete): ?>
<form action="?_action=deletepost" method="post" class="seamless-inline">
<input type="hidden" name="post" value="<?= htmlentities($post->id) ?>">
<button type="submit" class="btn btn-danger"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span><span class="sr-only">Delete post</span></button>
</form>
<?php endif; ?>
</div>
<?php endif; ?>
<?php if ($postAuthor): ?>
<?php if ($hide_actions): ?>
<?= htmlentities($postAuthor->displayName) ?>
<?php else: ?>
<a href="?_action=viewuser&user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a>
<?php endif; ?>
<?php if ($your_are_the_author): ?>
<span class="text-normal label label-primary">You</span>
<?php endif; ?>
<?php else: ?>
<em class="text-muted">(deleted)</em>
<?php endif; ?>
</h3>
<span class="_time"><?= $post->postDate->format("c"); ?></span>
</div>
<div class="panel-body">
<div class="post-content"><?= renderPost($post->content) ?></div>
<?php if (count($imageAttachments) > 0): ?>
<div class="post-images clearfix">
<?php /** @var Attachment $attachment */ foreach ($imageAttachments as $attachment): ?>
<?php if ($hide_actions): ?>
<span class="image-attachment" title="<?= htmlentities($attachment->name) ?>">
<img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110">
</span>
<?php else: ?>
<a class="image-attachment" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>">
<img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110">
</a>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
</div>
<?php if (count($fileAttachments) > 0): ?>
<div class="panel-footer">
<div class="btn-group">
<?php /** @var Attachment $attachment */ foreach ($fileAttachments as $attachment): ?>
<?php if ($hide_actions): ?>
<button class="btn btn-default"><?= htmlentities($attachment->name) ?></button>
<?php else: ?>
<a class="btn btn-default" href="?_action=attachment&attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php endif; ?>
|