Kaynağa Gözat

Concurrent removal of topics detected and action stopped second half of [Bug 4910]

Signed-off-by: emanuele <[email protected]>
emanuele 12 yıl önce
ebeveyn
işleme
97538cb22f

+ 29 - 0
Sources/RemoveTopic.php

@@ -48,6 +48,8 @@ function RemoveTopic2()
 	if (empty($topic))
 		redirectexit();
 
+	removeDeleteConcurrence();
+
 	$request = $smcFunc['db_query']('', '
 		SELECT t.id_member_started, ms.subject, t.approved
 		FROM {db_prefix}topics AS t
@@ -95,6 +97,8 @@ function DeleteMessage()
 	if (empty($topic) && isset($_REQUEST['topic']))
 		$topic = (int) $_REQUEST['topic'];
 
+	removeDeleteConcurrence();
+
 	$request = $smcFunc['db_query']('', '
 		SELECT t.id_member_started, m.id_member, m.subject, m.poster_time, m.approved
 		FROM {db_prefix}topics AS t
@@ -1458,4 +1462,29 @@ function mergePosts($msgs = array(), $from_topic, $target_topic)
 	updateLastMessages(array($from_board, $target_board));
 }
 
+function removeDeleteConcurrence()
+{
+	global $modSettings, $board, $topic, $smcFunc, $scripturl, $context;
+
+	// No recycle no need to go further
+	if (empty($modSettings['recycle_enable']) || empty($modSettings['recycle_board']))
+		return false;
+
+	// If it's confirmed go on and delete (from recycle)
+	if (isset($_GET['confirm_delete']))
+		return true;
+
+	if (empty($board))
+		return false;
+
+	if ($modSettings['recycle_board'] != $board)
+		return true;
+	elseif (isset($_REQUEST['msg']))
+		$confirm_url = $scripturl . '?action=deletemsg;confirm_delete;topic=' . $context['current_topic'] . '.0;msg=' . $_REQUEST['msg'] . ';' . $context['session_var'] . '=' . $context['session_id'];
+	else
+		$confirm_url = $scripturl . '?action=removetopic2;confirm_delete;topic=' . $context['current_topic'] . '.0;' . $context['session_var'] . '=' . $context['session_id'];
+
+	fatal_lang_error('post_already_deleted', false, array($confirm_url));
+}
+
 ?>

+ 1 - 0
Themes/default/languages/Errors.english.php

@@ -189,6 +189,7 @@ $txt['ban_name_exists'] = 'The name of this ban (%1$s) already exists. Please ch
 $txt['ban_trigger_already_exists'] = 'This ban trigger (%1$s) already exists in %2$s.';
 
 $txt['recycle_no_valid_board'] = 'No valid board selected for recycled topics';
+$txt['post_already_deleted'] = 'The topic or message has already been moved to the recycle board. Are you sure you want to delete it completely?<br />If so follow <a href="%1$s">this link</a>';
 
 $txt['login_threshold_fail'] = 'Sorry, you are out of login chances.  Please come back and try again later.';
 $txt['login_threshold_brute_fail'] = 'Sorry, but you\'ve reached your login attempts threshold.  Please wait 30 seconds and try again later.';