#18 if deleteFiles() method called then run 'file.delete' trigger

This commit is contained in:
akasima 2014-08-22 15:33:36 +09:00 committed by bnu
parent 97e33898f2
commit 93297dfc52

View file

@ -764,7 +764,7 @@ class fileController extends file
$oDocumentController = getController('document'); $oDocumentController = getController('document');
$documentSrlList = array(); $documentSrlList = array();
for($i=0;$i<count($srls);$i++) for($i=0, $c=count($srls); $i<$c; $i++)
{ {
$srl = (int)$srls[$i]; $srl = (int)$srls[$i];
if(!$srl) continue; if(!$srl) continue;
@ -818,29 +818,33 @@ class fileController extends file
{ {
// Get a list of attachements // Get a list of attachements
$oFileModel = getModel('file'); $oFileModel = getModel('file');
$columnList = array('uploaded_filename', 'module_srl'); $columnList = array('file_srl', 'uploaded_filename', 'module_srl');
$file_list = $oFileModel->getFiles($upload_target_srl, $columnList); $file_list = $oFileModel->getFiles($upload_target_srl, $columnList);
// Success returned if no attachement exists // Success returned if no attachement exists
if(!is_array($file_list)||!count($file_list)) return new Object(); if(!is_array($file_list)||!count($file_list)) return new Object();
// Remove from the DB // Remove from the DB
$args = new stdClass(); $args = new stdClass();
$args->upload_target_srl = $upload_target_srl; $args->upload_target_srl = $upload_target_srl;
$output = executeQuery('file.deleteFiles', $args); $output = executeQuery('file.deleteFiles', $args);
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
// Delete the file // Delete the file
$path = array(); $path = array();
$file_count = count($file_list); $file_count = count($file_list);
for($i=0;$i<$file_count;$i++) for($i=0;$i<$file_count;$i++)
{ {
$uploaded_filename = $file_list[$i]->uploaded_filename; $this->deleteFile($file_list[$i]->file_srl);
FileHandler::removeFile($uploaded_filename);
$module_srl = $file_list[$i]->module_srl;
$uploaded_filename = $file_list[$i]->uploaded_filename;
$path_info = pathinfo($uploaded_filename); $path_info = pathinfo($uploaded_filename);
if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname']; if(!in_array($path_info['dirname'], $path)) $path[] = $path_info['dirname'];
} }
// Remove a file directory of the document // Remove a file directory of the document
for($i=0;$i<count($path);$i++) FileHandler::removeBlankDir($path[$i]); for($i=0, $c=count($path); $i<$c; $i++)
{
FileHandler::removeBlankDir($path[$i]);
}
return $output; return $output;
} }