Explorar o código

+ Allow for Splitting posts off while the moderation is set to checkboxes [Bug 0922]

emanuele %!s(int64=13) %!d(string=hai) anos
pai
achega
d62e27f020

+ 16 - 0
Sources/Display.php

@@ -1631,6 +1631,22 @@ function QuickInTopicModeration()
 	// We are restoring messages. We handle this in another place.
 	if (isset($_REQUEST['restore_selected']))
 		redirectexit('action=restoretopic;msgs=' . implode(',', $messages) . ';' . $context['session_var'] . '=' . $context['session_id']);
+	if (isset($_REQUEST['split_selection']))
+	{
+		$request = $smcFunc['db_query']('', '
+			SELECT subject
+			FROM {db_prefix}messages
+			WHERE id_msg = {int:message}
+			LIMIT 1',
+			array(
+				'message' => min($messages),
+			)
+		);
+		list($subname) = $smcFunc['db_fetch_row']($request);
+		$smcFunc['db_free_result']($request);
+		$_SESSION['split_selection'][$topic] = $messages;
+		redirectexit('action=splittopics;sa=selectTopics;topic=' . $topic . '.0;subname_enc=' .urlencode($subname) . ';' . $context['session_var'] . '=' . $context['session_id']);
+	}
 
 	// Allowed to delete any message?
 	if (allowedTo('delete_any'))

+ 4 - 0
Sources/SplitTopics.php

@@ -197,6 +197,10 @@ function SplitSelectTopics()
 	// Haven't selected anything have we?
 	$_SESSION['split_selection'][$topic] = empty($_SESSION['split_selection'][$topic]) ? array() : $_SESSION['split_selection'][$topic];
 
+	// This is a special case for split topics from quick-moderation checkboxes
+	if (isset($_REQUEST['subname_enc']))
+		$_REQUEST['subname'] = urldecode($_REQUEST['subname_enc']);
+
 	$context['not_selected'] = array(
 		'num_messages' => 0,
 		'start' => empty($_REQUEST['start']) ? 0 : (int) $_REQUEST['start'],

+ 4 - 0
Themes/default/Display.template.php

@@ -781,6 +781,10 @@ function template_main()
 						sRestoreButtonLabel: \'', $txt['quick_mod_restore'], '\',
 						sRestoreButtonImage: \'restore_selected.gif\',
 						sRestoreButtonConfirm: \'', $txt['quickmod_confirm'], '\',
+						bCanSplit: ', $context['can_split'] ? 'true' : 'false', ',
+						sSplitButtonLabel: \'', $txt['quickmod_split_selected'], '\',
+						sSplitButtonImage: \'split_selected.gif\',
+						sSplitButtonConfirm: \'', $txt['quickmod_confirm'], '\',
 						sFormId: \'quickModForm\'
 					});';
 

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

@@ -643,6 +643,7 @@ $txt['show_unread_replies'] = 'Show new replies to your posts.';
 $txt['change_color'] = 'Change Color';
 
 $txt['quickmod_delete_selected'] = 'Remove Selected';
+$txt['quickmod_split_selected'] = 'Split Selected';
 
 // In this string, don't use entities. (&, etc.)
 $txt['show_personal_messages'] = 'You have received one or more new personal messages.\\nWould you like to open a new window to view them?';

+ 23 - 0
Themes/default/scripts/topic.js

@@ -453,6 +453,16 @@ InTopicModeration.prototype.handleClick = function(oCheckbox)
 				sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'restore\')"'
 			});
 
+		// Add the 'split selected items' button.
+		if (this.opt.bCanSplit)
+			smf_addButton(this.opt.sButtonStrip, this.opt.bUseImageButton, {
+				sId: this.opt.sSelf + '_split_button',
+				sText: this.opt.sSplitButtonLabel,
+				sImage: this.opt.sSplitButtonImage,
+				sUrl: '#',
+				sCustom: ' onclick="return ' + this.opt.sSelf + '.handleSubmit(\'split\')"'
+			});
+
 		// Adding these buttons once should be enough.
 		this.bButtonsShown = true;
 	}
@@ -473,6 +483,12 @@ InTopicModeration.prototype.handleClick = function(oCheckbox)
 		document.getElementById(this.opt.sSelf + '_restore_button').style.display = this.iNumSelected < 1 ? "none" : "";
 	}
 
+	if (this.opt.bCanSplit && !this.opt.bUseImageButton)
+	{
+		setInnerHTML(document.getElementById(this.opt.sSelf + '_split_button'), this.opt.sSplitButtonLabel + ' [' + this.iNumSelected + ']');
+		document.getElementById(this.opt.sSelf + '_split_button').style.display = this.iNumSelected < 1 ? "none" : "";
+	}
+
 	// Try to restore the correct position.
 	var aItems = document.getElementById(this.opt.sButtonStrip).getElementsByTagName('span');
 	if (aItems.length > 3)
@@ -517,6 +533,13 @@ InTopicModeration.prototype.handleSubmit = function (sSubmitType)
 			oForm.action = oForm.action + ';restore_selected=1';
 		break;
 
+		case 'split':
+			if (!confirm(this.opt.sRestoreButtonConfirm))
+				return false;
+
+			oForm.action = oForm.action + ';split_selection=1';
+		break;
+
 		default:
 			return false;
 		break;