2019-06-07 17:33:51 +00:00
|
|
|
<?php
|
2019-09-28 22:43:51 +00:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2020-05-21 15:05:30 +00:00
|
|
|
use Misuzu\Pagination;
|
2020-05-25 19:58:06 +00:00
|
|
|
use Misuzu\Users\User;
|
2020-05-21 15:05:30 +00:00
|
|
|
|
2019-06-07 17:33:51 +00:00
|
|
|
require_once '../../../misuzu.php';
|
|
|
|
|
2020-05-25 19:58:06 +00:00
|
|
|
if(!User::hasCurrent() || !perms_check_user(MSZ_PERMS_GENERAL, User::getCurrent()->getId(), MSZ_PERM_GENERAL_VIEW_LOGS)) {
|
2019-06-07 17:33:51 +00:00
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
$auditLog = $msz->getAuditLog();
|
|
|
|
$pagination = new Pagination($auditLog->countLogs(), 50);
|
2019-06-07 17:33:51 +00:00
|
|
|
|
2020-05-21 15:05:30 +00:00
|
|
|
if(!$pagination->hasValidOffset()) {
|
2019-06-07 17:33:51 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-07-17 17:43:17 +00:00
|
|
|
$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);
|
|
|
|
}
|
2019-06-07 17:33:51 +00:00
|
|
|
|
2019-12-04 18:16:22 +00:00
|
|
|
Template::render('manage.general.logs', [
|
2019-06-07 17:33:51 +00:00
|
|
|
'global_logs' => $logs,
|
2020-05-21 15:05:30 +00:00
|
|
|
'global_logs_pagination' => $pagination,
|
2023-07-17 17:43:17 +00:00
|
|
|
'global_logs_users' => $userInfos,
|
2019-06-07 17:33:51 +00:00
|
|
|
]);
|