diff --git a/modules/comment/comment.controller.php b/modules/comment/comment.controller.php index f57f067f6..3eb2baee8 100644 --- a/modules/comment/comment.controller.php +++ b/modules/comment/comment.controller.php @@ -2001,6 +2001,41 @@ class CommentController extends Comment $this->setMessage('success_declared_cancel'); } + /** + * Update the number of uploaded files in the comment + * + * @param int|array $comment_srl_list + * @return void + */ + public function updateUploadedCount($comment_srl_list) + { + if (!is_array($comment_srl_list)) + { + $comment_srl_list = array($comment_srl_list); + } + + if (!count($comment_srl_list)) + { + return; + } + + $comment_srl_list = array_unique($comment_srl_list); + + foreach($comment_srl_list as $comment_srl) + { + $comment_srl = (int)$comment_srl; + if ($comment_srl <= 0) + { + continue; + } + + $args = new stdClass; + $args->comment_srl = $comment_srl; + $args->uploaded_count = FileModel::getFilesCount($comment_srl); + executeQuery('comment.updateUploadedCount', $args); + } + } + /** * Method to add a pop-up menu when clicking for displaying child comments * @param string $url diff --git a/modules/comment/queries/updateUploadedCount.xml b/modules/comment/queries/updateUploadedCount.xml new file mode 100644 index 000000000..9a9bfab15 --- /dev/null +++ b/modules/comment/queries/updateUploadedCount.xml @@ -0,0 +1,11 @@ + + + + + + + + + + + diff --git a/modules/document/document.controller.php b/modules/document/document.controller.php index 418857e29..4c281b0d4 100644 --- a/modules/document/document.controller.php +++ b/modules/document/document.controller.php @@ -3788,7 +3788,17 @@ Content; } } + /** + * A typo of updateUploadedCount, maintained for backward compatibility. + * + * @deprecated + */ public function updateUploaedCount($document_srl_list) + { + return $this->updateUploadedCount($document_srl_list); + } + + public function updateUploadedCount($document_srl_list) { if(!is_array($document_srl_list)) { @@ -3804,7 +3814,8 @@ Content; foreach($document_srl_list as $document_srl) { - if(!$document_srl = (int) $document_srl) + $document_srl = (int)$document_srl; + if ($document_srl <= 0) { continue; } @@ -3824,7 +3835,7 @@ Content; return; } - $this->updateUploaedCount($file->upload_target_srl); + $this->updateUploadedCount($file->upload_target_srl); } /** diff --git a/modules/file/file.controller.php b/modules/file/file.controller.php index c46e633c1..c9ae4e628 100644 --- a/modules/file/file.controller.php +++ b/modules/file/file.controller.php @@ -2002,6 +2002,8 @@ class FileController extends File } $this->copyFiles($obj->source->document_srl, $obj->copied->module_srl, $obj->copied->document_srl, $obj->copied->content); + $this->setFilesValid($obj->copied->document_srl, 'doc'); + DocumentController::getInstance()->updateUploadedCount($obj->copied->document_srl); } function triggerAddCopyCommentByDocument(&$obj) @@ -2012,6 +2014,8 @@ class FileController extends File } $this->copyFiles($obj->source->comment_srl, $obj->copied->module_srl, $obj->copied->comment_srl, $obj->copied->content); + $this->setFilesValid($obj->copied->comment_srl, 'com'); + CommentController::getInstance()->updateUploadedCount($obj->copied->comment_srl); } function triggerCopyModule(&$obj)