diff --git a/CHANGELOG.md b/CHANGELOG.md index 8136ba093..3abee5daa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ - Improved BitTorrent clients ban functionality [\#1657](https://github.com/torrentpier/torrentpier/pull/1657) ([belomaxorka](https://github.com/belomaxorka)) - Improved `filelist.php` [\#1586](https://github.com/torrentpier/torrentpier/pull/1586) ([belomaxorka](https://github.com/belomaxorka)) - Invites: Permanent invites feature [\#1670](https://github.com/torrentpier/torrentpier/pull/1670) ([belomaxorka](https://github.com/belomaxorka)) +- Show torrent status changes in actions log [\#1688](https://github.com/torrentpier/torrentpier/pull/1688) ([belomaxorka](https://github.com/belomaxorka)) - Changed database encoding to `utf8mb4_unicode_ci` [\#1684](https://github.com/torrentpier/torrentpier/pull/1684) ([belomaxorka](https://github.com/belomaxorka)) - Demo mode: Save user language in cookies [\#1584](https://github.com/torrentpier/torrentpier/pull/1584) ([belomaxorka](https://github.com/belomaxorka)) - BBCode: Fixed relative links working [\#1613](https://github.com/torrentpier/torrentpier/pull/1613) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/admin/admin_log.php b/admin/admin_log.php index 6993f02c0..e25ee7d7e 100644 --- a/admin/admin_log.php +++ b/admin/admin_log.php @@ -225,6 +225,7 @@ if ($log_rowset) { case $log_type['mod_topic_unlock']: case $log_type['mod_topic_set_downloaded']: case $log_type['mod_topic_unset_downloaded']: + case $log_type['mod_topic_change_tor_status']: case $log_type['mod_topic_renamed']: case $log_type['mod_post_delete']: case $log_type['mod_post_pin']: diff --git a/library/ajax/change_tor_status.php b/library/ajax/change_tor_status.php index f1e5f96ce..d193fba7e 100644 --- a/library/ajax/change_tor_status.php +++ b/library/ajax/change_tor_status.php @@ -11,7 +11,7 @@ if (!defined('IN_AJAX')) { die(basename(__FILE__)); } -global $userdata, $bb_cfg, $lang; +global $userdata, $bb_cfg, $lang, $log_action; if (!$attach_id = (int)$this->request['attach_id']) { $this->ajax_die($lang['EMPTY_ATTACH_ID']); @@ -87,6 +87,19 @@ switch ($mode) { \TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $new_status); + // Log action + $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . '', $bb_cfg['tor_icons'][$tor['tor_status']] . ' ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . ''); + if ($comment) { + $log_msg .= "
{$lang['COMMENT']}: $comment."; + } + $log_action->mod('mod_topic_change_tor_status', array( + 'forum_id' => $tor['forum_id'], + 'topic_id' => $tor['topic_id'], + 'topic_title' => $tor['topic_title'], + 'user_id' => $userdata['user_id'], + 'log_msg' => $log_msg . '
-------------', + )); + $this->response['status'] = $bb_cfg['tor_icons'][$new_status] . ' ' . $lang['TOR_STATUS_NAME'][$new_status] . ' · ' . profile_url($userdata) . ' · ' . delta_time(TIMENOW) . $lang['TOR_BACK'] . ''; if ($bb_cfg['tor_comment'] && (($comment && $comment != $lang['COMMENT']) || in_array($new_status, $bb_cfg['tor_reply']))) { diff --git a/library/ajax/mod_action.php b/library/ajax/mod_action.php index 7ba26b6cc..22edfc39c 100644 --- a/library/ajax/mod_action.php +++ b/library/ajax/mod_action.php @@ -30,7 +30,28 @@ switch ($mode) { $topic_ids = DB()->fetch_rowset("SELECT attach_id FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($topics)", 'attach_id'); foreach ($topic_ids as $attach_id) { + $tor = DB()->fetch_row(" + SELECT + tor.forum_id, tor.topic_id, t.topic_title, tor.tor_status + FROM " . BB_BT_TORRENTS . " tor + INNER JOIN " . BB_TOPICS . " t ON(t.topic_id = tor.topic_id) + WHERE tor.attach_id = $attach_id LIMIT 1"); + + if (!$tor) { + $this->ajax_die($lang['TORRENT_FAILED']); + } + \TorrentPier\Legacy\Torrent::change_tor_status($attach_id, $status); + + // Log action + $log_msg = sprintf($lang['TOR_STATUS_LOG_ACTION'], $bb_cfg['tor_icons'][$status] . ' ' . $lang['TOR_STATUS_NAME'][$status] . '', $bb_cfg['tor_icons'][$tor['tor_status']] . ' ' . $lang['TOR_STATUS_NAME'][$tor['tor_status']] . ''); + $log_action->mod('mod_topic_change_tor_status', array( + 'forum_id' => $tor['forum_id'], + 'topic_id' => $tor['topic_id'], + 'topic_title' => $tor['topic_title'], + 'user_id' => $userdata['user_id'], + 'log_msg' => $log_msg . '
-------------', + )); } $this->response['status'] = $bb_cfg['tor_icons'][$status]; $this->response['topics'] = explode(',', $topics); diff --git a/library/language/source/main.php b/library/language/source/main.php index 1bc4b74e0..d841717f9 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -1436,6 +1436,7 @@ $lang['CHANGE_TOR_TYPE'] = 'Type the torrent successfully changed'; $lang['DEL_TORRENT'] = 'Are you sure you want to delete the torrent?'; $lang['DEL_MOVE_TORRENT'] = 'Are you sure you want to delete and move the topic?'; $lang['UNEXECUTED_RELEASE'] = 'Do you have a shapeless release before creating a new fix his unformed!'; +$lang['TOR_STATUS_LOG_ACTION'] = 'New status: %s.
Previous status: %s.'; // tor_comment $lang['TOR_MOD_TITLE'] = 'Changing the status of distribution - %s'; @@ -2811,6 +2812,7 @@ $lang['LOG_ACTION']['LOG_TYPE'] = [ 'mod_topic_split' => 'Topic:
split', 'mod_topic_set_downloaded' => 'Topic:
set downloaded', 'mod_topic_unset_downloaded' => 'Topic:
unset downloaded', + 'mod_topic_change_tor_status' => 'Topic:
changed torrent status', 'mod_topic_renamed' => 'Topic:
renamed', 'mod_post_delete' => 'Post:
deleted', 'mod_post_pin' => 'Post:
pinned', diff --git a/src/Legacy/LogAction.php b/src/Legacy/LogAction.php index 0567d5556..5a799844e 100644 --- a/src/Legacy/LogAction.php +++ b/src/Legacy/LogAction.php @@ -27,9 +27,10 @@ class LogAction 'mod_post_pin' => 9, 'mod_post_unpin' => 10, 'mod_topic_split' => 11, - 'adm_user_delete' => 12, - 'adm_user_ban' => 13, - 'adm_user_unban' => 14, + 'mod_topic_change_tor_status' => 12, + 'adm_user_delete' => 13, + 'adm_user_ban' => 14, + 'adm_user_unban' => 15, ]; public $log_type_select = []; public $log_disabled = false;