When deleting a comment, add to display 'deleted' message.

This commit is contained in:
BJRambo 2016-05-23 05:05:51 +09:00
parent fc8025759c
commit 228eb1f6c9
5 changed files with 95 additions and 5 deletions

View file

@ -510,10 +510,19 @@ class boardController extends board
// generate comment controller object
$oCommentController = getController('comment');
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
if(!$output->toBool())
if($this->module_info->comment_delete_message === 'Y')
{
return $output;
$comment->content = '';
$comment->status = 7;
$output = $oCommentController->updateCommentByDelete($comment, $this->grant->manager);
}
else
{
$output = $oCommentController->deleteComment($comment_srl, $this->grant->manager);
if(!$output->toBool())
{
return $output;
}
}
$this->add('mid', Context::get('mid'));

View file

@ -73,3 +73,5 @@ $lang->document_force_to_move = '삭제시 휴지통으로 강제이동';
$lang->about_document_force_to_move = '게시글을 삭제시 휴지통으로 강제이동할지 않할지를 선택하는 옵션입니다.';
$lang->comment_delete_message = '댓글 삭제 메세지';
$lang->about_comment_delete_message = '이 옵션을 사용할 경우 댓글을 삭제할 경우, 댓글이 삭제가 되지 않고 댓글의 내용에 삭제된 메세지를 띄우게 됩니다. 추후 다시 댓글을 복구 할 수 있습니다.';
$lang->msg_delete_comment = '댓글이 삭제되었습니다.';
$lang->msg_admin_delete_comment = '관리자에 의해 댓글이 삭제되었습니다.';

View file

@ -25,7 +25,16 @@
<input type="hidden" name="comment_srl" value="{$comment->get('comment_srl')}" />
</form>
<!--@else-->
{$comment->getContent(false)}
<div class="xe_content">
<!--@if($comment->status == 7)-->
댓글이 삭제되었습니다.
<!--@elseif($comment->status == 8)-->
관리자에 의해 댓글이 삭제되었습니다.
<!--@end-->
</div>
<block cond="$comment->status != '8' && $comment->status != '7'">
{$comment->getContent(false)}
</block>
<!--@end-->
<div cond="$comment->hasUploadedFiles()" class="fileList">
<button type="button" class="toggleFile" onclick="jQuery(this).next('ul.files').toggle();"><i class="xi-diskette"></i> {$lang->uploaded_file} [<strong>{$comment->get('uploaded_count')}</strong>]</button>
@ -33,7 +42,7 @@
<li loop="$comment->getUploadedFiles()=>$key,$file"><a href="{getUrl('')}{$file->download_url}">{$file->source_filename} <span class="fileSize">[File Size:{FileHandler::filesize($file->file_size)}/Download:{number_format($file->download_count)}]</span></a></li>
</ul>
</div>
<p class="action">
<p class="action" cond="$comment->status < 7">
<a cond="$comment->getVote() === false || $comment->getVote() < 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteUp','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote}{$comment->get('voted_count')}</a>
<a cond="$comment->getVote() > 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteUpCancel','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote}{$comment->get('voted_count')}</a>
<a cond="$comment->getVote() === false || $comment->getVote() > 0" href="#" onclick="doCallModuleAction('comment','procCommentVoteDown','{$comment->comment_srl}');return false;"|cond="$is_logged" class="voted"><i class="xi-thumbs-up"></i>{$lang->cmd_vote_down}{$comment->get('blamed_count')}</a>
@ -43,6 +52,9 @@
<a cond="$comment->isGranted()||!$comment->get('member_srl')" href="{getUrl('act','dispBoardDeleteComment','comment_srl',$comment->comment_srl)}" class="delete"><i class="xi-trash"></i> {$lang->cmd_delete}</a>
<a cond="$is_logged" class="comment_{$comment->comment_srl} this" href="#popup_menu_area" onclick="return false">{$lang->cmd_comment_do}</a>
</p>
<p class="action">
</p>
</li>
</ul>
<div cond="$oDocument->comment_page_navigation" class="pagination">

View file

@ -904,6 +904,48 @@ class commentController extends comment
return $output;
}
/**
* Fix comment the delete comment message
* @param object $obj
* @param bool $is_admin
* @return object
*/
function updateCommentByDelete($obj, $is_admin = FALSE)
{
$logged_info = Context::get('logged_info');
// begin transaction
$oDB = DB::getInstance();
$oDB->begin();
// If the case manager to delete comments, it indicated that the administrator deleted.
if($is_admin === true && $obj->member_srl !== $logged_info->member_srl)
{
$obj->content = lang('msg_admin_delete_comment');
$obj->status = 8;
}
else
{
$obj->content = lang('msg_delete_comment');
}
$output = executeQuery('comment.updateCommentByDelete', $obj);
if(!$output->toBool())
{
$oDB->rollback();
return $output;
}
// call a trigger by delete (after)
ModuleHandler::triggerCall('comment.updateCommentByDelete', 'after', $obj);
$oDB->commit();
$output->add('document_srl', $obj->document_srl);
return $output;
}
/**
* Delete comment
* @param int $comment_srl

View file

@ -0,0 +1,25 @@
<query id="updateCommentByDelete" action="update">
<tables>
<table name="comments" />
</tables>
<columns>
<column name="module_srl" var="module_srl" filter="number" default="0" />
<column name="member_srl" var="member_srl" />
<column name="parent_srl" var="parent_srl" filter="number" default="0" />
<column name="is_secret" var="is_secret" default="N" />
<column name="notify_message" var="notify_message" default="N" />
<column name="content" var="content" notnull="notnull" />
<column name="password" var="password" minlength="2" maxlength="60" />
<column name="user_id" var="user_id" />
<column name="user_name" var="user_name" default="" />
<column name="nick_name" var="nick_name" notnull="notnull" minlength="1" maxlength="40" />
<column name="email_address" var="email_address" filter="email" maxlength="250" />
<column name="homepage" var="homepage" filter="homepage" maxlength="250" />
<column name="uploaded_count" var="uploaded_count" default="0" />
<column name="last_update" var="last_update" default="curdate()" />
<column name="status" var="status" default="1" />
</columns>
<conditions>
<condition operation="equal" column="comment_srl" var="comment_srl" filter="number" notnull="notnull" />
</conditions>
</query>