summaryrefslogtreecommitdiff
path: root/src/application/views/view_post.php
diff options
context:
space:
mode:
authorJonas Kohl2024-09-12 19:49:17 +0200
committerJonas Kohl2024-09-12 19:49:17 +0200
commit086e2d2668784469ec114f6e6fd2b3dace3d7c3b (patch)
treeb9bacedb713501d88d24085940267a7c94e69b29 /src/application/views/view_post.php
parent34b1b391d4b03659a96f868857c230002b351514 (diff)
Way more progress on forum
Diffstat (limited to 'src/application/views/view_post.php')
-rw-r--r--src/application/views/view_post.php86
1 files changed, 86 insertions, 0 deletions
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php
new file mode 100644
index 0000000..0776fb5
--- /dev/null
+++ b/src/application/views/view_post.php
@@ -0,0 +1,86 @@
+<?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));
+
+?>
+
+<?php if ($post->deleted): ?>
+<div class="media">
+<div class="media-left hidden-sm hidden-xs">
+ <div class="media-object" style="width:64px"></div>
+</div>
+<div class="media-body">
+ <div class="well">
+ <em>This post has been deleted</em>
+ </div>
+</div>
+</div>
+<?php else: ?>
+<div class="media">
+ <div class="media-left hidden-sm hidden-xs">
+ <?php if ($postAuthor): ?>
+ <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>">
+ <img class="media-object" src="/ui/placeholder.svg" alt="" width="64" height="64">
+ </a>
+ <?php else: ?>
+ <div class="media-object" style="width:64px;height:64px"></div>
+ <?php endif; ?>
+ </div>
+ <div class="media-body">
+ <div class="panel panel-default">
+ <div class="panel-heading">
+ <h3 class="panel-title">
+ <div class="pull-right">
+ <?php if ($canReply): ?>
+ <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 if ($postAuthor): ?>
+ <a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a>
+ <?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): ?>
+ <a class="image-attachment" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>">
+ <img class="image-attachment-image" src="?_action=thumb&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="110">
+ </a>
+ <?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): ?>
+ <a class="btn btn-default" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a>
+ <?php endforeach; ?>
+ </div>
+ </div>
+ <?php endif; ?>
+ </div>
+ </div>
+</div>
+
+<?php endif; ?>