Browse Source

Kepp moving more DB stuff

Signed-off-by: Suki <[email protected]>
Suki 11 years ago
parent
commit
7c09229f19

+ 4 - 37
Sources/ReportedPosts.php

@@ -277,43 +277,10 @@ function HandleComment()
 
 		$newComment = trim($smcFunc['htmlspecialchars']($_POST['mod_comment']));
 
-		// In it goes.
-		if (!empty($newComment))
-		{
-			$smcFunc['db_insert']('',
-				'{db_prefix}log_comments',
-				array(
-					'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'recipient_name' => 'string',
-					'id_notice' => 'int', 'body' => 'string', 'log_time' => 'int',
-				),
-				array(
-					$user_info['id'], $user_info['name'], 'reportc', '',
-					$_REQUEST['report'], $newComment, time(),
-				),
-				array('id_comment')
-			);
-			$last_comment = $smcFunc['db_insert_id']('{db_prefix}log_comments', 'id_comment');
-
-			// And get ready to notify people.
-			$smcFunc['db_insert']('insert',
-				'{db_prefix}background_tasks',
-				array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
-				array('$sourcedir/tasks/MsgReportReply-Notify.php', 'MsgReportReply_Notify_Background', serialize(array(
-					'report_id' => $_REQUEST['report'],
-					'comment_id' => $last_comment,
-					'msg_id' => $row['id_msg'],
-					'topic_id' => $row['id_topic'],
-					'board_id' => $row['id_board'],
-					'sender_id' => $user_info['id'],
-					'sender_name' => $user_info['name'],
-					'time' => time(),
-				)), 0),
-				array('id_task')
-			);
-
-			// Redirect to prevent double submission.
-			redirectexit($scripturl . '?action=moderate;area=reports;report=' . $_REQUEST['report']);
-		}
+		saveModComment();
 	}
+
+	//Redirect to prevent double submission.
+	redirectexit($scripturl . '?action=moderate;area=reports;report=' . $_REQUEST['report']);
 }
 ?>

+ 39 - 0
Sources/Subs-ReportedPosts.php

@@ -351,4 +351,43 @@ function getReportComments($report_id)
 
 	return $report;
 }
+
+function saveModComment($data)
+{
+	global $smcFunc, $user_info;
+
+	if (empty($data))
+		return false;
+
+	$smcFunc['db_insert']('',
+		'{db_prefix}log_comments',
+		array(
+			'id_member' => 'int', 'member_name' => 'string', 'comment_type' => 'string', 'recipient_name' => 'string',
+			'id_notice' => 'int', 'body' => 'string', 'log_time' => 'int',
+		),
+		array(
+			$user_info['id'], $user_info['name'], 'reportc', '',
+			$_REQUEST['report'], $newComment, time(),
+		),
+		array('id_comment')
+	);
+	$last_comment = $smcFunc['db_insert_id']('{db_prefix}log_comments', 'id_comment');
+
+	// And get ready to notify people.
+	$smcFunc['db_insert']('insert',
+		'{db_prefix}background_tasks',
+		array('task_file' => 'string', 'task_class' => 'string', 'task_data' => 'string', 'claimed_time' => 'int'),
+		array('$sourcedir/tasks/MsgReportReply-Notify.php', 'MsgReportReply_Notify_Background', serialize(array(
+			'report_id' => $_REQUEST['report'],
+			'comment_id' => $last_comment,
+			'msg_id' => $row['id_msg'],
+			'topic_id' => $row['id_topic'],
+			'board_id' => $row['id_board'],
+			'sender_id' => $user_info['id'],
+			'sender_name' => $user_info['name'],
+			'time' => time(),
+		)), 0),
+		array('id_task')
+	);
+}
 ?>

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

@@ -181,7 +181,7 @@ function template_viewmodreport()
 
 	echo '
 	<div id="modcenter">
-		<form action="', $scripturl, '?action=moderate;area=reports;report=', $context['report']['id'], '" method="post" accept-charset="', $context['character_set'], '">
+		<form action="', $scripturl, '?action=moderate;area=reports;sa;handlecomment;report=', $context['report']['id'], '" method="post" accept-charset="', $context['character_set'], '">
 			<div class="cat_bar">
 				<h3 class="catbg">
 					', sprintf($txt['mc_viewmodreport'], $context['report']['message_link'], $context['report']['author']['link']), '