public function executeAddComment(sfWebRequest $request)
  {
    $this->commentForm = new sfNestedCommentFrontForm(null, $this->getUser());
    $bindValues = $request->getParameter($this->commentForm->getName());
    if (sfNestedCommentConfig::isRecaptchaEnabled())
    {
      $captcha = array(
        'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
        'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'),
      );
      $bindValues = array_merge($bindValues, array('captcha' => $captcha));
    }
    $this->commentForm->bind($bindValues);
    if ($this->commentForm->isValid())
    {
      $comment = $this->commentForm->save();

      $this->getUser()->setFlash('add_comment', $comment->getIsModerated() ? 'moderated' : 'normal');
      
      $this->dispatcher->notify(new sfEvent($this, 'sf_nested_comment.add', array('object' => $comment)));

      $email_pref = sfNestedCommentConfig::isMailEnabled();
      if($email_pref == true || ($email_pref == 'moderated' && $comment->getIsModerated()))
      {
        $params = $this->prepareMailParameter($comment);
        sfNestedCommentTools::sendEmail($this->getMailer(), $params);
      }

      if($request->isXmlHttpRequest())
      {
        $this->setLayout(false);
        sfConfig::set('sf_web_debug', false);
        $commentableObject = $comment->getCommentableObject();
        $comments = sfNestedCommentTools::getComments($commentableObject, $request);
        return $this->renderPartial('sfNestedComment/comments', array('object' => $commentableObject, 'comments' => $comments, 'commentForm' =>  sfNestedCommentTools::createCommentForm($commentableObject)));
      }
      else
      {
        return $this->redirect($request->getReferer());
      }
    }
    else
    {
      if($request->isXmlHttpRequest())
      {
        $this->getResponse()->setStatusCode(404);
        $this->setLayout(false);
        sfConfig::set('sf_web_debug', false);
        return $this->renderPartial('sfNestedComment/add_comment', array('commentForm' => $this->commentForm));
      }
      else
      {
        return 'Error';
      }
    }
  }
 public function executeShowComments(sfWebRequest $request)
 {
   $this->comments = sfNestedCommentTools::getComments($this->object, $request);
   $this->commentForm = sfNestedCommentTools::createCommentForm($this->object, $this->getUser());
 }