public function executeAddComment()
 {
     $this->forward404Unless(sfConfig::get('app_sfSimpleBlog_comment_enabled', true));
     $post = sfSimpleBlogPostPeer::retrieveByStrippedTitleAndDate($this->getRequestParameter('stripped_title'), $this->getRequestParameter('date'));
     $this->forward404Unless($post);
     $this->forward404Unless($post->allowComments());
     $comment = new sfSimpleBlogComment();
     $comment->setSfBlogPostId($post->getId());
     $automoderation = sfConfig::get('app_sfSimpleBlog_comment_automoderation', 'first_post');
     if ($automoderation === true || $automoderation === 'first_post' && !sfSimpleBlogCommentPeer::isAuthorApproved($this->getRequestParameter('name'), $this->getRequestParameter('mail'))) {
         $comment->setIsModerated(true);
         $this->setFlash('add_comment', 'moderated');
     } else {
         $this->setFlash('add_comment', 'normal');
     }
     $comment->setAuthorName($this->getRequestParameter('name'));
     $comment->setAuthorEmail($this->getRequestParameter('mail'));
     if ($url = $this->getRequestParameter('website', '')) {
         if (strpos($url, 'http://') !== 0) {
             $url = 'http://' . $url;
         }
         $comment->setAuthorUrl($url);
     }
     $comment->setContent(strip_tags($this->getRequestParameter('content')));
     $comment->save();
     $email_pref = sfConfig::get('app_sfSimpleBlog_comment_mail_alert', 1);
     if ($email_pref == 1 || $email_pref == 'moderated' && $comment->getIsModerated()) {
         $this->getRequest()->setAttribute('comment', $comment);
         $raw_email = $this->sendEmail('sfSimpleBlog', 'sendMailOnComment');
         $this->logMessage($raw_email, 'debug');
     }
     if ($this->getRequest()->isXmlHttpRequest()) {
         $this->post = $post;
         $this->comments = $post->getComments();
         return 'Ajax';
     } else {
         $this->redirect(sfSimpleBlogTools::generatePostUri($post));
     }
 }