댓글 삭제할때에도 휴지통 사용여부에 따라 휴지통으로 이동할 수 있도록 기능 추가

This commit is contained in:
BJRambo 2017-03-06 11:38:47 +09:00
parent 46055ffa66
commit b040372133
3 changed files with 117 additions and 6 deletions

View file

@ -530,6 +530,10 @@ class boardController extends board
if($this->module_info->comment_delete_message === 'yes' && $instant_delete != 'Y')
{
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
if($this->module_info->trash_use == 'Y')
{
$output = $oCommentController->moveCommentToTrash($comment);
}
}
elseif(starts_with('only_comm', $this->module_info->comment_delete_message) && $instant_delete != 'Y')
{
@ -537,22 +541,40 @@ class boardController extends board
if(count($childs) > 0)
{
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
if($this->module_info->trash_use == 'Y')
{
$output = $oCommentController->moveCommentToTrash($comment);
}
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager, FALSE, $childs);
if(!$output->toBool())
if($this->module_info->trash_use == 'Y')
{
return $output;
$output = $oCommentController->moveCommentToTrash($comment);
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager, FALSE, $childs);
if(!$output->toBool())
{
return $output;
}
}
}
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
if(!$output->toBool())
if($this->module_info->trash_use == 'Y')
{
return $output;
$output = $oCommentController->moveCommentToTrash($comment);
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
if(!$output->toBool())
{
return $output;
}
}
}

View file

@ -1143,6 +1143,94 @@ class commentController extends comment
return $output;
}
/**
* Comment move to trash
* @param $obj
* @return object
*/
function moveCommentToTrash($obj)
{
$logged_info = Context::get('logged_info');
$trash_args = new stdClass();
if(!$obj->trash_srl)
{
$trash_args->trash_srl = getNextSequence();
}
else
{
$trash_args->trash_srl = $obj->trash_srl;
}
$oCommentModel = getModel('comment');
$oComment = $oCommentModel->getComment($obj->comment_srl);
$oMemberModel = getModel('member');
$member_info = $oMemberModel->getMemberInfoByMemberSrl($oComment->get('member_srl'));
if($member_info->is_admin == 'Y' && $logged_info->is_admin != 'Y')
{
return new Object(-1, 'msg_admin_comment_no_move_to_trash');
}
$trash_args->module_srl = $oComment->variables['module_srl'];
$obj->module_srl = $oComment->variables['module_srl'];
if($trash_args->module_srl === 0)
{
return false;
}
$trash_args->document_srl = $obj->document_srl;
$trash_args->comment_srl = $obj->comment_srl;
$trash_args->description = $obj->description;
if(!Context::get('is_logged'))
{
$trash_args->member_Srl = $logged_info->member_srl;
$trash_args->user_id = htmlspecialchars_decode($logged_info->user_id);
$trash_args->user_name = htmlspecialchars_decode($logged_info->user_name);
$trash_args->nick_name = htmlspecialchars_decode($logged_info->nick_name);
}
$oDB = &DB::getInstance();
$oDB->begin();
require_once(RX_BASEDIR.'modules/trash/model/TrashVO.php');
$oTrashVO = new TrashVO();
$oTrashVO->setTrashSrl(getNextSequence());
$oTrashVO->setTitle(trim(strip_tags($oComment->variables['content'])));
$oTrashVO->setOriginModule('comment');
$oTrashVO->setSerializedObject(serialize($oComment->variables));
$oTrashVO->setDescription($obj->description);
$oTrashAdminController = getAdminController('trash');
$output = $oTrashAdminController->insertTrash($oTrashVO);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
$output = executeQuery('comment.deleteComment', $trash_args);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
if($oComment->hasUploadedFiles())
{
$args = new stdClass();
$args->upload_target_srl = $oComment->comment_srl;
$args->isvalid = 'N';
executeQuery('file.updateFileValid', $args);
}
ModuleHandler::triggerCall('comment.moveCommentToTrash', 'after', $obj);
$oDB->commit();
return $output;
}
/**
* Remove all comment relation log
* @return Object

View file

@ -55,3 +55,4 @@ $lang->msg_deleted_comment = '삭제된 댓글입니다.';
$lang->msg_admin_deleted_comment = '관리자가 삭제한 댓글입니다.';
$lang->msg_no_text_comment = '글자가 없는 댓글입니다.';
$lang->msg_comment_notify_mail = '[%s] 새로운 댓글이 등록되었습니다 : %s';
$lang->msg_admin_comment_no_move_to_trash = '최고관리자의 댓글을 휴지통으로 이동시킬 권한이 없습니다.';