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

56 lines
1.5 KiB
PHP
Raw Permalink Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use RuntimeException;
2022-09-13 13:14:49 +00:00
if(!$msz->getAuthInfo()->getPerms('user')->check(Perm::U_WARNINGS_MANAGE))
Template::throwError(403);
2022-09-13 13:14:49 +00:00
$usersCtx = $msz->getUsersContext();
$warns = $usersCtx->getWarnings();
2022-09-13 13:14:49 +00:00
2023-07-26 22:43:50 +00:00
$filterUser = null;
if(filter_has_var(INPUT_GET, 'u')) {
$filterUserId = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_NUMBER_INT);
2022-09-13 13:14:49 +00:00
try {
$filterUser = $usersCtx->getUserInfo($filterUserId);
} catch(RuntimeException $ex) {
Template::throwError(404);
2022-09-13 13:14:49 +00:00
}
}
2023-07-26 22:43:50 +00:00
$pagination = new Pagination($warns->countWarnings(userInfo: $filterUser), 10);
2022-09-13 13:14:49 +00:00
if(!$pagination->hasValidOffset())
Template::throwError(404);
2022-09-13 13:14:49 +00:00
2023-07-26 22:43:50 +00:00
$warnList = [];
$warnInfos = $warns->getWarnings(userInfo: $filterUser, pagination: $pagination);
foreach($warnInfos as $warnInfo) {
$userInfo = $usersCtx->getUserInfo($warnInfo->getUserId());
$userColour = $usersCtx->getUserColour($userInfo);
if(!$warnInfo->hasModId()) {
$modInfo = null;
$modColour = null;
} else {
$modInfo = $usersCtx->getUserInfo($warnInfo->getModId());
$modColour = $usersCtx->getUserColour($modInfo);
}
2023-07-26 22:43:50 +00:00
$warnList[] = [
'info' => $warnInfo,
'user' => $userInfo,
'user_colour' => $userColour,
2023-07-26 22:43:50 +00:00
'mod' => $modInfo,
'mod_colour' => $modColour,
2023-07-26 22:43:50 +00:00
];
}
2022-09-13 13:14:49 +00:00
Template::render('manage.users.warnings', [
2023-07-26 22:43:50 +00:00
'manage_warns' => $warnList,
'manage_warns_pagination' => $pagination,
'manage_warns_filter_user' => $filterUser,
2022-09-13 13:14:49 +00:00
]);