diff --git a/modules/document/conf/module.xml b/modules/document/conf/module.xml
index b6e6105d2..dc576e769 100644
--- a/modules/document/conf/module.xml
+++ b/modules/document/conf/module.xml
@@ -49,6 +49,7 @@
+
diff --git a/modules/document/document.admin.controller.php b/modules/document/document.admin.controller.php
index a38e3a00c..58312f283 100644
--- a/modules/document/document.admin.controller.php
+++ b/modules/document/document.admin.controller.php
@@ -731,6 +731,44 @@ class DocumentAdminController extends Document
$output = $oDocumentController->deleteDocument($oDocument->get('document_srl'), true, true, $oDocument);
return $output;
}
+
+ /**
+ * Recalculate category document counts
+ */
+ public function procDocumentAdminRecalculateCategoryCounts()
+ {
+ // Get the document count for each category.
+ $oDB = DB::getInstance();
+ $output = executeQueryArray('document.getCategoryDocumentCounts', []);
+ $module_srl_list = [];
+
+ // Update the document count of each category.
+ $oDB->beginTransaction();
+ foreach ($output->data ?: [] as $row)
+ {
+ $module_srl_list[$row->module_srl] = true;
+ $output = executeQuery('document.updateCategoryCount', [
+ 'category_srl' => $row->category_srl,
+ 'document_count' => $row->count,
+ ]);
+ if (!$output->toBool())
+ {
+ $oDB->rollback();
+ return $output;
+ }
+ }
+ $oDB->commit();
+
+ // Refresh category cache files for affected modules.
+ $oDocumentController = DocumentController::getInstance();
+ foreach ($module_srl_list as $module_srl => $unused)
+ {
+ $oDocumentController->makeCategoryFile($module_srl);
+ }
+
+ $this->setError(-1);
+ $this->setMessage('success_updated');
+ }
}
/* End of file document.admin.controller.php */
/* Location: ./modules/document/document.admin.controller.php */
diff --git a/modules/document/lang/en.php b/modules/document/lang/en.php
index 281cfba03..4b607bd22 100644
--- a/modules/document/lang/en.php
+++ b/modules/document/lang/en.php
@@ -134,3 +134,6 @@ $lang->allow_declare_from_same_ip = 'Allow reporting from same IP';
$lang->allow_declare_cancel = 'Allow report cancellation';
$lang->cmd_search_division = 'Search division';
$lang->about_search_division = 'Divide search results into sections in order to reduce time and server load. Setting this value to 0 will disable divisions entirely. Disabling divisions or using large values may cause serious problems such as timeouts or server overload. Values between 5000 and 10000 are recommended.';
+$lang->cmd_recalculate_category_counts = 'Recalculate per-category document counts';
+$lang->about_recalculate_category_counts = 'If per-category document counts are displayed incorrectly after batch move or deletion, click the button above to refresh the statistics. This may take a long time if you have a large number of posts.';
+$lang->prevent_redeclare = 'Prevent the same user from reporting this post again.';
diff --git a/modules/document/lang/ko.php b/modules/document/lang/ko.php
index 1253281a2..ff141bcba 100644
--- a/modules/document/lang/ko.php
+++ b/modules/document/lang/ko.php
@@ -126,4 +126,6 @@ $lang->allow_declare_from_same_ip = '동일 IP 신고 허용';
$lang->allow_declare_cancel = '신고 취소 허용';
$lang->cmd_search_division = '검색 결과 분할';
$lang->about_search_division = '검색 소요시간과 서버 부하를 줄이기 위해 일정 갯수만큼 끊어서 검색합니다. 0으로 설정할 경우 분할하지 않습니다. 분할하지 않거나 지나치게 많은 게시물을 한 번에 검색하려고 하면 타임아웃, 서버 다운 등 심각한 부작용이 발생할 수 있으므로 5000~10000 내외를 권장합니다.';
+$lang->cmd_recalculate_category_counts = '분류별 문서 수 다시 계산';
+$lang->about_recalculate_category_counts = '게시물 일괄 이동 등으로 각 분류별 문서 수가 정확하게 표시되지 않는 경우, 위의 버튼을 클릭하여 갱신할 수 있습니다. 문서가 많은 사이트라면 오랜 시간이 걸릴 수 있으니 주의하시기 바랍니다.';
$lang->prevent_redeclare = '같은 사용자가 이 게시물을 다시 신고하는 것을 방지합니다.';
diff --git a/modules/document/queries/getCategoryDocumentCounts.xml b/modules/document/queries/getCategoryDocumentCounts.xml
new file mode 100644
index 000000000..d3639bdfc
--- /dev/null
+++ b/modules/document/queries/getCategoryDocumentCounts.xml
@@ -0,0 +1,17 @@
+
+
+