Commit e015fffc authored by Luke Ward's avatar Luke Ward
Browse files

Catch MySQL error when submitting duplicate post report

parent 33dab250
......@@ -309,12 +309,17 @@
INSERT INTO `forum_flags` (`post_id`, `user_id`, `type`, `comment`)
VALUES (:post_id, :user_id, :type, :comment);
");
$stmt->execute(array(
':post_id' => $data['post_id'],
':user_id' => $DtW->user->id,
':type' => $data['reason'],
':comment' => $data['comment']
));
try {
$stmt->execute(array(
':post_id' => $data['post_id'],
':user_id' => $DtW->user->id,
':type' => $data['reason'],
':comment' => $data['comment']
));
} catch (\Exception $e) {
throw new \Exception('Report not submitted. You may have already reported this post.');
}
}
private function loadTopics() {
......
......@@ -24,10 +24,10 @@ modal.feedback = function(data) {
if (data.type == 'success') {
$modal.addClass('feedback-success');
$modal.html('<i class="fa fa-check-circle-o" aria-hidden="true"></i><span>' + data.msg + '</span>');
$modal.html('<i class="far fa-check-circle" aria-hidden="true"></i><span>' + data.msg + '</span>');
} else {
$modal.addClass('feedback-error');
$modal.html('<i class="fa fa-times-circle-o" aria-hidden="true"></i><span>' + data.msg + '</span>');
$modal.html('<i class="far fa-times-circle" aria-hidden="true"></i><span>' + data.msg + '</span>');
}
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment