2023-04-30 00:18:14 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-09-06 20:06:07 +00:00
|
|
|
$authInfo = $msz->getAuthInfo();
|
|
|
|
if(!$authInfo->getPerms('global')->check(Perm::G_FORUM_TOPIC_REDIRS_MANAGE))
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(403);
|
2023-04-30 00:18:14 +00:00
|
|
|
|
2023-09-08 13:22:46 +00:00
|
|
|
$forumCtx = $msz->getForumContext();
|
|
|
|
$forumTopicRedirects = $forumCtx->getTopicRedirects();
|
2023-08-28 01:17:34 +00:00
|
|
|
|
2023-04-30 00:18:14 +00:00
|
|
|
if($_SERVER['REQUEST_METHOD'] === 'POST') {
|
|
|
|
if(!CSRF::validateRequest())
|
|
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
|
2023-08-28 01:17:34 +00:00
|
|
|
$rTopicId = (string)filter_input(INPUT_POST, 'topic_redir_id');
|
2023-04-30 00:18:14 +00:00
|
|
|
$rTopicURL = trim((string)filter_input(INPUT_POST, 'topic_redir_url'));
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
$msz->createAuditLog('FORUM_TOPIC_REDIR_CREATE', [$rTopicId]);
|
2023-09-08 13:22:46 +00:00
|
|
|
$forumTopicRedirects->createTopicRedirect($rTopicId, $authInfo->getUserInfo(), $rTopicURL);
|
2023-04-30 00:18:14 +00:00
|
|
|
url_redirect('manage-forum-topic-redirs');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(filter_input(INPUT_GET, 'm') === 'explode') {
|
|
|
|
if(!CSRF::validateRequest())
|
|
|
|
throw new \Exception("Request verification failed.");
|
|
|
|
|
2023-08-28 01:17:34 +00:00
|
|
|
$rTopicId = (string)filter_input(INPUT_GET, 't');
|
2023-07-17 17:43:17 +00:00
|
|
|
$msz->createAuditLog('FORUM_TOPIC_REDIR_REMOVE', [$rTopicId]);
|
2023-09-08 13:22:46 +00:00
|
|
|
$forumTopicRedirects->deleteTopicRedirect($rTopicId);
|
2023-04-30 00:18:14 +00:00
|
|
|
url_redirect('manage-forum-topic-redirs');
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-09-08 13:22:46 +00:00
|
|
|
$pagination = new Pagination($forumTopicRedirects->countTopicRedirects(), 20);
|
2023-08-31 15:59:53 +00:00
|
|
|
if(!$pagination->hasValidOffset())
|
|
|
|
Template::throwError(404);
|
2023-04-30 00:18:14 +00:00
|
|
|
|
2023-09-08 13:22:46 +00:00
|
|
|
$redirs = $forumTopicRedirects->getTopicRedirects(pagination: $pagination);
|
2023-04-30 00:18:14 +00:00
|
|
|
|
|
|
|
Template::render('manage.forum.redirs', [
|
|
|
|
'manage_redirs' => $redirs,
|
|
|
|
'manage_redirs_pagination' => $pagination,
|
|
|
|
]);
|