misuzu/public-legacy/manage/users/bans.php

55 lines
1.6 KiB
PHP
Raw Normal View History

<?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.');
if(!$msz->authInfo->getPerms('user')->check(Perm::U_BANS_MANAGE))
Template::throwError(403);
$filterUser = null;
if(filter_has_var(INPUT_GET, 'u')) {
$filterUserId = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_NUMBER_INT);
try {
$filterUser = $msz->usersCtx->getUserInfo($filterUserId);
} catch(RuntimeException $ex) {
Template::throwError(404);
}
}
2024-12-19 01:22:26 +00:00
$pagination = Pagination::fromInput($msz->usersCtx->bans->countBans(userInfo: $filterUser), 10);
if(!$pagination->validOffset)
Template::throwError(404);
$banList = [];
$banInfos = $msz->usersCtx->bans->getBans(userInfo: $filterUser, activeFirst: true, pagination: $pagination);
foreach($banInfos as $banInfo) {
$userInfo = $msz->usersCtx->getUserInfo($banInfo->userId);
$userColour = $msz->usersCtx->getUserColour($userInfo);
if($banInfo->modId === null) {
$modInfo = null;
$modColour = null;
} else {
$modInfo = $msz->usersCtx->getUserInfo($banInfo->modId);
$modColour = $msz->usersCtx->getUserColour($modInfo);
}
$banList[] = [
'info' => $banInfo,
'user' => $userInfo,
'user_colour' => $userColour,
'mod' => $modInfo,
'mod_colour' => $modColour,
];
}
Template::render('manage.users.bans', [
'manage_bans' => $banList,
'manage_bans_pagination' => $pagination,
'manage_bans_filter_user' => $filterUser,
]);