/** * Validate the message * * @return boolean */ protected function _validateMessage() { $validator = new Zend_Validate_StringLength(2); if (!$validator->isValid($this->comment->getMessage())) { $this->errors['message'] = $validator->getMessages(); return false; } return true; }
/** * Save a comment object to the database * * @param SxCms_Comment $comment * @return mixed */ public function save(SxCms_Comment $comment) { $db = Zend_Registry::get('db'); $author = $comment->getCommenter(); $data = array('page_id' => $comment->getPage()->getId(), 'comment' => $comment->getMessage(), 'datePosted' => date('Y-m-d H:i:s'), 'author_name' => $author->getName(), 'author_email' => $author->getEmail(), 'author_link' => $author->getWebsite(), 'approved' => $comment->isApproved(), 'dateApproved' => $comment->getDateApproved()); if (!$comment->getId()) { $result = $db->insert('PageComment', $data); $comment->setId($db->lastInsertId()); return $result; } return $db->update('PageComment', $data, 'comment_id = ' . $comment->getId()); }