/** * Validates and saves a new comment. Redirects back to the comments page. * @param $comment Posted comment. */ protected function postComment( WikilogComment &$comment ) { global $wgOut, $wgUser; global $wgWikilogModerateAnonymous; $check = $this->validateComment( $comment ); if ( $check !== false ) { return $this->view(); } # Check through captcha. if ( !WlCaptcha::confirmEdit( $this->getTitle(), $comment->getText() ) ) { $this->mCaptchaForm = WlCaptcha::getCaptchaForm(); $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->addHtml( $this->getPostCommentForm( $comment->mParent ) ); return; } # Limit rate of comments. if ( $wgUser->pingLimiter() ) { $wgOut->rateLimited(); return; } # Set pending state if moderated. if ( $comment->mUserID == 0 && $wgWikilogModerateAnonymous ) { $comment->mStatus = WikilogComment::S_PENDING; } if ( !$this->exists() ) { # Initialize a blank talk page. $user = User::newFromName( wfMsgForContent( 'wikilog-auto' ), false ); $this->doEdit( wfMsgForContent( 'wikilog-newtalk-text' ), wfMsgForContent( 'wikilog-newtalk-summary' ), EDIT_NEW | EDIT_SUPPRESS_RC, false, $user ); } $comment->saveComment(); $dest = $this->getTitle(); $dest->setFragment( "#c{$comment->mID}" ); $wgOut->redirect( $dest->getFullUrl() ); }