휴지통에서 댓글 복원할 수 있는 메서드 추가.

This commit is contained in:
BJRambo 2017-03-07 07:38:43 +09:00
parent b040372133
commit 7b4c49d7e9
2 changed files with 55 additions and 1 deletions

View file

@ -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;
}

View file

@ -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