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
|
|
|
|
2024-12-02 02:28:08 +00:00
|
|
|
if(!isset($msz) || !($msz instanceof \Misuzu\MisuzuContext))
|
|
|
|
die('Script must be called through the Misuzu route dispatcher.');
|
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
if(!$msz->authInfo->getPerms('global')->check(Perm::G_CL_CHANGES_MANAGE))
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(403);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2024-12-19 01:22:26 +00:00
|
|
|
$pagination = Pagination::fromInput($msz->changelog->countChanges(), 30);
|
|
|
|
if(!$pagination->validOffset)
|
2023-08-31 15:59:53 +00:00
|
|
|
Template::throwError(404);
|
2022-09-13 13:14:49 +00:00
|
|
|
|
2024-11-30 04:09:29 +00:00
|
|
|
$changeInfos = $msz->changelog->getChanges(pagination: $pagination);
|
2023-07-15 02:05:49 +00:00
|
|
|
$changes = [];
|
|
|
|
|
|
|
|
foreach($changeInfos as $changeInfo) {
|
2024-11-30 04:09:29 +00:00
|
|
|
$userInfo = $changeInfo->userId !== null ? $msz->usersCtx->getUserInfo($changeInfo->userId) : null;
|
2023-07-15 02:05:49 +00:00
|
|
|
|
|
|
|
$changes[] = [
|
|
|
|
'change' => $changeInfo,
|
2024-11-30 04:09:29 +00:00
|
|
|
'tags' => $msz->changelog->getTags(changeInfo: $changeInfo),
|
2023-07-15 02:05:49 +00:00
|
|
|
'user' => $userInfo,
|
2024-11-30 04:09:29 +00:00
|
|
|
'user_colour' => $msz->usersCtx->getUserColour($userInfo),
|
2023-07-15 02:05:49 +00:00
|
|
|
];
|
|
|
|
}
|
2022-09-13 13:14:49 +00:00
|
|
|
|
|
|
|
Template::render('manage.changelog.changes', [
|
|
|
|
'changelog_changes' => $changes,
|
2024-11-30 04:09:29 +00:00
|
|
|
'changelog_pagination' => $pagination,
|
2022-09-13 13:14:49 +00:00
|
|
|
]);
|