From 18f402968a5c13bddbc0094b74e61d96de547a4e Mon Sep 17 00:00:00 2001 From: Will Rossiter Date: Tue, 25 May 2010 02:08:17 +0000 Subject: [PATCH] BUGFIX: if moderation on comments is enabled then redirect the user back down to the comment section to view the message rather than trying to direct to selector which doesnt exist git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/cms/branches/2.4@105514 467b73ca-7a2a-4603-9d3b-597d59a354a9 --- code/sitefeatures/PageCommentInterface.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/code/sitefeatures/PageCommentInterface.php b/code/sitefeatures/PageCommentInterface.php index c4228a40..467c1bae 100755 --- a/code/sitefeatures/PageCommentInterface.php +++ b/code/sitefeatures/PageCommentInterface.php @@ -343,17 +343,19 @@ class PageCommentInterface_Form extends Form { if($comment->NeedsModeration){ $this->sessionMessage($moderationMsg, 'good'); } - // since it is not ajax redirect user down to their comment since it has been posted - // get the pages url off the comments parent ID. + if($comment->ParentID) { $page = DataObject::get_by_id("Page", $comment->ParentID); if($page) { - // Redirect to the actual post on the page. - return Director::redirect($page->Link() . '#PageComment_' . $comment->ID); + // if it needs moderation then it won't appear in the list. Therefore + // we need to link to the comment holder rather than the individual comment + $url = ($comment->NeedsModeration) ? $page->Link() . '#PageComments_holder' : $page->Link() . '#PageComment_' . $comment->ID; + + return Director::redirect($url); } } - - return Director::redirectBack(); // worst case, just go back to the page + + return Director::redirectBack(); } } }