Added OP badge, closes #120.

This commit is contained in:
flash 2019-01-22 14:58:57 +01:00
parent d2e7984708
commit cdb8e75f72
3 changed files with 62 additions and 3 deletions

View file

@ -225,4 +225,39 @@
vertical-align: middle;
}
}
&__badge {
background-color: var(--accent-colour);
border-radius: 12px;
width: 100%;
padding: 2px;
box-shadow: 0 2px 3px #000A;
margin: 4px;
overflow: hidden;
@media (max-width: @site-mobile-width) {
width: auto;
padding: 2px 10px;
margin: 0;
align-self: flex-start;
margin-left: 5px;
font-size: .9em;
}
&__desktop {
display: block;
@media (max-width: @site-mobile-width) {
display: none;
}
}
&__mobile {
display: none;
@media (max-width: @site-mobile-width) {
display: block;
}
}
}
}

View file

@ -106,7 +106,14 @@ function forum_post_get(int $postId, bool $allowDeleted = false): array
SELECT MIN(`post_id`) = p.`post_id`
FROM `msz_forum_posts`
WHERE `topic_id` = p.`topic_id`
) AS `is_opening_post`
) AS `is_opening_post`,
(
SELECT `user_id` = u.`user_id`
FROM `msz_forum_posts`
WHERE `topic_id` = p.`topic_id`
ORDER BY `post_id`
LIMIT 1
) AS `is_original_poster`
FROM `msz_forum_posts` AS p
LEFT JOIN `msz_users` AS u
ON u.`user_id` = p.`user_id`
@ -146,7 +153,14 @@ function forum_post_listing(int $topicId, int $offset = 0, int $take = 0, bool $
SELECT MIN(`post_id`) = p.`post_id`
FROM `msz_forum_posts`
WHERE `topic_id` = p.`topic_id`
) AS `is_opening_post`
) AS `is_opening_post`,
(
SELECT `user_id` = u.`user_id`
FROM `msz_forum_posts`
WHERE `topic_id` = p.`topic_id`
ORDER BY `post_id`
LIMIT 1
) AS `is_original_poster`
FROM `msz_forum_posts` AS p
LEFT JOIN `msz_users` AS u
ON u.`user_id` = p.`user_id`

View file

@ -393,13 +393,23 @@
</a>
<a class="forum__post__username" href="/profile.php?u={{ post.poster_id }}">{{ post.poster_name }}</a>
<a class="forum__post__usertitle">{{ post.poster_title }}</a>
{% if post.poster_title|length > 0 %}
<div class="forum__post__usertitle">{{ post.poster_title }}</div>
{% endif %}
<div class="forum__post__icons">
<div class="flag flag--{{ post.poster_country|lower }}" title="{{ post.poster_country|country_name }}"></div>
<div class="forum__post__posts-count">{{ post.poster_post_count|number_format }} posts</div>
</div>
{% if post.is_original_poster %}
<div class="forum__post__badge forum__post__badge--original-poster">
<div class="forum__post__badge__desktop">Original Poster</div>
<div class="forum__post__badge__mobile">OP</div>
</div>
{% endif %}
<div class="forum__post__joined">
joined <time datetime="{{ post.poster_joined|date('c') }}" title="{{ post.poster_joined|date('r') }}">{{ post.poster_joined|time_diff }}</time>
</div>