mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
#1055 게시물 이동 시 첨부파일의 수를 갱신하는 동작을 간소화 하도록 개선
This commit is contained in:
parent
228f4aa9bc
commit
21961fb3e9
4 changed files with 32 additions and 19 deletions
|
|
@ -95,6 +95,7 @@ class documentAdminController extends document
|
||||||
$oFileController = getController('file');
|
$oFileController = getController('file');
|
||||||
|
|
||||||
$files = $oDocument->getUploadedFiles();
|
$files = $oDocument->getUploadedFiles();
|
||||||
|
$delete_file_srls = array();
|
||||||
if(is_array($files))
|
if(is_array($files))
|
||||||
{
|
{
|
||||||
foreach($files as $val)
|
foreach($files as $val)
|
||||||
|
|
@ -119,9 +120,10 @@ class documentAdminController extends document
|
||||||
$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
|
$obj->content = str_replace('sid='.$val->sid, 'sid='.$inserted_file->get('sid'), $obj->content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Delete an existing file
|
$delete_file_srls[] = $val->file_srl;
|
||||||
$oFileController->deleteFile($val->file_srl);
|
|
||||||
}
|
}
|
||||||
|
// Delete an existing file
|
||||||
|
$oFileController->deleteFile($delete_file_srls);
|
||||||
}
|
}
|
||||||
// Set the all files to be valid
|
// Set the all files to be valid
|
||||||
$oFileController->setFilesValid($obj->document_srl);
|
$oFileController->setFilesValid($obj->document_srl);
|
||||||
|
|
|
||||||
|
|
@ -2482,18 +2482,13 @@ class documentController extends document
|
||||||
if(is_array($documentSrlList))
|
if(is_array($documentSrlList))
|
||||||
{
|
{
|
||||||
$documentSrlList = array_unique($documentSrlList);
|
$documentSrlList = array_unique($documentSrlList);
|
||||||
foreach($documentSrlList AS $key=>$documentSrl)
|
foreach($documentSrlList AS $key => $documentSrl)
|
||||||
{
|
{
|
||||||
$oldDocument = $oDocumentModel->getDocument($documentSrl);
|
|
||||||
$fileCount = $oFileModel->getFilesCount($documentSrl);
|
$fileCount = $oFileModel->getFilesCount($documentSrl);
|
||||||
|
$args = new stdClass();
|
||||||
if($oldDocument != null)
|
$args->document_srl = $documentSrl;
|
||||||
{
|
$args->uploaded_count = $fileCount;
|
||||||
$newDocumentArray = $oldDocument->variables;
|
executeQuery('document.updateUploadedCount', $args);
|
||||||
$newDocumentArray['uploaded_count'] = $fileCount;
|
|
||||||
$newDocumentObject = (object) $newDocumentArray;
|
|
||||||
$this->updateDocument($oldDocument, $newDocumentObject);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
11
modules/document/queries/updateUploadedCount.xml
Normal file
11
modules/document/queries/updateUploadedCount.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
<query id="updateUploadedCount" action="update">
|
||||||
|
<tables>
|
||||||
|
<table name="documents" />
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="uploaded_count" var="uploaded_count" default="0" filter="number" />
|
||||||
|
</columns>
|
||||||
|
<conditions>
|
||||||
|
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||||
|
</conditions>
|
||||||
|
</query>
|
||||||
|
|
@ -777,25 +777,30 @@ class fileController extends file
|
||||||
{
|
{
|
||||||
if(!$file_srl) return;
|
if(!$file_srl) return;
|
||||||
|
|
||||||
$srls = explode(',',$file_srl);
|
$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
|
||||||
if(!count($srls)) return;
|
if(!count($srls)) return;
|
||||||
|
|
||||||
$oDocumentController = getController('document');
|
$oDocumentController = getController('document');
|
||||||
$documentSrlList = array();
|
$documentSrlList = array();
|
||||||
|
|
||||||
for($i=0, $c=count($srls); $i<$c; $i++)
|
foreach($srls as $srl)
|
||||||
{
|
{
|
||||||
$srl = (int)$srls[$i];
|
$srl = (int)$srl;
|
||||||
if(!$srl) continue;
|
if(!$srl)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$args = new stdClass;
|
$args = new stdClass();
|
||||||
$args->file_srl = $srl;
|
$args->file_srl = $srl;
|
||||||
$output = executeQuery('file.getFile', $args);
|
$output = executeQuery('file.getFile', $args);
|
||||||
|
|
||||||
if(!$output->toBool()) continue;
|
if(!$output->toBool() || !$output->data)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
$file_info = $output->data;
|
$file_info = $output->data;
|
||||||
if(!$file_info) continue;
|
|
||||||
|
|
||||||
if($file_info->upload_target_srl)
|
if($file_info->upload_target_srl)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue