2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
|
|
|
use Misuzu\Pagination;
|
|
|
|
|
2023-08-02 22:12:47 +00:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2023-08-02 22:12:47 +00:00
|
|
|
$users = $msz->getUsers();
|
2023-07-17 17:43:17 +00:00
|
|
|
$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;
|
|
|
|
}
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
$logs = $auditLog->getLogs(pagination: $pagination);
|
|
|
|
$userInfos = [];
|
2023-08-02 22:12:47 +00:00
|
|
|
$userColours = [];
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
foreach($logs as $log)
|
|
|
|
if($log->hasUserId()) {
|
|
|
|
$userId = $log->getUserId();
|
2023-08-02 22:12:47 +00:00
|
|
|
if(!array_key_exists($userId, $userInfos)) {
|
|
|
|
$userInfos[$userId] = $users->getUser($userId, 'id');
|
|
|
|
$userColours[$userId] = $users->getUserColour($userInfos[$userId]);
|
|
|
|
}
|
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
|
|
|
]);
|