mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
if file delete, update file count in document table
git-svn-id: http://xe-core.googlecode.com/svn/branches/maserati@12610 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
d6ae208275
commit
62fec548c6
2 changed files with 34 additions and 0 deletions
|
|
@ -2237,6 +2237,30 @@ class documentController extends document
|
|||
if(!$obj->status && $obj->is_secret != 'Y') $obj->status = $this->getConfigStatus('public');
|
||||
}
|
||||
|
||||
public function updateUploaedCount($documentSrlList)
|
||||
{
|
||||
$oDocumentModel = &getModel('document');
|
||||
$oFileModel = &getModel('file');
|
||||
|
||||
if(is_array($documentSrlList))
|
||||
{
|
||||
$documentSrlList = array_unique($documentSrlList);
|
||||
foreach($documentSrlList AS $key=>$documentSrl)
|
||||
{
|
||||
$oldDocument = $oDocumentModel->getDocument($documentSrl);
|
||||
$fileCount = $oFileModel->getFilesCount($documentSrl);
|
||||
|
||||
if($oldDocument != null)
|
||||
{
|
||||
$newDocumentArray = $oldDocument->variables;
|
||||
$newDocumentArray['uploaded_count'] = $fileCount;
|
||||
$newDocumentObject = (object) $newDocumentArray;
|
||||
$this->updateDocument($oldDocument, $newDocumentObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy extra keys when module copied
|
||||
* @param object $obj
|
||||
|
|
|
|||
|
|
@ -735,6 +735,8 @@ class fileController extends file
|
|||
$srls = explode(',',$file_srl);
|
||||
if(!count($srls)) return;
|
||||
|
||||
$oDocumentController = &getController('document');
|
||||
$documentSrlList = array();
|
||||
for($i=0;$i<count($srls);$i++)
|
||||
{
|
||||
$srl = (int)$srls[$i];
|
||||
|
|
@ -743,11 +745,17 @@ class fileController extends file
|
|||
$args = null;
|
||||
$args->file_srl = $srl;
|
||||
$output = executeQuery('file.getFile', $args);
|
||||
|
||||
if(!$output->toBool()) continue;
|
||||
|
||||
$file_info = $output->data;
|
||||
if(!$file_info) continue;
|
||||
|
||||
if($file_info->upload_target_srl)
|
||||
{
|
||||
array_push($documentSrlList, $file_info->upload_target_srl);
|
||||
}
|
||||
|
||||
$source_filename = $output->data->source_filename;
|
||||
$uploaded_filename = $output->data->uploaded_filename;
|
||||
// Call a trigger (before)
|
||||
|
|
@ -764,6 +772,8 @@ class fileController extends file
|
|||
FileHandler::removeFile($uploaded_filename);
|
||||
}
|
||||
|
||||
$oDocumentController->updateUploaedCount($documentSrlList);
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue