2018-07-06 01:28:06 +00:00
|
|
|
<?php
|
2018-10-04 20:30:55 +00:00
|
|
|
require_once '../misuzu.php';
|
2018-07-06 01:28:06 +00:00
|
|
|
|
|
|
|
$changelogChange = (int)($_GET['c'] ?? 0);
|
|
|
|
$changelogDate = $_GET['d'] ?? '';
|
2018-07-07 14:57:10 +00:00
|
|
|
$changelogUser = (int)($_GET['u'] ?? 0);
|
2018-07-07 19:21:42 +00:00
|
|
|
$changelogTags = $_GET['t'] ?? '';
|
2018-07-06 01:28:06 +00:00
|
|
|
|
2019-01-03 00:33:02 +00:00
|
|
|
tpl_var('comments_perms', $commentPerms = comments_get_perms(user_session_current('user_id', 0)));
|
2018-07-06 01:28:06 +00:00
|
|
|
|
|
|
|
if ($changelogChange > 0) {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getChange = db_prepare('
|
2018-07-06 01:28:06 +00:00
|
|
|
SELECT
|
|
|
|
c.`change_id`, c.`change_created`, c.`change_log`, c.`change_text`,
|
|
|
|
a.`action_name`, a.`action_colour`, a.`action_class`,
|
2018-11-17 21:59:01 +00:00
|
|
|
u.`user_id`, u.`username`, u.`display_role` as `user_role`,
|
2018-07-06 01:28:06 +00:00
|
|
|
DATE(`change_created`) as `change_date`,
|
|
|
|
COALESCE(u.`user_title`, r.`role_title`) as `user_title`,
|
2018-07-18 16:01:17 +00:00
|
|
|
COALESCE(u.`user_colour`, r.`role_colour`) as `user_colour`
|
2018-07-06 01:28:06 +00:00
|
|
|
FROM `msz_changelog_changes` as c
|
|
|
|
LEFT JOIN `msz_users` as u
|
|
|
|
ON u.`user_id` = c.`user_id`
|
|
|
|
LEFT JOIN `msz_roles` as r
|
|
|
|
ON r.`role_id` = u.`display_role`
|
|
|
|
LEFT JOIN `msz_changelog_actions` as a
|
|
|
|
ON a.`action_id` = c.`action_id`
|
|
|
|
WHERE `change_id` = :change_id
|
|
|
|
');
|
|
|
|
$getChange->bindValue('change_id', $changelogChange);
|
|
|
|
$change = $getChange->execute() ? $getChange->fetch(PDO::FETCH_ASSOC) : [];
|
|
|
|
|
|
|
|
if (!$change) {
|
2018-11-17 21:59:01 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
2018-07-06 01:28:06 +00:00
|
|
|
} else {
|
2018-10-06 23:30:48 +00:00
|
|
|
$getTags = db_prepare('
|
2018-07-06 01:28:06 +00:00
|
|
|
SELECT
|
|
|
|
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
|
|
|
FROM `msz_changelog_tags` as t
|
|
|
|
LEFT JOIN `msz_changelog_change_tags` as ct
|
|
|
|
ON ct.`tag_id` = t.`tag_id`
|
|
|
|
WHERE ct.`change_id` = :change_id
|
|
|
|
');
|
|
|
|
$getTags->bindValue('change_id', $change['change_id']);
|
|
|
|
$tags = $getTags->execute() ? $getTags->fetchAll(PDO::FETCH_ASSOC) : [];
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_var('tags', $tags);
|
2018-07-06 01:28:06 +00:00
|
|
|
}
|
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('changelog.change', [
|
2018-08-06 22:19:35 +00:00
|
|
|
'change' => $change,
|
|
|
|
'comments_category' => $commentsCategory = comments_category_info(
|
|
|
|
"changelog-date-{$change['change_date']}",
|
|
|
|
true
|
|
|
|
),
|
2018-10-02 22:34:05 +00:00
|
|
|
'comments' => comments_category_get($commentsCategory['category_id'], user_session_current('user_id', 0)),
|
2018-08-06 22:19:35 +00:00
|
|
|
]);
|
2018-07-06 01:28:06 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!empty($changelogDate)) {
|
|
|
|
$dateParts = explode('-', $changelogDate, 3);
|
|
|
|
|
2018-07-21 00:50:58 +00:00
|
|
|
if (count($dateParts) !== 3
|
2018-10-08 13:24:26 +00:00
|
|
|
|| !array_test($dateParts, 'is_user_int')
|
2018-07-21 00:50:58 +00:00
|
|
|
|| !checkdate($dateParts[1], $dateParts[2], $dateParts[0])) {
|
2018-07-06 01:28:06 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-07 19:21:42 +00:00
|
|
|
$changesCount = !empty($changelogDate) ? -1 : changelog_count_changes($changelogDate, $changelogUser);
|
2019-01-03 00:33:02 +00:00
|
|
|
$changesPagination = pagination_create($changesCount, 30);
|
2019-01-03 16:06:35 +00:00
|
|
|
$changesOffset = $changesCount === -1 ? 0 : pagination_offset($changesPagination, pagination_param());
|
|
|
|
$changes = $changesCount === -1 || pagination_is_valid_offset($changesOffset)
|
2019-01-03 00:33:02 +00:00
|
|
|
? changelog_get_changes($changelogDate, $changelogUser, $changesOffset, $changesPagination['range'])
|
|
|
|
: [];
|
2018-07-06 01:28:06 +00:00
|
|
|
|
2018-07-07 19:21:42 +00:00
|
|
|
if (!$changes) {
|
|
|
|
http_response_code(404);
|
|
|
|
}
|
2018-07-06 01:28:06 +00:00
|
|
|
|
2018-08-15 20:29:18 +00:00
|
|
|
if (!empty($changelogDate) && count($changes) > 0) {
|
2018-08-15 01:12:58 +00:00
|
|
|
tpl_vars([
|
2018-08-06 22:19:35 +00:00
|
|
|
'comments_category' => $commentsCategory = comments_category_info("changelog-date-{$changelogDate}", true),
|
2018-10-02 22:34:05 +00:00
|
|
|
'comments' => comments_category_get($commentsCategory['category_id'], user_session_current('user_id', 0)),
|
2018-08-06 22:19:35 +00:00
|
|
|
]);
|
|
|
|
}
|
|
|
|
|
2018-08-15 01:12:58 +00:00
|
|
|
echo tpl_render('changelog.index', [
|
2018-07-06 01:28:06 +00:00
|
|
|
'changes' => $changes,
|
|
|
|
'changelog_count' => $changesCount,
|
2018-07-07 19:21:42 +00:00
|
|
|
'changelog_date' => $changelogDate,
|
|
|
|
'changelog_user' => $changelogUser,
|
2019-01-03 00:33:02 +00:00
|
|
|
'changelog_pagination' => $changesPagination,
|
2018-07-06 01:28:06 +00:00
|
|
|
]);
|