2019-05-13 17:02:01 +00:00
|
|
|
<?php
|
2019-09-28 22:43:51 +00:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2019-05-13 17:02:01 +00:00
|
|
|
require_once '../../misuzu.php';
|
|
|
|
|
|
|
|
$postId = !empty($_GET['p']) && is_string($_GET['p']) ? (int)$_GET['p'] : 0;
|
|
|
|
$post = news_post_get($postId);
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if(!$post) {
|
2019-05-13 17:02:01 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($post['comment_section_id'] === null) {
|
2019-05-13 17:02:01 +00:00
|
|
|
$commentsInfo = comments_category_create("news-{$post['post_id']}");
|
|
|
|
|
2019-06-10 17:04:53 +00:00
|
|
|
if($commentsInfo) {
|
2019-05-13 17:02:01 +00:00
|
|
|
$post['comment_section_id'] = $commentsInfo['category_id'];
|
|
|
|
news_post_comments_set(
|
|
|
|
$post['post_id'],
|
|
|
|
$post['comment_section_id'] = $commentsInfo['category_id']
|
|
|
|
);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
$commentsInfo = comments_category_info($post['comment_section_id']);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tpl_render('news.post', [
|
|
|
|
'post' => $post,
|
|
|
|
'comments_perms' => comments_get_perms(user_session_current('user_id', 0)),
|
|
|
|
'comments_category' => $commentsInfo,
|
|
|
|
'comments' => comments_category_get($commentsInfo['category_id'], user_session_current('user_id', 0)),
|
|
|
|
]);
|