misuzu/public-legacy/manage/changelog/index.php

48 lines
1.3 KiB
PHP
Raw Normal View History

2022-09-13 13:14:49 +00:00
<?php
namespace Misuzu;
use RuntimeException;
2022-09-13 13:14:49 +00:00
if(!$msz->getAuthInfo()->getPerms('global')->check(Perm::G_CL_CHANGES_MANAGE))
Template::throwError(403);
2022-09-13 13:14:49 +00:00
2023-07-15 02:05:49 +00:00
$changelog = $msz->getChangelog();
$changelogPagination = new Pagination($changelog->countChanges(), 30);
2022-09-13 13:14:49 +00:00
if(!$changelogPagination->hasValidOffset())
Template::throwError(404);
2022-09-13 13:14:49 +00:00
$changeInfos = $changelog->getChanges(pagination: $changelogPagination);
2023-07-15 02:05:49 +00:00
$changes = [];
$userInfos = [];
$userColours = [];
2023-07-15 02:05:49 +00:00
foreach($changeInfos as $changeInfo) {
$userId = $changeInfo->getUserId();
if(array_key_exists($userId, $userInfos)) {
$userInfo = $userInfos[$userId];
} else {
try {
$userInfo = $users->getUser($userId, 'id');
$userColours[$userId] = $users->getUserColour($userInfo);
} catch(RuntimeException $ex) {
2023-07-15 02:05:49 +00:00
$userInfo = null;
}
$userInfos[$userId] = $userInfo;
}
$changes[] = [
'change' => $changeInfo,
'tags' => $changelog->getTags(changeInfo: $changeInfo),
2023-07-15 02:05:49 +00:00
'user' => $userInfo,
'user_colour' => $userColours[$userId] ?? \Index\Colour\Colour::none(),
2023-07-15 02:05:49 +00:00
];
}
2022-09-13 13:14:49 +00:00
Template::render('manage.changelog.changes', [
'changelog_changes' => $changes,
'changelog_pagination' => $changelogPagination,
]);