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