From 7b4c49d7e91fe1b45158240c224ca4ff3cf1bef5 Mon Sep 17 00:00:00 2001 From: BJRambo Date: Tue, 7 Mar 2017 07:38:43 +0900 Subject: [PATCH] =?UTF-8?q?=ED=9C=B4=EC=A7=80=ED=86=B5=EC=97=90=EC=84=9C?= =?UTF-8?q?=20=EB=8C=93=EA=B8=80=20=EB=B3=B5=EC=9B=90=ED=95=A0=20=EC=88=98?= =?UTF-8?q?=20=EC=9E=88=EB=8A=94=20=EB=A9=94=EC=84=9C=EB=93=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/comment/comment.admin.controller.php | 13 +++++- modules/comment/comment.controller.php | 43 ++++++++++++++++++++ 2 files changed, 55 insertions(+), 1 deletion(-) diff --git a/modules/comment/comment.admin.controller.php b/modules/comment/comment.admin.controller.php index 500e178ce..0dcd0520c 100644 --- a/modules/comment/comment.admin.controller.php +++ b/modules/comment/comment.admin.controller.php @@ -467,7 +467,18 @@ class commentAdminController extends comment $obj->module_srl = $originObject->module_srl; $oCommentController = getController('comment'); - $output = $oCommentController->insertComment($obj, true); + $oCommentModel = getModel('comment'); + + $oComment = $oCommentModel->getComment($originObject->comment_srl); + + if($oComment) + { + $output = $oCommentController->updateCommentByRestore(); + } + else + { + $output = $oCommentController->insertComment($obj, true); + } return $output; } diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index ea0a471dc..2003b19e7 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -980,6 +980,49 @@ class commentController extends comment return $output; } + function updateCommentByRestore($obj, $is_admin = FALSE) + { + if (!$obj->comment_srl) + { + return new Object(-1, 'msg_invalid_request'); + } + + // begin transaction + $oDB = DB::getInstance(); + $oDB->begin(); + + $obj->status = RX_STATUS_PUBLIC; + $obj->member_srl = 0; + $output = executeQuery('comment.updateCommentByDelete', $obj); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + + // update the number of comments + $oCommentModel = getModel('comment'); + $comment_count = $oCommentModel->getCommentCount($obj->document_srl); + // only document is exists + if(isset($comment_count)) + { + // create the controller object of the document + $oDocumentController = getController('document'); + + // update comment count of the article posting + $output = $oDocumentController->updateCommentCount($obj->document_srl, $comment_count, NULL, FALSE); + if(!$output->toBool()) + { + $oDB->rollback(); + return $output; + } + } + + $oDB->commit(); + + return $output; + } + /** * Delete comment * @param int $comment_srl