public function addAction() { if ($this->tplVars['lvals']['canEdit']) { array_push($this->tplVars['page_js'], 'jquery-1.8.3.js'); array_push($this->tplVars['page_js'], 'select2.min.js'); array_push($this->tplVars['page_css'], 'comments.css'); array_push($this->tplVars['page_css'], 'select2.css'); array_push($this->tplVars['header']['actions']['names'], array('name' => 'add', 'menu_name' => 'Add Comment')); array_push($this->viewIncludes, 'comments/commentsEdit.tpl'); $this->tplVars['lvals']['postRes'] = 2; $comments = new CommentsModel(); $this->tplVars['products'] = $comments->getProducts(true); $this->tplVars['pages'] = $comments->getPages(true, $this->getSiteId()); if ($this->_hasParam('pid')) { $this->tplVars['products']['select'] = array($this->_getParam('pid')); } $this->tplVars['lvals']['isNewRecord'] = true; if ($this->_request->getPost('ispost')) { $this->tplVars['comments'] = $this->_request->getPost(); $this->tplVars['pages']['select'] = $this->_request->getPost('comment_pages'); $this->tplVars['products']['select'] = $this->_request->getPost('comment_product_id'); $id = $this->tplVars['lvals']['postRes'] = $comments->addComment($this->tplVars['comments']); $this->to_log($id); if ($id > 0) { if ((bool) $this->_request->getPost('toitem')) { $this->_redirect('/comments/list/#comment' . $id . ''); } else { $this->_redirect('/comments/edit/id/' . $id . '/'); } } } } }