2023-07-26 18:19:46 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
use RuntimeException;
|
|
|
|
|
2024-12-02 02:28:08 +00:00
|
|
|
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|
|
|
die('Script must be called through the Misuzu route dispatcher.');
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if(!$msz->authInfo->getPerms('user')->check(Perm::U_BANS_MANAGE))
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(403);
|
2023-07-26 18:19:46 +00:00
|
|
|
|
|
|
|
$filterUser = null;
|
|
|
|
if(filter_has_var(INPUT_GET, 'u')) {
|
2023-08-02 22:12:47 +00:00
|
|
|
$filterUserId = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_NUMBER_INT);
|
2023-07-26 18:19:46 +00:00
|
|
|
try {
|
2024-11-30 04:09:29 +00:00
|
|
|
$filterUser = $msz->usersCtx->getUserInfo($filterUserId);
|
2023-07-26 18:19:46 +00:00
|
|
|
} catch(RuntimeException $ex) {
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(404);
|
2023-07-26 18:19:46 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$pagination = new Pagination($msz->usersCtx->bans->countBans(userInfo: $filterUser), 10);
|
2023-07-26 18:19:46 +00:00
|
|
|
|
2023-08-31 15:59:53 +00:00
|
|
|
if(!$pagination->hasValidOffset())
|
|
|
|
Template::throwError(404);
|
2023-07-26 18:19:46 +00:00
|
|
|
|
|
|
|
$banList = [];
|
2024-11-30 04:09:29 +00:00
|
|
|
$banInfos = $msz->usersCtx->bans->getBans(userInfo: $filterUser, activeFirst: true, pagination: $pagination);
|
2023-07-26 18:19:46 +00:00
|
|
|
|
|
|
|
foreach($banInfos as $banInfo) {
|
2024-11-30 04:09:29 +00:00
|
|
|
$userInfo = $msz->usersCtx->getUserInfo($banInfo->userId);
|
|
|
|
$userColour = $msz->usersCtx->getUserColour($userInfo);
|
2023-08-02 22:12:47 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if($banInfo->modId === null) {
|
2023-08-02 22:12:47 +00:00
|
|
|
$modInfo = null;
|
|
|
|
$modColour = null;
|
|
|
|
} else {
|
2024-11-30 04:09:29 +00:00
|
|
|
$modInfo = $msz->usersCtx->getUserInfo($banInfo->modId);
|
|
|
|
$modColour = $msz->usersCtx->getUserColour($modInfo);
|
2023-08-02 22:12:47 +00:00
|
|
|
}
|
2023-07-26 18:19:46 +00:00
|
|
|
|
|
|
|
$banList[] = [
|
|
|
|
'info' => $banInfo,
|
|
|
|
'user' => $userInfo,
|
2023-08-02 22:12:47 +00:00
|
|
|
'user_colour' => $userColour,
|
2023-07-26 18:19:46 +00:00
|
|
|
'mod' => $modInfo,
|
2023-08-02 22:12:47 +00:00
|
|
|
'mod_colour' => $modColour,
|
2023-07-26 18:19:46 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
Template::render('manage.users.bans', [
|
|
|
|
'manage_bans' => $banList,
|
|
|
|
'manage_bans_pagination' => $pagination,
|
|
|
|
'manage_bans_filter_user' => $filterUser,
|
|
|
|
]);
|