2019-06-08 21:46:24 +00:00
|
|
|
<?php
|
2019-09-28 22:38:39 +00:00
|
|
|
namespace Misuzu;
|
|
|
|
|
2019-06-08 21:46:24 +00:00
|
|
|
require_once '../../../misuzu.php';
|
|
|
|
|
|
|
|
if(!perms_check_user(MSZ_PERMS_CHANGELOG, user_session_current('user_id'), MSZ_PERM_CHANGELOG_MANAGE_CHANGES)) {
|
|
|
|
echo render_error(403);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-28 22:38:39 +00:00
|
|
|
$changesCount = (int)DB::query('
|
2019-06-08 21:46:24 +00:00
|
|
|
SELECT COUNT(`change_id`)
|
|
|
|
FROM `msz_changelog_changes`
|
|
|
|
')->fetchColumn();
|
|
|
|
|
2019-12-06 01:04:10 +00:00
|
|
|
$changelogPagination = new Pagination($changesCount, 30);
|
2019-06-08 21:46:24 +00:00
|
|
|
|
2019-12-06 01:04:10 +00:00
|
|
|
if(!$changelogPagination->hasValidOffset()) {
|
2019-06-08 21:46:24 +00:00
|
|
|
echo render_error(404);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-09-28 22:38:39 +00:00
|
|
|
$getChanges = DB::prepare('
|
2019-06-08 21:46:24 +00:00
|
|
|
SELECT
|
|
|
|
c.`change_id`, c.`change_log`, c.`change_created`, c.`change_action`,
|
|
|
|
u.`user_id`, u.`username`,
|
|
|
|
COALESCE(u.`user_colour`, r.`role_colour`) AS `user_colour`,
|
|
|
|
DATE(`change_created`) AS `change_date`,
|
|
|
|
!ISNULL(c.`change_text`) AS `change_has_text`
|
|
|
|
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`
|
|
|
|
ORDER BY c.`change_id` DESC
|
|
|
|
LIMIT :offset, :take
|
|
|
|
');
|
2019-12-06 01:04:10 +00:00
|
|
|
$getChanges->bind('take', $changelogPagination->getRange());
|
|
|
|
$getChanges->bind('offset', $changelogPagination->getOffset());
|
2019-09-28 22:38:39 +00:00
|
|
|
$changes = $getChanges->fetchAll();
|
2019-06-08 21:46:24 +00:00
|
|
|
|
2019-09-28 22:38:39 +00:00
|
|
|
$getTags = DB::prepare('
|
2019-06-08 21:46:24 +00:00
|
|
|
SELECT
|
|
|
|
t.`tag_id`, t.`tag_name`, t.`tag_description`
|
|
|
|
FROM `msz_changelog_change_tags` as ct
|
|
|
|
LEFT JOIN `msz_changelog_tags` as t
|
|
|
|
ON t.`tag_id` = ct.`tag_id`
|
|
|
|
WHERE ct.`change_id` = :change_id
|
|
|
|
');
|
|
|
|
|
|
|
|
// grab tags
|
|
|
|
for($i = 0; $i < count($changes); $i++) {
|
2019-09-28 22:38:39 +00:00
|
|
|
$getTags->bind('change_id', $changes[$i]['change_id']);
|
|
|
|
$changes[$i]['tags'] = $getTags->fetchAll();
|
2019-06-08 21:46:24 +00:00
|
|
|
}
|
|
|
|
|
2019-12-04 18:16:22 +00:00
|
|
|
Template::render('manage.changelog.changes', [
|
2019-06-08 21:46:24 +00:00
|
|
|
'changelog_changes' => $changes,
|
|
|
|
'changelog_changes_count' => $changesCount,
|
|
|
|
'changelog_pagination' => $changelogPagination,
|
|
|
|
]);
|