2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-07-22 15:02:41 +00:00
|
|
|
use RuntimeException;
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if(!$msz->authInfo->getPerms('user')->check(Perm::U_WARNINGS_MANAGE))
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(403);
|
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')) {
|
2023-08-02 22:12:47 +00:00
|
|
|
$filterUserId = filter_input(INPUT_GET, 'u', FILTER_SANITIZE_NUMBER_INT);
|
2022-09-13 13:14:49 +00:00
|
|
|
try {
|
2024-11-30 04:09:29 +00:00
|
|
|
$filterUser = $msz->usersCtx->getUserInfo($filterUserId);
|
2023-07-22 15:02:41 +00:00
|
|
|
} catch(RuntimeException $ex) {
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(404);
|
2022-09-13 13:14:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$pagination = new Pagination($msz->usersCtx->warnings->countWarnings(userInfo: $filterUser), 10);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2023-08-31 15:59:53 +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 = [];
|
2024-11-30 04:09:29 +00:00
|
|
|
$warnInfos = $msz->usersCtx->warnings->getWarnings(userInfo: $filterUser, pagination: $pagination);
|
2023-07-26 22:43:50 +00:00
|
|
|
|
|
|
|
foreach($warnInfos as $warnInfo) {
|
2024-11-30 04:09:29 +00:00
|
|
|
$userInfo = $msz->usersCtx->getUserInfo($warnInfo->userId);
|
|
|
|
$userColour = $msz->usersCtx->getUserColour($userInfo);
|
2023-08-02 22:12:47 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if($warnInfo->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($warnInfo->modId);
|
|
|
|
$modColour = $msz->usersCtx->getUserColour($modInfo);
|
2023-08-02 22:12:47 +00:00
|
|
|
}
|
2023-07-26 22:43:50 +00:00
|
|
|
|
|
|
|
$warnList[] = [
|
|
|
|
'info' => $warnInfo,
|
|
|
|
'user' => $userInfo,
|
2023-08-02 22:12:47 +00:00
|
|
|
'user_colour' => $userColour,
|
2023-07-26 22:43:50 +00:00
|
|
|
'mod' => $modInfo,
|
2023-08-02 22:12:47 +00:00
|
|
|
'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
|
|
|
]);
|