2023-07-26 18:19:46 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
use RuntimeException;
|
|
|
|
|
2023-08-31 15:59:53 +00:00
|
|
|
if(!$msz->getAuthInfo()->getPerms('user')->check(Perm::U_BANS_MANAGE))
|
|
|
|
Template::throwError(403);
|
2023-07-26 18:19:46 +00:00
|
|
|
|
2023-09-06 13:50:19 +00:00
|
|
|
$usersCtx = $msz->getUsersContext();
|
|
|
|
$bans = $usersCtx->getBans();
|
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 {
|
2023-09-06 13:50:19 +00:00
|
|
|
$filterUser = $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
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$pagination = new Pagination($bans->countBans(userInfo: $filterUser), 10);
|
|
|
|
|
2023-08-31 15:59:53 +00:00
|
|
|
if(!$pagination->hasValidOffset())
|
|
|
|
Template::throwError(404);
|
2023-07-26 18:19:46 +00:00
|
|
|
|
|
|
|
$banList = [];
|
|
|
|
$banInfos = $bans->getBans(userInfo: $filterUser, activeFirst: true, pagination: $pagination);
|
|
|
|
|
|
|
|
foreach($banInfos as $banInfo) {
|
2023-09-06 13:50:19 +00:00
|
|
|
$userInfo = $usersCtx->getUserInfo($banInfo->getUserId());
|
|
|
|
$userColour = $usersCtx->getUserColour($userInfo);
|
2023-08-02 22:12:47 +00:00
|
|
|
|
|
|
|
if(!$banInfo->hasModId()) {
|
|
|
|
$modInfo = null;
|
|
|
|
$modColour = null;
|
|
|
|
} else {
|
2023-09-06 13:50:19 +00:00
|
|
|
$modInfo = $usersCtx->getUserInfo($banInfo->getModId());
|
|
|
|
$modColour = $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,
|
|
|
|
]);
|