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

51 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->isLoggedIn() || !perms_check_user(MSZ_PERMS_CHANGELOG, $msz->getActiveUser()->getId(), MSZ_PERM_CHANGELOG_MANAGE_CHANGES)) {
2022-09-13 13:14:49 +00:00
echo render_error(403);
return;
}
2023-07-15 02:05:49 +00:00
$changelog = $msz->getChangelog();
$changelogPagination = new Pagination($changelog->countAllChanges(), 30);
2022-09-13 13:14:49 +00:00
if(!$changelogPagination->hasValidOffset()) {
echo render_error(404);
return;
}
2023-07-15 02:05:49 +00:00
$changeInfos = $changelog->getAllChanges(withTags: true, pagination: $changelogPagination);
$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,
'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,
]);