Example #1
0
 public function indexAction()
 {
     $envConf = Zend_Registry::get('environmentSettings');
     $req = $this->getRequest();
     $id = $req->getParam('id');
     $title = $req->getParam('title');
     $this->view->news = false;
     $this->view->paginator = false;
     $this->view->writeForm = new News_Form_Comment('#');
     if ($id) {
         $this->view->news = News_Model_News::getNewsById($id);
     } else {
         if ($title) {
             $this->view->news = News_Model_News::getNewsBySlug(urldecode($title));
         }
     }
     if ($this->view->news) {
         $paginator = $this->view->news->getCommentPaginator(false, true);
         $page = $req->getParam('page');
         $paginator->setItemCountPerPage($this->conf->news->comments->numpage);
         $paginator->setCurrentPageNumber($page);
         $this->view->paginator = $paginator;
     }
     if ($req->isPost() && $this->view->news) {
         if ($this->view->writeForm->isValid($_POST)) {
             $values = $this->view->writeForm->getValues();
             $nc = new News_Model_Comment();
             $nc->ip = getenv('REMOTE_ADDR');
             $nc->email = User_Model_User::isLoggedIn() ? Zend_Auth::getInstance()->getIdentity()->email : $values['email'];
             $nc->news_id = $this->view->news->id;
             $nc->visible = 'yes';
             // there is no moderation yet
             $nc->author = User_Model_User::isLoggedIn() ? Zend_Auth::getInstance()->getIdentity()->name : $values['author'];
             $nc->url = $values['url'];
             $nc->comment = $values['comment'];
             $nc->checkSpam();
             $nc->save();
             $this->view->writeForm = new News_Form_Comment('#');
             // clear form because comment is submitted
         }
     }
 }
Example #2
0
 public function previewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $n = News_Model_News::getNewsById($id);
     if (!$n) {
         $this->session->message = $this->translate('news_not_existent');
         $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'admin', 'module' => 'news'), 'news');
     }
     $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'comment', 'module' => 'news', 'title' => $n->title_slug), 'news_new_perma');
 }