diff --git a/modules/editor/editor.model.php b/modules/editor/editor.model.php
index 989eaf037..aba1ed1a6 100644
--- a/modules/editor/editor.model.php
+++ b/modules/editor/editor.model.php
@@ -262,7 +262,7 @@ class EditorModel extends Editor
$file_config->allowed_chunk_size = 0;
}
- Context::set('file_config',$file_config);
+ Context::set('file_config', $file_config);
// Configure upload status such as file size
$upload_status = FileModel::getUploadStatus();
@@ -293,7 +293,7 @@ class EditorModel extends Editor
// Check if the file already exists
if ($upload_target_srl)
{
- $files_count = FileModel::getFilesCount($upload_target_srl);
+ $files_count = FileModel::getFilesCount($upload_target_srl, $option->upload_target_type ?? null);
}
}
Context::set('files_count', (int)$files_count);
diff --git a/modules/file/file.model.php b/modules/file/file.model.php
index 4781038d0..fc725a412 100644
--- a/modules/file/file.model.php
+++ b/modules/file/file.model.php
@@ -81,7 +81,9 @@ class FileModel extends File
}
// Set file list
- foreach(self::getFiles($upload_target_srl) as $file_info)
+ $filter_type = $_SESSION['upload_info'][$editor_sequence]->upload_target_type ?? null;
+ $files = self::getFiles($upload_target_srl, [], 'file_srl', false, $filter_type);
+ foreach ($files as $file_info)
{
$obj = new stdClass;
$obj->file_srl = $file_info->file_srl;
@@ -288,12 +290,17 @@ class FileModel extends File
* Return number of attachments which belongs to a specific document
*
* @param int $upload_target_srl The sequence to get a number of files
+ * @param ?string $upload_target_type
* @return int Returns a number of files
*/
- public static function getFilesCount($upload_target_srl)
+ public static function getFilesCount($upload_target_srl, $upload_target_type = null)
{
$args = new stdClass();
$args->upload_target_srl = $upload_target_srl;
+ if ($upload_target_type)
+ {
+ $args->upload_target_type = $upload_target_type;
+ }
$output = executeQuery('file.getFilesCount', $args);
return (int)$output->data->count;
}
@@ -430,12 +437,20 @@ class FileModel extends File
* @param string $sortIndex The column that used as sort index
* @return array Returns array of object that contains file information. If no result returns null.
*/
- public static function getFiles($upload_target_srl, $columnList = array(), $sortIndex = 'file_srl', $ckValid = false)
+ public static function getFiles($upload_target_srl, $columnList = array(), $sortIndex = 'file_srl', $valid_files_only = false, $upload_target_type = null)
{
$args = new stdClass();
$args->upload_target_srl = $upload_target_srl;
$args->sort_index = $sortIndex;
- if($ckValid) $args->isvalid = 'Y';
+ if ($valid_files_only)
+ {
+ $args->isvalid = 'Y';
+ }
+ if ($upload_target_type)
+ {
+ $args->upload_target_type = $upload_target_type;
+ }
+
$output = executeQueryArray('file.getFiles', $args, $columnList);
if(!$output->data)
{
diff --git a/modules/file/queries/getFiles.xml b/modules/file/queries/getFiles.xml
index d0e326fb3..a5b0877b4 100644
--- a/modules/file/queries/getFiles.xml
+++ b/modules/file/queries/getFiles.xml
@@ -4,6 +4,7 @@
+
diff --git a/modules/file/queries/getFilesCount.xml b/modules/file/queries/getFilesCount.xml
index 81a257cd1..df0f7b6a8 100644
--- a/modules/file/queries/getFilesCount.xml
+++ b/modules/file/queries/getFilesCount.xml
@@ -7,6 +7,7 @@
+