public function editAction() { $itemId = $this->_request->getParam('id'); if (is_null($itemId)) { $this->_redirector->gotoUrlAndExit($this->getCurrentUrl()); return; } $item = $this->_modelMapper->find($itemId, new Forum_Model_Forum()); $oldContent = $item->getContent(); $markdown = $this->_request->getParam('contentMarkdown'); if ($markdown && $markdown != '') { $context_html = Michelf\MarkdownExtra::defaultTransform($markdown); $item->setContent($context_html); $item->setContentMarkdown($markdown); $item->setTimestamp(date("Y-m-d H:i:s")); if ($this->_userAuth->email != $item->getEmail()) { $item->setAuthor($this->_userAuth->name); $item->setEmail($this->_userAuth->email); $this->sendEditMail($item, $oldContent); } $this->_modelMapper->save($item); } $cacheName = !$item->getParentId() ? 'forumQuestions' : 'forumReply'; $this->clearCache($cacheName); $this->_redirector->gotoUrlAndExit($this->getCurrentUrl()); }
function getBlockForum() { $forumMapper = new Forum_Model_Mapper_Forum(); $select = $forumMapper->getDbTable()->select(); $select->where('parent_id != ?', 'null')->order('timestamp DESC')->limit(1, 0); $forumReply = $forumMapper->fetchAll($select); if (!empty($forumReply)) { $forumReply = array_shift($forumReply); $forumQuestion = $forumMapper->find($forumReply->getParentId(), new Forum_Model_Forum()); if (!is_null($forumQuestion)) { $this->view->assign(array('forum_question' => $forumQuestion, 'forum_reply' => $forumReply)); } } }