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

This commit is contained in:
akasima 2014-08-22 15:33:36 +09:00
parent f9ac4de9cc
commit ec71794b5c

View file

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