Added mod "Reason to move topic" (#1388)

* Added mod "Reason to move topic"

* Update CHANGELOG.md
This commit is contained in:
Roman Kelesidis 2024-02-08 15:41:10 +07:00 committed by GitHub
commit 58af3dff58
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 24 additions and 28 deletions

View file

@ -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))

View file

@ -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 <b>old topic</b>';
$lang['BOT_AFTER_SPLIT_TO_NEW'] = 'Add bot-message about split to <b>new topic</b>';
//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';

View file

@ -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']));

View file

@ -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));
}

View file

@ -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;
}

View file

@ -81,6 +81,7 @@
<!-- ENDIF -->
<!-- IF SHOW_BOT_OPTIONS -->
<p class="mrg_2"><input type="checkbox" name="insert_bot_msg" id="insert_bot_msg" checked /><label for="insert_bot_msg">{L_BOT_LEAVE_MSG_MOVED}</label></p>
<p class="mrg_2">{L_BOT_REASON_MOVED}&nbsp;<input type="text" name="reason_move_bot" maxlength="60" size="30"/></p>
<!-- ENDIF -->
</td>
</tr>