From 3bbf240d75c100bf97f380b5be567d157051d82a Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 28 Jul 2025 20:35:51 +0300 Subject: [PATCH 1/4] feat(log action): Show `attachment updated` action --- posting.php | 9 +++++++++ src/Legacy/Attach.php | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/posting.php b/posting.php index b75e17091..ddae2287d 100644 --- a/posting.php +++ b/posting.php @@ -368,6 +368,15 @@ if (($delete || $mode == 'delete') && !$confirm) { if (!$error_msg) { \TorrentPier\Legacy\Post::user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $notify_user); + + if (defined('ATTACHMENT_UPDATED')) { + global $log_action; + $log_action->mod('mod_topic_attach_updated', [ + 'forum_id' => $forum_id, + 'topic_id' => $topic_id, + 'topic_title' => $post_info['topic_title'], + ]); + } } if ($mode == 'newtopic' || $mode == 'reply') { diff --git a/src/Legacy/Attach.php b/src/Legacy/Attach.php index cd9ca32d2..213b254d6 100644 --- a/src/Legacy/Attach.php +++ b/src/Legacy/Attach.php @@ -479,14 +479,14 @@ class Attach unlink_attach($row['physical_filename'], MODE_THUMBNAIL); } - // todo: log action - torrent updated - //bt if ($this->attachment_extension_list[$actual_element] === TORRENT_EXT && $attachments[$actual_element]['tracker_status']) { Torrent::tracker_unregister($attachment_id); } //bt end + \define('ATTACHMENT_UPDATED', true); + // Make sure it is displayed $this->attachment_list[$actual_element] = $this->attach_filename; $this->attachment_comment_list[$actual_element] = $comment; From d426b01c2a6b65bc48437bbbc52039c2a203e4fc Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 28 Jul 2025 20:40:42 +0300 Subject: [PATCH 2/4] Updated --- posting.php | 3 ++- src/Legacy/Attach.php | 9 ++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/posting.php b/posting.php index ddae2287d..7ab4058b8 100644 --- a/posting.php +++ b/posting.php @@ -369,12 +369,13 @@ if (($delete || $mode == 'delete') && !$confirm) { if (!$error_msg) { \TorrentPier\Legacy\Post::user_notification($mode, $post_data, $post_info['topic_title'], $forum_id, $topic_id, $notify_user); - if (defined('ATTACHMENT_UPDATED')) { + if (defined('ATTACHMENT_UPDATED') && ATTACHMENT_UPDATED['status']) { global $log_action; $log_action->mod('mod_topic_attach_updated', [ 'forum_id' => $forum_id, 'topic_id' => $topic_id, 'topic_title' => $post_info['topic_title'], + 'log_msg' => sprintf('Attachment type: %s', ATTACHMENT_UPDATED['attachment_type']) ]); } } diff --git a/src/Legacy/Attach.php b/src/Legacy/Attach.php index 213b254d6..d7ad92bee 100644 --- a/src/Legacy/Attach.php +++ b/src/Legacy/Attach.php @@ -475,17 +475,24 @@ class Attach // Delete the Old Attachment unlink_attach($row['physical_filename']); + $attachment_type = $lang['ATTACHMENT']; + if ((int)$row['thumbnail'] === 1) { unlink_attach($row['physical_filename'], MODE_THUMBNAIL); + $attachment_type = $lang['ATTACHMENT_THUMBNAIL']; } //bt if ($this->attachment_extension_list[$actual_element] === TORRENT_EXT && $attachments[$actual_element]['tracker_status']) { Torrent::tracker_unregister($attachment_id); + $attachment_type = $lang['TORRENT']; } //bt end - \define('ATTACHMENT_UPDATED', true); + \define('ATTACHMENT_UPDATED', [ + 'status' => true, + 'attachment_type' => $attachment_type + ]); // Make sure it is displayed $this->attachment_list[$actual_element] = $this->attach_filename; From 3391d0ce6470e104065217fb5cd5feb1fc08fde5 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 28 Jul 2025 20:42:58 +0300 Subject: [PATCH 3/4] Updated --- admin/admin_log.php | 1 + src/Legacy/LogAction.php | 1 + 2 files changed, 2 insertions(+) diff --git a/admin/admin_log.php b/admin/admin_log.php index 01dbba373..f5c665187 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -235,6 +235,7 @@ if ($log_rowset) { case $log_type['mod_post_pin']: case $log_type['mod_post_unpin']: case $log_type['mod_topic_split']: + case $log_type['mod_topic_attach_updated']: // topic_title if (!empty($row['log_topic_title'])) { $topic_title = $row['log_topic_title']; diff --git a/src/Legacy/LogAction.php b/src/Legacy/LogAction.php index e4af99bb7..4b11ad65e 100644 --- a/src/Legacy/LogAction.php +++ b/src/Legacy/LogAction.php @@ -35,6 +35,7 @@ class LogAction 'mod_topic_tor_unregister' => 17, 'mod_topic_tor_register' => 18, 'mod_topic_tor_delete' => 19, + 'mod_topic_attach_updated' => 20, ]; public $log_type_select = []; public $log_disabled = false; From 978d03b8e8fa73a011a67598c3b3fe21075aef96 Mon Sep 17 00:00:00 2001 From: Roman Kelesidis Date: Mon, 28 Jul 2025 20:44:01 +0300 Subject: [PATCH 4/4] Update main.php --- library/language/source/main.php | 1 + 1 file changed, 1 insertion(+) diff --git a/library/language/source/main.php b/library/language/source/main.php index ffc0e2091..0a93ac453 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -2825,6 +2825,7 @@ $lang['LOG_ACTION']['LOG_TYPE'] = [ 'mod_topic_tor_unregister' => 'Topic:
torrent unregistered', 'mod_topic_tor_register' => 'Topic:
torrent registered', 'mod_topic_tor_delete' => 'Topic:
torrent deleted', + 'mod_topic_attach_updated' => 'Topic:
attachment updated', 'mod_topic_renamed' => 'Topic:
renamed', 'mod_post_delete' => 'Post:
deleted', 'mod_post_pin' => 'Post:
pinned',