2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
use Misuzu\Pagination;
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if(!$msz->authInfo->getPerms('global')->check(Perm::G_LOGS_VIEW))
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(403);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$pagination = new Pagination($msz->auditLog->countLogs(), 50);
|
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
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$logs = iterator_to_array($msz->auditLog->getLogs(pagination: $pagination));
|
2023-07-17 17:43:17 +00:00
|
|
|
$userInfos = [];
|
2023-08-02 22:12:47 +00:00
|
|
|
$userColours = [];
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
foreach($logs as $log)
|
2024-11-30 04:09:29 +00:00
|
|
|
if($log->userId !== null) {
|
|
|
|
$userId = $log->userId;
|
2023-08-02 22:12:47 +00:00
|
|
|
if(!array_key_exists($userId, $userInfos)) {
|
2024-11-30 04:09:29 +00:00
|
|
|
$userInfos[$userId] = $msz->usersCtx->getUserInfo($userId);
|
|
|
|
$userColours[$userId] = $msz->usersCtx->getUserColour($userId);
|
2023-08-02 22:12:47 +00:00
|
|
|
}
|
2023-07-17 17:43:17 +00:00
|
|
|
}
|
2022-09-13 13:14:49 +00:00
|
|
|
|
|
|
|
Template::render('manage.general.logs', [
|
|
|
|
'global_logs' => $logs,
|
|
|
|
'global_logs_pagination' => $pagination,
|
2023-07-17 17:43:17 +00:00
|
|
|
'global_logs_users' => $userInfos,
|
2023-08-02 22:12:47 +00:00
|
|
|
'global_logs_users_colours' => $userColours,
|
2022-09-13 13:14:49 +00:00
|
|
|
]);
|