public function save($subject, $body, $commentOn, $name = null, $email = null, $website = null) { $commentClass = $this->_commentClass; $comment = new $commentClass; $comment->title = $subject; $comment->comment = $body; if (UserSession::get()) { $comment->author = UserSession::get()->user(); $comment->spamStatus = PropertySpamStatus::OK; } else { $publicProfile = new AnonProfile; $publicProfile->name = $name; $publicProfile->email = $email; $publicProfile->website = $website; $publicProfile->IP = Session::IP(); $comment->anonAuthor = $publicProfile; if ($this->checkSpamStatus($comment, $publicProfile) === false) { $this->newComment = $comment; $this->commentRequests = $this->_commentRequests; $this->renderErrorSave($commentOn); return; } } if ($comment->spamStatus != PropertySpamStatus::SPAM) { try { $commentOn->comments[] = $comment; if ($comment->spamStatus == PropertySpamStatus::OK) { $this->notice(t('Your comment has been posted')); } $this->beforeSuccess($commentOn, $comment); $this->redirectOnSuccess($commentOn); } catch (ValidationException $e) { $this->error(t('Your comment was not posted')); $this->newComment = $comment; $this->commentRequests = $this->_commentRequests; $this->renderErrorSave($commentOn); } } else { $this->notice(t('Your comment has been marked as spam, and will not appear')); $this->redirectOnSuccess($commentOn); } }