mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-09 12:02:24 +09:00
Prevent files from being deleted upon module deletion if they belong to documents or comments that have since been moved to a different module
This commit is contained in:
parent
b213fc1968
commit
beec50f217
2 changed files with 39 additions and 4 deletions
|
|
@ -1723,14 +1723,18 @@ class FileController extends File
|
||||||
// Get a full list of attachments
|
// Get a full list of attachments
|
||||||
$args = new stdClass;
|
$args = new stdClass;
|
||||||
$args->module_srl = $module_srl;
|
$args->module_srl = $module_srl;
|
||||||
$output = executeQueryArray('file.getModuleFiles', $args);
|
$output = executeQueryArray('file.getModuleFilesProper', $args);
|
||||||
if(!$output->toBool() || empty($file_list = $output->data))
|
if (!$output->toBool())
|
||||||
{
|
{
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
if (!$output->data)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Delete the file
|
// Delete each file.
|
||||||
return $this->deleteFile($file_list);
|
return $this->deleteFile($output->data);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
31
modules/file/queries/getModuleFilesProper.xml
Normal file
31
modules/file/queries/getModuleFilesProper.xml
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
<query id="getModuleFilesProper" action="select">
|
||||||
|
<tables>
|
||||||
|
<table name="files" />
|
||||||
|
<table name="documents" type="left join">
|
||||||
|
<conditions>
|
||||||
|
<condition operation="equal" column="files.upload_target_srl" default="documents.document_srl" />
|
||||||
|
</conditions>
|
||||||
|
</table>
|
||||||
|
<table name="comments" type="left join">
|
||||||
|
<conditions>
|
||||||
|
<condition operation="equal" column="files.upload_target_srl" default="comments.comment_srl" />
|
||||||
|
</conditions>
|
||||||
|
</table>
|
||||||
|
</tables>
|
||||||
|
<columns>
|
||||||
|
<column name="files.*" />
|
||||||
|
<column name="documents.module_srl" alias="d_module_srl" />
|
||||||
|
<column name="comments.module_srl" alias="c_module_srl" />
|
||||||
|
</columns>
|
||||||
|
<conditions>
|
||||||
|
<condition operation="equal" column="files.module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||||
|
<group pipe="and">
|
||||||
|
<condition operation="equal" column="documents.module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||||
|
<condition operation="null" column="documents.module_srl" pipe="or" />
|
||||||
|
</group>
|
||||||
|
<group pipe="and">
|
||||||
|
<condition operation="equal" column="comments.module_srl" var="module_srl" filter="number" notnull="notnull" />
|
||||||
|
<condition operation="null" column="comments.module_srl" pipe="or" />
|
||||||
|
</group>
|
||||||
|
</conditions>
|
||||||
|
</query>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue