public function executeTogglePublish()
 {
     $comment = sfSimpleBlogCommentPeer::retrieveByPk($this->getRequestParameter('id'));
     $this->forward404Unless($comment);
     $comment->setIsModerated(!$comment->getIsModerated());
     $comment->save();
     if ($this->getRequestParameter('from_email') == 1) {
         $this->comment = $comment;
         return sfView::SUCCESS;
     }
     if ($referer = $this->getRequest()->getReferer()) {
         $this->redirect($referer);
     } else {
         $this->redirect('sfSimpleBlogCommentAdmin/list');
     }
 }
 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));
     }
 }
 public function executeCommentsForPostFeed()
 {
     sfLoader::loadHelpers(array('I18N'));
     $post = sfSimpleBlogPostPeer::retrieveByStrippedTitleAndDate($this->getRequestParameter('stripped_title'), $this->getDateFromRequest());
     $this->forward404Unless($post);
     $comments = sfSimpleBlogCommentPeer::getForPost($post, $this->getRequestParameter('nb', sfConfig::get('app_sfSimpleBlog_feed_count', 5)));
     $this->feed = sfFeedPeer::createFromObjects($comments, array('format' => $this->getRequestParameter('format', 'atom1'), 'title' => __('Comments on post "%1%" from %2%', array('%1%' => $post->getTitle(), '%2%' => sfConfig::get('app_sfSimpleBlog_title', ''))), 'link' => $this->getController()->genUrl('sfSimpleBlog/show?stripped_title=' . $post->getStrippedTitle()), 'authorName' => sfConfig::get('app_sfSimpleBlog_author', ''), 'methods' => array('title' => 'getPostTitle', 'authorEmail' => '')));
     $this->setTemplate('feed');
 }
 public static function retrieveByPKs($pks, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria();
         $criteria->add(sfSimpleBlogCommentPeer::ID, $pks, Criteria::IN);
         $objs = sfSimpleBlogCommentPeer::doSelect($criteria, $con);
     }
     return $objs;
 }