<?php
namespace Misuzu;

use Misuzu\Users\User;

if(!User::hasCurrent() || !perms_check_user(MSZ_PERMS_NEWS, User::getCurrent()->getId(), MSZ_PERM_NEWS_MANAGE_CATEGORIES)) {
    echo render_error(403);
    return;
}

$news = $msz->getNews();
$pagination = new Pagination($news->countAllCategories(true), 15);

if(!$pagination->hasValidOffset()) {
    echo render_error(404);
    return;
}

$categories = $news->getAllCategories(true, $pagination);

Template::render('manage.news.categories', [
    'news_categories' => $categories,
    'categories_pagination' => $pagination,
]);
