<?php
namespace Misuzu;

if(!$msz->getAuthInfo()->getPerms('global')->check(Perm::G_NEWS_POSTS_MANAGE))
    Template::throwError(403);

$news = $msz->getNews();
$pagination = new Pagination($news->countPosts(
    includeScheduled: true,
    includeDeleted: true
), 15);

if(!$pagination->hasValidOffset())
    Template::throwError(404);

$posts = $news->getPosts(
    includeScheduled: true,
    includeDeleted: true,
    pagination: $pagination
);

Template::render('manage.news.posts', [
    'news_posts' => $posts,
    'posts_pagination' => $pagination,
]);
