Browse Source

Add a confirmation message
and fix deleting a mod comment

Signed-off-by: Suki <[email protected]>

Suki 11 years ago
parent
commit
f69970dbfd

+ 9 - 4
Sources/ReportedPosts.php

@@ -264,6 +264,11 @@ function ReportDetails()
 	if ($context['report']['closed'])
 		$context[$context['moderation_menu_name']]['current_subsection'] = 'closed';
 
+	addInlineJavascript('
+	$(\'.deleteModComment\').on(\'click\', function() {
+		return confirm('. (JavaScriptEscape($txt['mc_reportedp_delete_confirm'])) .');
+});', true);
+
 	// Finally we are done :P
 	$context['page_title'] = sprintf($txt['mc_viewmodreport'], $context['report']['subject'], $context['report']['author']['name']);
 	$context['sub_template'] = 'viewmodreport';
@@ -291,13 +296,13 @@ function HandleComment()
 	}
 
 	// Deleting a comment?
-	if (!empty($REQUEST['delete']))
+	if (isset($_REQUEST['delete']) && isset($_REQUEST['mid']))
 	{
-		$comment_id = (int) $_REQUEST['mid'];
-
-		if (empty($comment_id))
+		if (empty($_REQUEST['mid']))
 			fatal_lang_error('mc_reportedp_comment_none_found');
 
+		$comment_id = (int) $_REQUEST['mid'];
+
 		deleteModComment($comment_id);
 	}
 

+ 8 - 1
Sources/Subs-ReportedPosts.php

@@ -445,8 +445,15 @@ function deleteModComment($comment_id)
 {
 	global $smcFunc;
 
+	if (empty($comment_id))
+		return false;
+
 	$smcFunc['db_query']('', '
 		DELETE FROM {db_prefix}log_comments
-		WHERE id_comment = {int:id}', array('id' => $comment_id, ));
+		WHERE id_comment = {int:comment_id}',
+		array(
+			'comment_id' => $comment_id,
+		)
+	);
 }
 ?>

+ 1 - 1
Themes/default/ReportedPosts.template.php

@@ -240,7 +240,7 @@ function template_viewmodreport()
 
 	foreach ($context['report']['mod_comments'] as $comment)
 		echo
-					'<p>', $comment['member']['link'], ': ', $comment['message'], ' <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reports;sa=editcomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .'">'. $txt['mc_reportedp_comment_edit'] .'</a> | <a href="' . $scripturl . '?action=moderate;area=reports;sa=handlecomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .';delete">'. $txt['mc_reportedp_comment_delete'] .'</a></span>' : '') ,'</p>';
+					'<p>', $comment['member']['link'], ': ', $comment['message'], ' <em class="smalltext">(', $comment['time'], ')</em>', ($comment['can_edit'] ? '<span class="floatright"><a href="' . $scripturl . '?action=moderate;area=reports;sa=editcomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .'">'. $txt['mc_reportedp_comment_edit'] .'</a> | <a href="' . $scripturl . '?action=moderate;area=reports;sa=handlecomment;rid='. $context['report']['id'] .';mid='. $comment['id'] .';delete" class="deleteModComment">'. $txt['mc_reportedp_comment_delete'] .'</a></span>' : '') ,'</p>';
 
 	echo '
 					<textarea rows="2" cols="60" style="' . (isBrowser('is_ie8') ? 'width: 635px; max-width: 60%; min-width: 60%' : 'width: 60%') . ';" name="mod_comment"></textarea>