diff options
author | Jonas Kohl | 2024-09-14 17:59:13 +0200 |
---|---|---|
committer | Jonas Kohl | 2024-09-14 17:59:13 +0200 |
commit | d8b74761c6cefdd83360d3f2add0e9ccdc6064c7 (patch) | |
tree | 5e2c947b4a90ae475a7e75897077246e5ea0a948 /src/application/views/view_post.php | |
parent | 948cead0f11d33adbcf0d08773c716e1b6ebb101 (diff) |
Even more changes (devel commit messages are useless)
Diffstat (limited to 'src/application/views/view_post.php')
-rw-r--r-- | src/application/views/view_post.php | 32 |
1 files changed, 22 insertions, 10 deletions
diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php index 5022d4a..26eec62 100644 --- a/src/application/views/view_post.php +++ b/src/application/views/view_post.php @@ -3,11 +3,17 @@ use mystic\forum\orm\UserPermissions; 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/")); $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_POST) ?? false; +$canEdit = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::EDIT_OWN_POST)) + || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_POST)); + $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST)) || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST)); @@ -30,15 +36,15 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id; </div> </div> <?php else: ?> -<div class="media" id="post-<?= htmlentities($post->id) ?>"> +<div class="media" id="post-<?= htmlentities($post->id) ?>" data-text="<?= htmlentities($post->content) ?>"> <?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"> + <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" 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"> + <img class="media-object" alt="Profile picture" src="?_action=profilepicture&user=<?= htmlentities(urlencode($postAuthor->id)) ?>" width="64" height="64"> </a> <?php endif; ?> <?php else: ?> @@ -49,12 +55,15 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id; <div class="media-body"> <div class="panel panel-default"> <div class="panel-heading"> - <h3 class="panel-title"> + <div class="panel-title h3"> <?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 if ($canReply): ?> + <button data-post-id="<?= htmlentities($post->id) ?>" 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 ($canEdit): ?> + <button data-post-id="<?= htmlentities($post->id) ?>" class="btn btn-default js-only _edit-post"><span class="glyphicon glyphicon-pencil" aria-hidden="true"></span><span class="sr-only">Edit post</span></button> <?php endif; ?> <?php if ($canDelete): ?> <form action="?_action=deletepost" method="post" class="seamless-inline"> @@ -76,21 +85,24 @@ $your_are_the_author = $GLOBALS["currentUser"]?->id === $postAuthor?->id; <?php else: ?> <em class="text-muted">(deleted)</em> <?php endif; ?> - </h3> + </div> <span class="_time"><?= $post->postDate->format("c"); ?></span> + <?php if ($post->edited): ?> + <em class="text-muted">(edited)</em> + <?php endif; ?> </div> <div class="panel-body"> - <div class="post-content"><?= renderPost($post->content) ?></div> + <div class="post-content"><?= renderPost(trim($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"> + <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100"> </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"> + <img class="image-attachment-image" src="?_action=thumb&attachment=<?= htmlentities(urlencode($attachment->id)) ?>" alt="" width="100"> </a> <?php endif; ?> <?php endforeach; ?> |