This repository has been archived on 2025-01-28. You can view files and clone it, but cannot push or open issues or pull requests.
misuzu-interim/public-legacy/manage/general/logs.php

34 lines
839 B
PHP
Raw Normal View History

2022-09-13 15:14:49 +02:00
<?php
namespace Misuzu;
use Misuzu\Pagination;
use Misuzu\Users\User;
if(!User::hasCurrent() || !perms_check_user(MSZ_PERMS_GENERAL, User::getCurrent()->getId(), MSZ_PERM_GENERAL_VIEW_LOGS)) {
echo render_error(403);
return;
}
$auditLog = $msz->getAuditLog();
$pagination = new Pagination($auditLog->countLogs(), 50);
2022-09-13 15:14:49 +02:00
if(!$pagination->hasValidOffset()) {
echo render_error(404);
return;
}
$logs = $auditLog->getLogs(pagination: $pagination);
$userInfos = [];
foreach($logs as $log)
if($log->hasUserId()) {
$userId = $log->getUserId();
if(!array_key_exists($userId, $userInfos))
$userInfos[$userId] = User::byId($userId);
}
2022-09-13 15:14:49 +02:00
Template::render('manage.general.logs', [
'global_logs' => $logs,
'global_logs_pagination' => $pagination,
'global_logs_users' => $userInfos,
2022-09-13 15:14:49 +02:00
]);