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

39 lines
1,018 B
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use Misuzu\Pagination;
if(!$msz->isLoggedIn() || !perms_check_user(MSZ_PERMS_GENERAL, $msz->getActiveUser()->getId(), MSZ_PERM_GENERAL_VIEW_LOGS)) {
2022-09-13 13:14:49 +00:00
echo render_error(403);
return;
}
$users = $msz->getUsers();
$auditLog = $msz->getAuditLog();
$pagination = new Pagination($auditLog->countLogs(), 50);
2022-09-13 13:14:49 +00:00
if(!$pagination->hasValidOffset()) {
echo render_error(404);
return;
}
$logs = $auditLog->getLogs(pagination: $pagination);
$userInfos = [];
$userColours = [];
foreach($logs as $log)
if($log->hasUserId()) {
$userId = $log->getUserId();
if(!array_key_exists($userId, $userInfos)) {
$userInfos[$userId] = $users->getUser($userId, 'id');
$userColours[$userId] = $users->getUserColour($userInfos[$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
]);