misuzu/public-legacy/manage/general/logs.php

36 lines
1 KiB
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use Misuzu\Pagination;
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('global')->check(Perm::G_LOGS_VIEW))
Template::throwError(403);
2022-09-13 13:14:49 +00:00
$pagination = new Pagination($msz->auditLog->countLogs(), 50);
2022-09-13 13:14:49 +00:00
if(!$pagination->hasValidOffset())
Template::throwError(404);
2022-09-13 13:14:49 +00:00
$logs = iterator_to_array($msz->auditLog->getLogs(pagination: $pagination));
$userInfos = [];
$userColours = [];
foreach($logs as $log)
if($log->userId !== null) {
$userId = $log->userId;
if(!array_key_exists($userId, $userInfos)) {
$userInfos[$userId] = $msz->usersCtx->getUserInfo($userId);
$userColours[$userId] = $msz->usersCtx->getUserColour($userId);
}
}
2022-09-13 13:14:49 +00:00
Template::render('manage.general.logs', [
'global_logs' => $logs,
'global_logs_pagination' => $pagination,
'global_logs_users' => $userInfos,
'global_logs_users_colours' => $userColours,
2022-09-13 13:14:49 +00:00
]);