From 95bfdb59b6a1e04e474551c23c7caef619c79839 Mon Sep 17 00:00:00 2001 From: Jonas Kohl Date: Thu, 19 Sep 2024 14:19:35 +0200 Subject: Topic locking --- src/application/views/view_post.php | 3 +++ src/application/views/view_search_results.php | 4 +++- src/application/views/view_topic_locked.php | 4 ++++ src/application/views/view_topic_start.php | 31 ++++++++++++++++++++++++++- src/application/views/view_topics.php | 7 +++++- src/application/views/view_user.php | 4 +++- 6 files changed, 49 insertions(+), 4 deletions(-) create mode 100644 src/application/views/view_topic_locked.php (limited to 'src/application/views') diff --git a/src/application/views/view_post.php b/src/application/views/view_post.php index 62b2d18..0f86896 100644 --- a/src/application/views/view_post.php +++ b/src/application/views/view_post.php @@ -5,6 +5,7 @@ use mystic\forum\orm\Attachment; /** @var mystic\forum\orm\Post $post */ /** @var mystic\forum\orm\User $postAuthor */ +/** @var mystic\forum\orm\Topic $topic */ $isImage = fn(string $m) => str_starts_with($m, "image/") || str_starts_with($m, "video/"); @@ -16,6 +17,8 @@ $canReply = $GLOBALS["currentUser"]?->hasPermission(UserPermissions::CREATE_OWN_ $canEdit = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::EDIT_OWN_POST)) || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::EDIT_OTHER_POST)); +$canEdit = $canEdit && !$topic->isLocked; + $canDelete = ($GLOBALS["currentUser"]?->id === $postAuthor?->id && $postAuthor?->hasPermission(UserPermissions::DELETE_OWN_POST)) || ($GLOBALS["currentUser"]?->hasPermission(UserPermissions::DELETE_OTHER_POST)); diff --git a/src/application/views/view_search_results.php b/src/application/views/view_search_results.php index e21fbb8..914d2b2 100644 --- a/src/application/views/view_search_results.php +++ b/src/application/views/view_search_results.php @@ -20,7 +20,9 @@ use mystic\forum\utils\StringUtils; = __("posted by %author% on %post_date% in %topic%", [ "author" => '' . htmlentities($users[$post->authorId]?->displayName ?? __("unknown")) . '', "post_date" => '' . htmlentities($post->postDate->format("c")) . '', - "topic" => '' . htmlentities($topics[$post->topicId]?->title ?? "unknown") . '', + "topic" => '' + . ($topics[$post->topicId]?->isLocked ? ' ' : '') + . htmlentities($topics[$post->topicId]?->title ?? "unknown") . '', ]) ?> diff --git a/src/application/views/view_topic_locked.php b/src/application/views/view_topic_locked.php new file mode 100644 index 0000000..ac59fcb --- /dev/null +++ b/src/application/views/view_topic_locked.php @@ -0,0 +1,4 @@ +