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
This commit is contained in:
Will Rossiter 2010-05-25 02:08:17 +00:00 committed by Sam Minnee
parent 1b6741e08d
commit 18f402968a

View File

@ -343,17 +343,19 @@ class PageCommentInterface_Form extends Form {
if($comment->NeedsModeration){ if($comment->NeedsModeration){
$this->sessionMessage($moderationMsg, 'good'); $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) { if($comment->ParentID) {
$page = DataObject::get_by_id("Page", $comment->ParentID); $page = DataObject::get_by_id("Page", $comment->ParentID);
if($page) { if($page) {
// Redirect to the actual post on the page. // if it needs moderation then it won't appear in the list. Therefore
return Director::redirect($page->Link() . '#PageComment_' . $comment->ID); // 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();
} }
} }
} }