2022-09-13 13:14:49 +00:00
|
|
|
<?php
|
|
|
|
namespace Misuzu;
|
|
|
|
|
2023-07-22 15:02:41 +00:00
|
|
|
use RuntimeException;
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2023-08-02 22:12:47 +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 = [];
|
2023-08-02 22:12:47 +00:00
|
|
|
$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 {
|
2023-08-02 22:12:47 +00:00
|
|
|
$userInfo = $users->getUser($userId, 'id');
|
|
|
|
$userColours[$userId] = $users->getUserColour($userInfo);
|
2023-07-22 15:02:41 +00:00
|
|
|
} catch(RuntimeException $ex) {
|
2023-07-15 02:05:49 +00:00
|
|
|
$userInfo = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
$userInfos[$userId] = $userInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
$changes[] = [
|
|
|
|
'change' => $changeInfo,
|
|
|
|
'user' => $userInfo,
|
2023-08-02 22:12:47 +00:00
|
|
|
'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,
|
|
|
|
]);
|