From d3db01aae0d087c40e80681dc1e095935ed3a463 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Sun, 7 May 2017 21:37:37 +0900 Subject: [PATCH] Add option to control updating the document's last-updated timestamp when a comment is posted --- modules/board/board.controller.php | 7 +++- modules/board/lang/en.php | 2 + modules/board/lang/ko.php | 4 +- modules/board/tpl/board_insert.html | 42 ++++++++++++------- modules/comment/comment.controller.php | 14 ++----- modules/document/document.controller.php | 13 +++--- .../document/queries/updateCommentCount.xml | 2 +- 7 files changed, 49 insertions(+), 35 deletions(-) diff --git a/modules/board/board.controller.php b/modules/board/board.controller.php index 50bd382dd..ff9970ffd 100644 --- a/modules/board/board.controller.php +++ b/modules/board/board.controller.php @@ -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()) diff --git a/modules/board/lang/en.php b/modules/board/lang/en.php index 6c687baf7..c417cc6d4 100644 --- a/modules/board/lang/en.php +++ b/modules/board/lang/en.php @@ -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)'; diff --git a/modules/board/lang/ko.php b/modules/board/lang/ko.php index fe606a780..d0d93ade9 100644 --- a/modules/board/lang/ko.php +++ b/modules/board/lang/ko.php @@ -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)'; diff --git a/modules/board/tpl/board_insert.html b/modules/board/tpl/board_insert.html index f98d2cbca..4de695ac7 100644 --- a/modules/board/tpl/board_insert.html +++ b/modules/board/tpl/board_insert.html @@ -238,6 +238,18 @@

{$lang->msg_warning_update_log}

+
+ +
+ + +

{$lang->about_update_order_on_comment}

+
+
@@ -245,11 +257,23 @@ {$lang->cmd_yes}

{$lang->about_document_force_to_move}

+
+ +
+ + +

{$lang->about_non_login_vote}

+
+
@@ -261,8 +285,8 @@
- - + +

{$lang->about_protect_comment}

@@ -298,18 +322,6 @@

{$lang->about_use_status}

-
- -
- - -

{$lang->about_non_login_vote}

-
-
diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index 81e020862..023013910 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -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) diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 771729127..617c7c1d0 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -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); } diff --git a/modules/document/queries/updateCommentCount.xml b/modules/document/queries/updateCommentCount.xml index 2f4ac9b64..defbebdc4 100644 --- a/modules/document/queries/updateCommentCount.xml +++ b/modules/document/queries/updateCommentCount.xml @@ -5,7 +5,7 @@ - +