Added forum action audit logging.
This commit is contained in:
parent
c7aa90c6b2
commit
d6eebeee75
3 changed files with 38 additions and 6 deletions
|
@ -134,6 +134,10 @@ switch ($postMode) {
|
|||
|
||||
$deletePost = forum_post_delete($postInfo['post_id']);
|
||||
|
||||
if ($deletePost) {
|
||||
audit_log(MSZ_AUDIT_FORUM_POST_DELETE, $currentUserId, [$postInfo['post_id']]);
|
||||
}
|
||||
|
||||
if ($isXHR) {
|
||||
echo json_encode([
|
||||
'success' => $deletePost,
|
||||
|
@ -182,6 +186,7 @@ switch ($postMode) {
|
|||
break;
|
||||
}
|
||||
|
||||
audit_log(MSZ_AUDIT_FORUM_POST_NUKE, $currentUserId, [$postInfo['post_id']]);
|
||||
http_response_code(204);
|
||||
|
||||
if (!$isXHR) {
|
||||
|
@ -220,6 +225,7 @@ switch ($postMode) {
|
|||
break;
|
||||
}
|
||||
|
||||
audit_log(MSZ_AUDIT_FORUM_POST_RESTORE, $currentUserId, [$postInfo['post_id']]);
|
||||
http_response_code(204);
|
||||
|
||||
if (!$isXHR) {
|
||||
|
|
|
@ -169,6 +169,10 @@ if (in_array($moderationMode, $validModerationModes, true)) {
|
|||
|
||||
$deleteTopic = forum_topic_delete($topic['topic_id']);
|
||||
|
||||
if ($deleteTopic) {
|
||||
audit_log(MSZ_AUDIT_FORUM_TOPIC_DELETE, $topicUserId, [$topic['topic_id']]);
|
||||
}
|
||||
|
||||
if ($isXHR) {
|
||||
echo json_encode([
|
||||
'success' => $deleteTopic,
|
||||
|
@ -217,6 +221,7 @@ if (in_array($moderationMode, $validModerationModes, true)) {
|
|||
break;
|
||||
}
|
||||
|
||||
audit_log(MSZ_AUDIT_FORUM_TOPIC_RESTORE, $topicUserId, [$topic['topic_id']]);
|
||||
http_response_code(204);
|
||||
|
||||
if (!$isXHR) {
|
||||
|
@ -255,6 +260,7 @@ if (in_array($moderationMode, $validModerationModes, true)) {
|
|||
break;
|
||||
}
|
||||
|
||||
audit_log(MSZ_AUDIT_FORUM_TOPIC_NUKE, $topicUserId, [$topic['topic_id']]);
|
||||
http_response_code(204);
|
||||
|
||||
if (!$isXHR) {
|
||||
|
@ -263,24 +269,24 @@ if (in_array($moderationMode, $validModerationModes, true)) {
|
|||
break;
|
||||
|
||||
case 'bump':
|
||||
if ($canBumpTopic) {
|
||||
forum_topic_bump($topic['topic_id']);
|
||||
if ($canBumpTopic && forum_topic_bump($topic['topic_id'])) {
|
||||
audit_log(MSZ_AUDIT_FORUM_TOPIC_BUMP, $topicUserId, [$topic['topic_id']]);
|
||||
}
|
||||
|
||||
header('Location: /forum/topic.php?t=' . $topic['topic_id']);
|
||||
break;
|
||||
|
||||
case 'lock':
|
||||
if ($canLockTopic && !$topicIsLocked) {
|
||||
forum_topic_lock($topic['topic_id']);
|
||||
if ($canLockTopic && !$topicIsLocked && forum_topic_lock($topic['topic_id'])) {
|
||||
audit_log(MSZ_AUDIT_FORUM_TOPIC_LOCK, $topicUserId, [$topic['topic_id']]);
|
||||
}
|
||||
|
||||
header('Location: /forum/topic.php?t=' . $topic['topic_id']);
|
||||
break;
|
||||
|
||||
case 'unlock':
|
||||
if ($canLockTopic && $topicIsLocked) {
|
||||
forum_topic_unlock($topic['topic_id']);
|
||||
if ($canLockTopic && $topicIsLocked && forum_topic_unlock($topic['topic_id'])) {
|
||||
audit_log(MSZ_AUDIT_FORUM_TOPIC_UNLOCK, $topicUserId, [$topic['topic_id']]);
|
||||
}
|
||||
|
||||
header('Location: /forum/topic.php?t=' . $topic['topic_id']);
|
||||
|
|
|
@ -19,6 +19,16 @@ audit_log_define('NEWS_POST_CREATE');
|
|||
audit_log_define('NEWS_POST_EDIT');
|
||||
audit_log_define('NEWS_CATEGORY_CREATE');
|
||||
audit_log_define('NEWS_CATEGORY_EDIT');
|
||||
audit_log_define('FORUM_POST_EDIT');
|
||||
audit_log_define('FORUM_POST_DELETE');
|
||||
audit_log_define('FORUM_POST_RESTORE');
|
||||
audit_log_define('FORUM_POST_NUKE');
|
||||
audit_log_define('FORUM_TOPIC_DELETE');
|
||||
audit_log_define('FORUM_TOPIC_RESTORE');
|
||||
audit_log_define('FORUM_TOPIC_NUKE');
|
||||
audit_log_define('FORUM_TOPIC_BUMP');
|
||||
audit_log_define('FORUM_TOPIC_LOCK');
|
||||
audit_log_define('FORUM_TOPIC_UNLOCK');
|
||||
|
||||
// replace this with a localisation system
|
||||
define('MSZ_AUDIT_LOG_STRINGS', [
|
||||
|
@ -42,6 +52,16 @@ define('MSZ_AUDIT_LOG_STRINGS', [
|
|||
MSZ_AUDIT_NEWS_POST_EDIT => 'Edited news post #%d.',
|
||||
MSZ_AUDIT_NEWS_CATEGORY_CREATE => 'Created news category #%d.',
|
||||
MSZ_AUDIT_NEWS_CATEGORY_EDIT => 'Edited news category #%d.',
|
||||
MSZ_AUDIT_FORUM_POST_EDIT => 'Edited forum post #%d.',
|
||||
MSZ_AUDIT_FORUM_POST_DELETE => 'Deleted forum post #%d.',
|
||||
MSZ_AUDIT_FORUM_POST_RESTORE => 'Restored forum post #%d.',
|
||||
MSZ_AUDIT_FORUM_POST_NUKE => 'Nuked forum post #%d.',
|
||||
MSZ_AUDIT_FORUM_TOPIC_DELETE => 'Deleted forum topic #%d.',
|
||||
MSZ_AUDIT_FORUM_TOPIC_RESTORE => 'Restored forum topic #%d.',
|
||||
MSZ_AUDIT_FORUM_TOPIC_NUKE => 'Nuked forum topic #%d.',
|
||||
MSZ_AUDIT_FORUM_TOPIC_BUMP => 'Manually bumped forum topic #%d.',
|
||||
MSZ_AUDIT_FORUM_TOPIC_LOCK => 'Locked forum topic #%d.',
|
||||
MSZ_AUDIT_FORUM_TOPIC_UNLOCK => 'Unlocked forum topic #%d.',
|
||||
]);
|
||||
|
||||
function audit_log_define(string $name): void
|
||||
|
|
Loading…
Add table
Reference in a new issue