2019-06-09 22:10:59 +00:00
|
|
|
<?php
|
2019-09-28 22:43:51 +00:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2019-06-09 22:10:59 +00:00
|
|
|
require_once '../../../misuzu.php';
|
|
|
|
|
|
|
|
if(!perms_check_user(MSZ_PERMS_NEWS, user_session_current('user_id'), MSZ_PERM_NEWS_MANAGE_CATEGORIES)) {
|
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
$category = [];
|
|
|
|
$categoryId = (int)($_GET['c'] ?? null);
|
|
|
|
|
2019-06-10 15:21:53 +00:00
|
|
|
if(!empty($_POST['category']) && csrf_verify_request()) {
|
2019-06-09 22:10:59 +00:00
|
|
|
$originalCategoryId = (int)($_POST['category']['id'] ?? null);
|
|
|
|
$categoryId = news_category_create(
|
|
|
|
$_POST['category']['name'] ?? null,
|
|
|
|
$_POST['category']['description'] ?? null,
|
|
|
|
!empty($_POST['category']['hidden']),
|
|
|
|
$originalCategoryId
|
|
|
|
);
|
|
|
|
|
|
|
|
audit_log(
|
|
|
|
$originalCategoryId === $categoryId
|
|
|
|
? MSZ_AUDIT_NEWS_CATEGORY_EDIT
|
|
|
|
: MSZ_AUDIT_NEWS_CATEGORY_CREATE,
|
|
|
|
user_session_current('user_id'),
|
|
|
|
[$categoryId]
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if($categoryId > 0) {
|
|
|
|
$category = news_category_get($categoryId);
|
|
|
|
}
|
|
|
|
|
|
|
|
echo tpl_render('manage.news.category', compact('category'));
|