public function action_add() { if (!$this->user->id) { $this->redirect('/'); } $comment = new Model_Comment(); $comment->article_id = Arr::get($_POST, 'article_id'); $comment->text = Arr::get($_POST, 'text'); $comment->parent_id = Arr::get($_POST, 'parent_id', '0'); $comment->user_id = $this->user->id; if (preg_match('(^[0-9]{1,})', $comment->article_id) != true) { $this->redirect('/'); } if ($comment->text == '') { $this->redirect('/article/' . $comment->article_id); } if ($comment->parent_id != 0) { $parent_comment = Model_Comment::get($comment->parent_id); if ($parent_comment->parent_id != 0) { $comment->root_id = $parent_comment->root_id; } else { $comment->root_id = $parent_comment->id; } } else { $comment->root_id = 0; } $comment->insert(); $this->redirect('/article/' . $comment->article_id); }
$objComment = new Model_Comment($objConnection); $objCommentBad = new Model_CommentBad($objConnection); $objUser = new Model_User($objConnection); $objArticle = new Model_Article($objConnection); $objArticleType = new Model_ArticleType($objConnection); if ($_pgR["act"] == model_Article::ACT_ADD || $_pgR["act"] == model_Article::ACT_UPDATE) { if (global_common::isCLogin()) { //get user info $c_userInfo = $_SESSION[global_common::SES_C_USERINFO]; $articleid = $_pgR[global_mapping::ArticleID]; $content = html_entity_decode($_pgR[global_mapping::Content], ENT_COMPAT, 'UTF-8'); $createdby = $c_userInfo[global_mapping::UserID]; $status = 1; if ($_pgR["act"] == Model_Comment::ACT_ADD) { $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objComment->insert($articleid, $content, $createdby, $status); //echo global_common::convertToXML($arrHeader, array("rs","info"), array(0,$resultID), array(0,1)); //return; if ($resultID) { $commentHTML = $objComment->getCommentHTMLByArticle($articleid); $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf", "form"), array(1, 'Gửi bình luận thành công', $commentHTML), array(0, 1, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "info"), array(0, "Input data is invalid"), array(0, 1)); return; } } else { $modifiedBy = $c_userInfo[global_mapping::UserID]; $articleID = html_entity_decode($_pgR[global_mapping::ArticleID], ENT_COMPAT, 'UTF-8');
// echo global_common::convertToXML($arrHeader, array("rs",'info'), array(0,global_common::STRING_NAME_EXIST), array(0,1)); // return; //} $commentID = $_pgR['CommentID']; $commentID = global_editor::rteSafe(html_entity_decode($commentID, ENT_COMPAT, 'UTF-8')); $commentType = $_pgR['CommentType']; $commentType = global_editor::rteSafe(html_entity_decode($commentType, ENT_COMPAT, 'UTF-8')); $articleID = $_pgR['ArticleID']; $articleID = global_editor::rteSafe(html_entity_decode($articleID, ENT_COMPAT, 'UTF-8')); $content = $_pgR['Content']; $content = global_editor::rteSafe(html_entity_decode($content, ENT_COMPAT, 'UTF-8')); $status = $_pgR['Status']; $status = global_editor::rteSafe(html_entity_decode($status, ENT_COMPAT, 'UTF-8')); //$strName = $_pgR['name']; //$strName = global_editor::rteSafe(html_entity_decode($strName,ENT_COMPAT ,'UTF-8' )); $resultID = $objComment->insert($commentType, $articleID, $content); if ($resultID) { $intPage = 1; $total = 0; $comments = $objComment->getCommentByArticle($intPage, $total, $articleID, '*', '', ' CreatedDate DESC'); $path = 'include/_comment_list.inc'; ob_start(); include $path; $contents = ob_get_contents(); ob_end_clean(); $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array('rs', 'inf', 'list'), array(1, 'Your comment was posted successfully', $contents), array(0, 1, 1)); return; } else { echo global_common::convertToXML($arrHeader, array("rs", "info"), array(0, "Input data is invalid"), array(0, 1));
$objCommentBad = new Model_CommentBad($objConnection); $objUser = new Model_User($objConnection); $objArticle = new Model_Article($objConnection); $objArticleType = new Model_ArticleType($objConnection); $objRetailer = new Model_Retailer($objConnection); $objProduct = new Model_Product($objConnection); if ($_pgR["act"] == Model_Comment::ACT_ADD) { if (global_common::isCLogin()) { //get user info $c_userInfo = $_SESSION[global_common::SES_C_USERINFO]; $retailerID = $_pgR[global_mapping::RetailerID]; $content = html_entity_decode($_pgR[global_mapping::Content], ENT_COMPAT, 'UTF-8'); $createdby = $c_userInfo[global_mapping::UserID]; $status = 1; $createdBy = $c_userInfo[global_mapping::UserID]; $resultID = $objComment->insert($retailerID, $content, $createdby, $status); //echo global_common::convertToXML($arrHeader, array("rs","info"), array(0,$resultID), array(0,1)); //return; if ($resultID) { $commentHTML = $objComment->getCommentHTMLByArticle($retailerID, 0); $arrHeader = global_common::getMessageHeaderArr($banCode); //$banCode echo global_common::convertToXML($arrHeader, array("rs", "inf", "form"), array(1, 'Gửi bình luận thành công', $commentHTML), array(0, 1, 1)); try { //echo $retailerID; $retailer = $objRetailer->getRetailerByID($retailerID); //print_r($retailer); //recieve email when got a comment if ($retailer[global_mapping::Status]) { //echo 'send mail:'; $product = $objProduct->getProductByID($retailer[global_mapping::ProductID]);