summaryrefslogtreecommitdiff
path: root/src/application/views/view_post.php
diff options
context:
space:
mode:
authorJonas Kohl2024-09-16 19:32:09 +0200
committerJonas Kohl2024-09-16 19:32:09 +0200
commit6b7e714b59e28bc138681662006941274c3261af (patch)
treec683082c0a00681542db02d415bd45968f0a517b /src/application/views/view_post.php
parentfd3d969cf658475709db6a1e5090069cce51cbbd (diff)
A lot more stuff
Diffstat (limited to 'src/application/views/view_post.php')
-rw-r--r--src/application/views/view_post.php26
1 files changed, 22 insertions, 4 deletions
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php
index 510b22c..fe885bc 100644
--- a/src/application/views/view_post.php
+++ b/src/application/views/view_post.php
@@ -6,8 +6,10 @@ use mystic\forum\orm\Attachment;
/** @var mystic\forum\orm\Post $post */
/** @var mystic\forum\orm\User $postAuthor */
-$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/"));
+$isImage = fn(string $m) => str_starts_with($m, "image/") || str_starts_with($m, "video/");
+
+$fileAttachments = array_filter($attachments, fn(Attachment $a) => !$isImage($a->mimeType));
+$imageAttachments = array_filter($attachments, fn(Attachment $a) => $isImage($a->mimeType));
$canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false;
@@ -17,9 +19,12 @@ $canEdit = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->h
$canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST))
|| ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST));
+$canViewAttachments = $GLOBALS["currentUser"] !== null;
+
$hide_actions ??= false;
$hide_pfp ??= false;
$your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
+$is_op = $postAuthor?->id === $topicAuthor?->id && $postAuthor?->id !== null;
?>
@@ -78,6 +83,9 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
<?= htmlentities($postAuthor->displayName) ?>
<?php else: ?>
<a href="?_action=viewuser&amp;user=<?= htmlentities(urlencode($postAuthor->id)) ?>"><?= htmlentities($postAuthor->displayName) ?></a>
+ <?php if ($is_op): ?>
+ <span title="<?= __("Created this topic") ?>" class="text-info glyphicon glyphicon-comment"></span>
+ <?php endif; ?>
<?php endif; ?>
<?php if ($your_are_the_author): ?>
<span class="text-normal label label-primary"><?= __("You") ?></span>
@@ -101,8 +109,13 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
<img class="image-attachment-image" src="?_action=thumb&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100">
</span>
<?php else: ?>
- <a class="image-attachment attachment" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>">
+ <a class="image-attachment attachment<?php if (str_starts_with($attachment->mimeType, "video/")): ?> video-attachment<?php endif; ?>" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>" data-attachment-id="<?= htmlentities($attachment->id) ?>">
<img class="image-attachment-image" src="?_action=thumb&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100">
+ <?php if (!$canViewAttachments): ?>
+ <span class="attachment-lock glyphicon glyphicon-ban-circle" aria-hidden="true"></span>
+ <?php elseif (str_starts_with($attachment->mimeType, "video/")): ?>
+ <span class="video-player-icon glyphicon glyphicon-play" aria-hidden="true"></span>
+ <?php endif; ?>
</a>
<?php endif; ?>
<?php endforeach; ?>
@@ -116,7 +129,12 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id;
<?php if ($hide_actions): ?>
<button class="btn btn-default"><?= htmlentities($attachment->name) ?></button>
<?php else: ?>
- <a class="btn btn-default attachment" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a>
+ <a class="btn btn-default attachment" href="?_action=attachment&amp;attachment=<?= htmlentities(urlencode($attachment->id)) ?>">
+ <?php if (!$canViewAttachments): ?>
+ <span class="glyphicon glyphicon-ban-circle" aria-hidden="true"></span>
+ <?php endif; ?>
+ <?= htmlentities($attachment->name) ?>
+ </a>
<?php endif; ?>
<?php endforeach; ?>
</div>