Add option to control updating the document's last-updated timestamp when a comment is posted

This commit is contained in:
Kijin Sung 2017-05-07 21:37:37 +09:00
parent 8c797aaba1
commit d3db01aae0
7 changed files with 49 additions and 35 deletions

View file

@ -435,6 +435,9 @@ class boardController extends board
// INSERT if comment_srl does not exist.
if($comment->comment_srl != $obj->comment_srl)
{
// Update document last_update info?
$update_document = $this->module_info->update_order_on_comment === 'N' ? false : true;
// Parent exists.
if($obj->parent_srl)
{
@ -443,12 +446,12 @@ class boardController extends board
{
return new Object(-1, 'msg_invalid_request');
}
$output = $oCommentController->insertComment($obj, $bAnonymous);
$output = $oCommentController->insertComment($obj, $bAnonymous, $update_document);
}
// Parent does not exist.
else
{
$output = $oCommentController->insertComment($obj, $bAnonymous);
$output = $oCommentController->insertComment($obj, $bAnonymous, $update_document);
}
// Set grant for the new comment.
if ($output->toBool())

View file

@ -43,6 +43,8 @@ $lang->about_hide_category = 'You can disable a category feature.';
$lang->protect_content = 'Protect Content';
$lang->protect_comment = 'Protect Comment';
$lang->protect_regdate = 'Update/Delete Time Limit';
$lang->update_order_on_comment = 'Update Document on New Comment';
$lang->about_update_order_on_comment = 'When a new comment is posted, update the update timestamp of the parent document. This is needed for forums.';
$lang->non_login_vote = 'Allow guest votes';
$lang->about_non_login_vote = 'Allow users who are not logged in to vote on articles.';
$lang->about_protect_regdate = 'Prevent updating or deleting a document or comment after a certain amount of time has passed. (Unit: day)';

View file

@ -16,7 +16,7 @@ $lang->secret = '비밀글 기능';
$lang->thisissecret = '비밀글입니다.';
$lang->admin_mail = '관리자 메일';
$lang->update_log = '게시글 수정 내역';
$lang->last_updater = '수정한사람';
$lang->last_updater = '수정한 사람';
$lang->cmd_board_list = '게시판 목록';
$lang->cmd_module_config = '게시판 공통 설정';
$lang->cmd_board_info = '게시판 정보';
@ -48,6 +48,8 @@ $lang->about_hide_category = '임시로 분류를 사용하지 않으려면 체
$lang->protect_content = '글 보호 기능';
$lang->protect_comment = '댓글 보호 기능';
$lang->protect_regdate = '기간 제한 기능';
$lang->update_order_on_comment = '댓글 작성시 글 수정 시각 갱신';
$lang->about_update_order_on_comment = '댓글이 작성되면 해당 글의 수정 시각을 갱신합니다. 포럼형 게시판, 최근 댓글 표시 기능 등에 필요합니다.';
$lang->non_login_vote = '비회원 추천 허용';
$lang->about_non_login_vote = '로그인하지 않은 방문자도 추천할 수 있도록 합니다.';
$lang->about_protect_regdate = '글이나 댓글을 작성한 후 일정 기간이 지나면 수정 또는 삭제할 수 없도록 합니다. (단위 : day)';

View file

@ -238,6 +238,18 @@
<p>{$lang->msg_warning_update_log}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->update_order_on_comment}</label>
<div class="x_controls">
<label class="x_inline">
<input type="radio" id="update_order_on_comment_y" name="update_order_on_comment" value="Y" checked="checked"|cond="$module_info->update_order_on_comment != 'N'" /> {$lang->cmd_yes}
</label>
<label class="x_inline">
<input type="radio" id="update_order_on_comment_n" name="update_order_on_comment" value="N" checked="checked"|cond="$module_info->update_order_on_comment == 'N'" /> {$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_update_order_on_comment}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->document_force_to_move}</label>
<div class="x_controls">
@ -245,11 +257,23 @@
<input type="radio" id="trash_use_y" name="trash_use" value="Y" checked="checked"|cond="$module_info->trash_use == 'Y'" /> {$lang->cmd_yes}
</label>
<label class="x_inline">
<input type="radio" id="trash_use_n" name="trash_use" value="N" checked="checked"|cond="$module_info->trash_use == 'N'" /> {$lang->cmd_no}
<input type="radio" id="trash_use_n" name="trash_use" value="N" checked="checked"|cond="$module_info->trash_use != 'Y'" /> {$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_document_force_to_move}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->non_login_vote}</label>
<div class="x_controls">
<label class="x_inline">
<input type="radio" id="non_login_vote_y" name="non_login_vote" value="Y" checked="checked"|cond="$module_info->non_login_vote == 'Y'" /> {$lang->cmd_yes}
</label>
<label class="x_inline">
<input type="radio" id="non_login_vote_n" name="non_login_vote" value="N" checked="checked"|cond="$module_info->non_login_vote != 'Y'" /> {$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_non_login_vote}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->protect_content}</label>
<div class="x_controls">
@ -261,8 +285,8 @@
<div class="x_control-group">
<label class="x_control-label">{$lang->protect_comment}</label>
<div class="x_controls">
<label class="x_inline" for="protect_delete_comment"><input type="checkbox" name="protect_delete_comment" id="protect_delete_comment" value="Y" checked="checked"|cond="$module_info->protect_delete_comment == 'Y'" />{$lang->cmd_delete} </label>
<label class="x_inline" for="protect_update_comment"><input type="checkbox" name="protect_update_comment" id="protect_update_comment" value="Y" checked="checked"|cond="$module_info->protect_update_comment == 'Y'" />{$lang->cmd_modify} </label>
<label class="x_inline" for="protect_delete_comment"><input type="checkbox" name="protect_delete_comment" id="protect_delete_comment" value="Y" checked="checked"|cond="$module_info->protect_delete_comment == 'Y'" /> {$lang->cmd_delete}</label>
<label class="x_inline" for="protect_update_comment"><input type="checkbox" name="protect_update_comment" id="protect_update_comment" value="Y" checked="checked"|cond="$module_info->protect_update_comment == 'Y'" /> {$lang->cmd_modify}</label>
<p>{$lang->about_protect_comment}</p>
</div>
</div>
@ -298,18 +322,6 @@
<p class="x_help-block">{$lang->about_use_status}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->non_login_vote}</label>
<div class="x_controls">
<label class="x_inline">
<input type="radio" id="non_login_vote_y" name="non_login_vote" value="Y" checked="checked"|cond="$module_info->non_login_vote == 'Y'" /> {$lang->use}
</label>
<label class="x_inline">
<input type="radio" id="non_login_vote_n" name="non_login_vote" value="N" checked="checked"|cond="$module_info->non_login_vote != 'Y'" /> {$lang->notuse}
</label>
<p class="x_help-block">{$lang->about_non_login_vote}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label" for="admin_mail">{$lang->admin_mail}</label>
<div class="x_controls">

View file

@ -290,9 +290,10 @@ class commentController extends comment
* Enter comments
* @param object $obj
* @param bool $manual_inserted
* @param bool $update_document
* @return object
*/
function insertComment($obj, $manual_inserted = FALSE)
function insertComment($obj, $manual_inserted = FALSE, $update_document = TRUE)
{
if(!$manual_inserted && !checkCSRF())
{
@ -565,16 +566,9 @@ class commentController extends comment
$oDocumentController = getController('document');
// Update the number of comments in the post
if(!$using_validation)
if(!$using_validation || $is_admin)
{
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
}
else
{
if($is_admin)
{
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, TRUE);
}
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, $update_document);
}
// call a trigger(after)

View file

@ -1585,24 +1585,25 @@ class documentController extends document
* @param int $document_srl
* @param int $comment_count
* @param string $last_updater
* @param bool $comment_inserted
* @param bool $update_order
* @return object
*/
function updateCommentCount($document_srl, $comment_count, $last_updater, $comment_inserted = false)
function updateCommentCount($document_srl, $comment_count, $last_updater, $update_order = false)
{
$args = new stdClass();
$args->document_srl = $document_srl;
$args->comment_count = $comment_count;
if($comment_inserted)
if($update_order)
{
$args->update_order = -1*getNextSequence();
$args->last_update = date('YmdHis');
$args->last_updater = $last_updater;
// remove document item from cache
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
}
// remove document item from cache
Rhymix\Framework\Cache::delete('document_item:' . getNumberingPath($document_srl) . $document_srl);
return executeQuery('document.updateCommentCount', $args);
}

View file

@ -5,7 +5,7 @@
<columns>
<column name="comment_count" var="comment_count" notnull="notnull" />
<column name="update_order" var="update_order" />
<column name="last_update" var="last_update" default="curdate()" />
<column name="last_update" var="last_update" />
<column name="last_updater" var="last_updater" />
</columns>
<conditions>