diff --git a/CHANGELOG.md b/CHANGELOG.md index 54c930f22..658c373a4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ **Merged pull requests:** - Release 2.4.2 🐯 ([belomaxorka](https://github.com/belomaxorka)) +- Added mod "Reason to move topic" [\#1388](https://github.com/torrentpier/torrentpier/pull/1388) ([belomaxorka](https://github.com/belomaxorka)) - Created template file for AJAX quick actions [\#1381](https://github.com/torrentpier/torrentpier/pull/1381) ([belomaxorka](https://github.com/belomaxorka)) - Removed `wbr()` [\#1387](https://github.com/torrentpier/torrentpier/pull/1387) ([belomaxorka](https://github.com/belomaxorka)) - Removed converting for legacy md5 passwords [\#1386](https://github.com/torrentpier/torrentpier/pull/1386) ([belomaxorka](https://github.com/belomaxorka)) diff --git a/library/language/source/main.php b/library/language/source/main.php index 8fb799c36..beadde838 100644 --- a/library/language/source/main.php +++ b/library/language/source/main.php @@ -1336,6 +1336,7 @@ $lang['UPDATE_POST_TIME'] = 'Update post time'; $lang['TOPIC_SPLIT_NEW'] = 'New topic'; $lang['TOPIC_SPLIT_OLD'] = 'Old topic'; $lang['BOT_LEAVE_MSG_MOVED'] = 'Add bot-message about moving'; +$lang['BOT_REASON_MOVED'] = 'Reason to move'; $lang['BOT_AFTER_SPLIT_TO_OLD'] = 'Add bot-message about split to old topic'; $lang['BOT_AFTER_SPLIT_TO_NEW'] = 'Add bot-message about split to new topic'; //qr @@ -2515,7 +2516,7 @@ $lang['WRONG_INPUT'] = 'You have entered some wrong values. Please check your in $lang['PROCESSING'] = 'Processing...'; $lang['FINISHED'] = 'Finished'; -$lang['BOT_TOPIC_MOVED_FROM_TO'] = 'Topic has been moved from forum [b]%s[/b] to forum [b]%s[/b][br][br]%s'; +$lang['BOT_TOPIC_MOVED_FROM_TO'] = 'Topic has been moved from forum [b]%s[/b] to forum [b]%s[/b].[br][b]Reason to move:[/b] %s[br][br]%s'; $lang['BOT_MESS_SPLITS'] = 'Topic has been split. New topic - [b]%s[/b][br][br]%s'; $lang['BOT_TOPIC_SPLITS'] = 'Topic has been split from [b]%s[/b][br][br]%s'; diff --git a/modcp.php b/modcp.php index b7ac42a75..81bcd2a87 100644 --- a/modcp.php +++ b/modcp.php @@ -253,7 +253,7 @@ switch ($mode) { if ($confirmed) { $new_forum_id = (int)$_POST['new_forum']; - $result = \TorrentPier\Legacy\Admin\Common::topic_move($req_topics, $new_forum_id, $forum_id, isset($_POST['move_leave_shadow']), isset($_POST['insert_bot_msg'])); + $result = \TorrentPier\Legacy\Admin\Common::topic_move($req_topics, $new_forum_id, $forum_id, isset($_POST['move_leave_shadow']), isset($_POST['insert_bot_msg']), $_POST['reason_move_bot']); //Обновление кеша новостей на главной $news_forums = array_flip(explode(',', $bb_cfg['latest_news_forum_id'])); diff --git a/src/Legacy/Admin/Common.php b/src/Legacy/Admin/Common.php index a57b74ddd..985d34e76 100644 --- a/src/Legacy/Admin/Common.php +++ b/src/Legacy/Admin/Common.php @@ -419,15 +419,15 @@ class Common /** * Topic movement * - * @param array|string $topic_id - * @param int $to_forum_id - * @param null $from_forum_id + * @param int|array|string $topic_id + * @param int|string $to_forum_id + * @param int|string|null $from_forum_id * @param bool $leave_shadow * @param bool $insert_bot_msg - * + * @param string $reason_move * @return bool */ - public static function topic_move($topic_id, $to_forum_id, $from_forum_id = null, $leave_shadow = false, $insert_bot_msg = false) + public static function topic_move(int|array|string $topic_id, int|string $to_forum_id, int|string $from_forum_id = null, bool $leave_shadow = false, bool $insert_bot_msg = false, string $reason_move = ''): bool { global $log_action; @@ -496,7 +496,7 @@ class Common // Bot if ($insert_bot_msg) { foreach ($topics as $topic_id => $row) { - Post::insert_post('after_move', $topic_id, $to_forum_id, $row['forum_id']); + Post::insert_post('after_move', $topic_id, $to_forum_id, $row['forum_id'], reason_move: $reason_move); } self::sync('topic', array_keys($topics)); } diff --git a/src/Legacy/Post.php b/src/Legacy/Post.php index 7cff88bfa..c9655ed73 100644 --- a/src/Legacy/Post.php +++ b/src/Legacy/Post.php @@ -417,16 +417,15 @@ class Post * Insert post to the existing thread * * @param string $mode - * @param int $topic_id - * @param int $forum_id - * @param int $old_forum_id - * @param int $new_topic_id + * @param int|string $topic_id + * @param int|string|null $forum_id + * @param int|string|null $old_forum_id + * @param int|string|null $new_topic_id * @param string $new_topic_title - * @param int $old_topic_id - * @param string $message - * @param int $poster_id + * @param int|null $old_topic_id + * @param string $reason_move */ - public static function insert_post($mode, $topic_id, $forum_id = null, $old_forum_id = null, $new_topic_id = null, $new_topic_title = '', $old_topic_id = null, $message = '', $poster_id = null) + public static function insert_post(string $mode, int|string $topic_id, int|string $forum_id = null, int|string $old_forum_id = null, int|string $new_topic_id = null, string $new_topic_title = '', int $old_topic_id = null, string $reason_move = ''): void { global $userdata, $lang; @@ -434,10 +433,12 @@ class Post return; } - $post_username = $post_text = $poster_ip = ''; - + $post_username = ''; $post_time = TIMENOW; + $poster_id = BOT_UID; + $poster_ip = '7f000001'; + if ($mode == 'after_move') { if (!$forum_id || !$old_forum_id) { return; @@ -455,15 +456,10 @@ class Post return; } - $post_text = sprintf($lang['BOT_TOPIC_MOVED_FROM_TO'], '[url=' . make_url(FORUM_URL . $old_forum_id) . ']' . $forum_names[$old_forum_id] . '[/url]', '[url=' . make_url(FORUM_URL . $forum_id) . ']' . $forum_names[$forum_id] . '[/url]', profile_url($userdata)); - - $poster_id = BOT_UID; - $poster_ip = '7f000001'; + $reason_move = !empty($reason_move) ? htmlCHR($reason_move) : $lang['NOSELECT']; + $post_text = sprintf($lang['BOT_TOPIC_MOVED_FROM_TO'], '[url=' . make_url(FORUM_URL . $old_forum_id) . ']' . $forum_names[$old_forum_id] . '[/url]', '[url=' . make_url(FORUM_URL . $forum_id) . ']' . $forum_names[$forum_id] . '[/url]', $reason_move, profile_url($userdata)); } elseif ($mode == 'after_split_to_old') { $post_text = sprintf($lang['BOT_MESS_SPLITS'], '[url=' . make_url(TOPIC_URL . $new_topic_id) . ']' . htmlCHR($new_topic_title) . '[/url]', profile_url($userdata)); - - $poster_id = BOT_UID; - $poster_ip = '7f000001'; } elseif ($mode == 'after_split_to_new') { $sql = "SELECT t.topic_title, p.post_time FROM " . BB_TOPICS . " t, " . BB_POSTS . " p @@ -474,9 +470,6 @@ class Post $post_time = $row['post_time'] - 1; $post_text = sprintf($lang['BOT_TOPIC_SPLITS'], '[url=' . make_url(TOPIC_URL . $old_topic_id) . ']' . $row['topic_title'] . '[/url]', profile_url($userdata)); - - $poster_id = BOT_UID; - $poster_ip = '7f000001'; } else { return; } diff --git a/styles/templates/default/modcp.tpl b/styles/templates/default/modcp.tpl index f1c915170..ce25fe14f 100644 --- a/styles/templates/default/modcp.tpl +++ b/styles/templates/default/modcp.tpl @@ -81,6 +81,7 @@
+{L_BOT_REASON_MOVED}