mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-28 06:42:14 +09:00
문서 이동 / 첨부 파일 삭제 기능 개선
This commit is contained in:
parent
b180270e08
commit
3d2ade4aa1
14 changed files with 253 additions and 234 deletions
|
|
@ -15,42 +15,12 @@ class fileAdminController extends file
|
|||
}
|
||||
|
||||
/**
|
||||
* Delete the attachment of a particular module
|
||||
*
|
||||
* @param int $module_srl Sequence of module to delete files
|
||||
* @deprecated move to fileController
|
||||
* @return Object
|
||||
*/
|
||||
function deleteModuleFiles($module_srl)
|
||||
{
|
||||
// Get a full list of attachments
|
||||
$args = new stdClass();
|
||||
$args->module_srl = $module_srl;
|
||||
$columnList = array('file_srl', 'uploaded_filename');
|
||||
$output = executeQueryArray('file.getModuleFiles',$args, $columnList);
|
||||
if(!$output) return $output;
|
||||
$files = $output->data;
|
||||
// Remove from the DB
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQuery('file.deleteModuleFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
// Remove the file
|
||||
FileHandler::removeDir( sprintf("./files/attach/images/%s/", $module_srl) ) ;
|
||||
FileHandler::removeDir( sprintf("./files/attach/binaries/%s/", $module_srl) );
|
||||
// Remove the file list obtained from the DB
|
||||
$path = array();
|
||||
$cnt = count($files);
|
||||
for($i=0;$i<$cnt;$i++)
|
||||
{
|
||||
$uploaded_filename = $files[$i]->uploaded_filename;
|
||||
FileHandler::removeFile($uploaded_filename);
|
||||
|
||||
$path_info = pathinfo($uploaded_filename);
|
||||
if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
|
||||
}
|
||||
// Remove a file directory of the document
|
||||
for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]);
|
||||
|
||||
return $output;
|
||||
return getController('file')->deleteModuleFiles($module_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -77,7 +77,12 @@ class file extends ModuleObject
|
|||
if(!$oModuleModel->getTrigger('module.procModuleAdminCopyModule', 'file', 'controller', 'triggerCopyModule', 'after')) return true;
|
||||
|
||||
if(!$oDB->isColumnExists('files', 'cover_image')) return true;
|
||||
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'file', 'controller', 'triggeMoveDocumentModule', 'after'))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -140,6 +145,11 @@ class file extends ModuleObject
|
|||
}
|
||||
|
||||
if(!$oDB->isColumnExists('files', 'cover_image')) $oDB->addColumn('files', 'cover_image', 'char', '1', 'N');
|
||||
|
||||
if(!$oModuleModel->getTrigger('document.moveDocumentModule', 'file', 'controller', 'triggeMoveDocumentModule', 'after'))
|
||||
{
|
||||
$oModuleController->insertTrigger('document.moveDocumentModule', 'file', 'controller', 'triggeMoveDocumentModule', 'after');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -694,9 +694,8 @@ class fileController extends file
|
|||
{
|
||||
$module_srl = $obj->module_srl;
|
||||
if(!$module_srl) return;
|
||||
|
||||
$oFileController = getAdminController('file');
|
||||
return $oFileController->deleteModuleFiles($module_srl);
|
||||
|
||||
return $this->deleteModuleFiles($module_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -950,70 +949,58 @@ class fileController extends file
|
|||
* - ipaddress
|
||||
* </pre>
|
||||
*
|
||||
* @param int $file_srl Sequence of file to delete
|
||||
* @param array|int $file_list or $file_srl
|
||||
* @return Object
|
||||
*/
|
||||
function deleteFile($file_srl)
|
||||
function deleteFile($file_list)
|
||||
{
|
||||
if(!$file_srl) return;
|
||||
|
||||
$srls = (is_array($file_srl)) ? $file_srl : explode(',', $file_srl);
|
||||
if(!count($srls)) return;
|
||||
|
||||
$oDocumentController = getController('document');
|
||||
$documentSrlList = array();
|
||||
|
||||
foreach($srls as $srl)
|
||||
if(!is_array($file_list))
|
||||
{
|
||||
$srl = (int)$srl;
|
||||
if(!$srl)
|
||||
$file_list = explode(',', $file_list);
|
||||
}
|
||||
|
||||
if(empty($file_list))
|
||||
{
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
foreach($file_list as $file)
|
||||
{
|
||||
if(!is_object($file))
|
||||
{
|
||||
if(!$file_srl = (int) $file)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$file = getModel('file')->getFile($file_srl);
|
||||
}
|
||||
|
||||
if(empty($file->file_srl))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
$args->file_srl = $srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
|
||||
if(!$output->toBool() || !$output->data)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$file_info = $output->data;
|
||||
|
||||
if($file_info->upload_target_srl)
|
||||
{
|
||||
$documentSrlList[] = $file_info->upload_target_srl;
|
||||
}
|
||||
|
||||
$source_filename = $output->data->source_filename;
|
||||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
|
||||
|
||||
// Call a trigger (before)
|
||||
$trigger_obj = $output->data;
|
||||
$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $trigger_obj);
|
||||
$output = ModuleHandler::triggerCall('file.deleteFile', 'before', $file);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
|
||||
// Remove from the DB
|
||||
$output = executeQuery('file.deleteFile', $args);
|
||||
$output = executeQuery('file.deleteFile', $file);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
|
||||
// If successfully deleted, remove the file
|
||||
Rhymix\Framework\Storage::delete(FileHandler::getRealPath($uploaded_filename));
|
||||
|
||||
Rhymix\Framework\Storage::delete(FileHandler::getRealPath($file->uploaded_filename));
|
||||
|
||||
// Call a trigger (after)
|
||||
ModuleHandler::triggerCall('file.deleteFile', 'after', $trigger_obj);
|
||||
ModuleHandler::triggerCall('file.deleteFile', 'after', $file);
|
||||
|
||||
// Remove empty directories
|
||||
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($uploaded_filename)), true);
|
||||
Rhymix\Framework\Storage::deleteEmptyDirectory(dirname(FileHandler::getRealPath($file->uploaded_filename)), true);
|
||||
}
|
||||
|
||||
$oDocumentController->updateUploaedCount($documentSrlList);
|
||||
|
||||
return $output;
|
||||
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete all attachments of a particular document
|
||||
*
|
||||
|
|
@ -1024,26 +1011,39 @@ class fileController extends file
|
|||
{
|
||||
// Get a list of attachements
|
||||
$oFileModel = getModel('file');
|
||||
$columnList = array('file_srl', 'uploaded_filename', 'module_srl');
|
||||
$file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
|
||||
$file_list = $oFileModel->getFiles($upload_target_srl);
|
||||
|
||||
// Success returned if no attachement exists
|
||||
if(!is_array($file_list)||!count($file_list)) return new BaseObject();
|
||||
|
||||
// Delete the file
|
||||
foreach ($file_list as $file)
|
||||
if(empty($file_list))
|
||||
{
|
||||
$this->deleteFile($file->file_srl);
|
||||
return new BaseObject();
|
||||
}
|
||||
|
||||
// Remove from the DB
|
||||
$args = new stdClass();
|
||||
$args->upload_target_srl = $upload_target_srl;
|
||||
$output = executeQuery('file.deleteFiles', $args);
|
||||
if(!$output->toBool()) return $output;
|
||||
|
||||
return $output;
|
||||
|
||||
// Delete the file
|
||||
return $this->deleteFile($file_list);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete the attachment of a particular module
|
||||
*
|
||||
* @param int $module_srl Sequence of module to delete files
|
||||
* @return Object
|
||||
*/
|
||||
function deleteModuleFiles($module_srl)
|
||||
{
|
||||
// Get a full list of attachments
|
||||
$args = new stdClass;
|
||||
$args->module_srl = $module_srl;
|
||||
$output = executeQueryArray('file.getModuleFiles', $args);
|
||||
if(!$output->toBool() || empty($file_list = $output->data))
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
// Delete the file
|
||||
return $this->deleteFile($file_list);
|
||||
}
|
||||
|
||||
/**
|
||||
* Move an attachement to the other document
|
||||
*
|
||||
|
|
@ -1161,7 +1161,14 @@ class fileController extends file
|
|||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
function triggeMoveDocumentModule($obj)
|
||||
{
|
||||
$obj->upload_target_srls = $obj->document_srls;
|
||||
executeQuery('file.updateFileModule', $obj);
|
||||
executeQuery('file.updateFileModuleComment', $obj);
|
||||
}
|
||||
|
||||
function triggerCopyModule(&$obj)
|
||||
{
|
||||
$oModuleModel = getModel('module');
|
||||
|
|
|
|||
|
|
@ -6,6 +6,6 @@
|
|||
<column name="module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="upload_target_srl" var="upload_target_srl" filter="number" notnull="notnull" />
|
||||
<condition operation="in" column="upload_target_srl" var="upload_target_srls" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
|
|
|
|||
13
modules/file/queries/updateFileModuleComment.xml
Normal file
13
modules/file/queries/updateFileModuleComment.xml
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<query id="updateFileModuleComment" action="update">
|
||||
<tables>
|
||||
<table name="files" />
|
||||
<table name="comments" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="files.module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="files.upload_target_srl" default="comments.comment_srl" />
|
||||
<condition operation="in" column="comments.document_srl" var="upload_target_srls" filter="number" notnull="notnull" pipe="and" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue