Use proper ability functions in forum.php.

This commit is contained in:
flash 2018-10-18 23:54:21 +02:00
parent 3d5674dac8
commit 670d672807
2 changed files with 14 additions and 7 deletions

View file

@ -32,19 +32,26 @@ if ($forum['forum_type'] == MSZ_FORUM_TYPE_LINK) {
return;
}
$topics = forum_may_have_topics($forum['forum_type'])
$forumMayHaveTopics = forum_may_have_topics($forum['forum_type']);
$topics = $forumMayHaveTopics
? forum_topic_listing($forum['forum_id'], user_session_current('user_id', 0), $topicsOffset, $topicsRange)
: [];
$forumMayHaveChildren = forum_may_have_children($forum['forum_type']);
if ($forumMayHaveChildren) {
$forum['forum_subforums'] = forum_get_children($forum['forum_id'], user_session_current('user_id', 0));
foreach ($forum['forum_subforums'] as $skey => $subforum) {
$forum['forum_subforums'][$skey]['forum_subforums']
= forum_get_children($subforum['forum_id'], user_session_current('user_id', 0), true);
}
}
echo tpl_render('forum.forum', [
'forum_breadcrumbs' => forum_get_breadcrumbs($forum['forum_id']),
'forum_may_have_topics' => $forumMayHaveTopics,
'forum_may_have_children' => $forumMayHaveChildren,
'forum_info' => $forum,
'forum_topics' => $topics,
'forum_offset' => $topicsOffset,

View file

@ -12,11 +12,11 @@
<div style="{{ forum_info.forum_colour|html_colour('--accent-colour') }}">
{{ forum_header(forum_info.forum_name, forum_breadcrumbs, true) }}
{% if forum_info.forum_subforums|length > 0 or forum_info.forum_type == 1 %}
{% if forum_may_have_children and forum_info.forum_subforums|length > 0 %}
{{ forum_category_listing(forum_info.forum_subforums, 'Forums') }}
{% endif %}
{% if forum_info.forum_type == 0 %}
{% if forum_may_have_topics %}
{% set fcbuttons = current_user is defined ? forum_category_buttons(forum_info, forum_perms) : '' %}
{% set fcpagination = pagination(
forum_info.forum_topic_count,