diff options
Diffstat (limited to 'src/application/views/view_post.php')
-rw-r--r-- | src/application/views/view_post.php | 26 |
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&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&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100"> </span> <?php else: ?> - <a class="image-attachment attachment" href="?_action=attachment&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&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" title="<?= htmlentities($attachment->name) ?>" data-attachment-id="<?= htmlentities($attachment->id) ?>"> <img class="image-attachment-image" src="?_action=thumb&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&attachment=<?= htmlentities(urlencode($attachment->id)) ?>"><?= htmlentities($attachment->name) ?></a> + <a class="btn btn-default attachment" href="?_action=attachment&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> |