Fill upload_target_type as soon as parent document/comment/module is saved

This commit is contained in:
Kijin Sung 2019-11-22 17:37:52 +09:00
parent 12f047b822
commit 1c07b2e0d2
3 changed files with 9 additions and 4 deletions

View file

@ -651,7 +651,7 @@ class fileController extends file
$document_srl = $obj->document_srl; $document_srl = $obj->document_srl;
if(!$document_srl) return; if(!$document_srl) return;
$output = $this->setFilesValid($document_srl); $output = $this->setFilesValid($document_srl, 'doc');
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
} }
@ -697,7 +697,7 @@ class fileController extends file
$uploaded_count = $obj->uploaded_count; $uploaded_count = $obj->uploaded_count;
if(!$comment_srl || !$uploaded_count) return; if(!$comment_srl || !$uploaded_count) return;
$output = $this->setFilesValid($comment_srl); $output = $this->setFilesValid($comment_srl, 'com');
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
} }
@ -770,10 +770,14 @@ class fileController extends file
* @param int $upload_target_srl * @param int $upload_target_srl
* @return Object * @return Object
*/ */
function setFilesValid($upload_target_srl) function setFilesValid($upload_target_srl, $upload_target_type = null)
{ {
$args = new stdClass(); $args = new stdClass();
$args->upload_target_srl = $upload_target_srl; $args->upload_target_srl = $upload_target_srl;
if($upload_target_type)
{
$args->upload_target_type = substr($upload_target_type, 0, 3);
}
return executeQuery('file.updateFileValid', $args); return executeQuery('file.updateFileValid', $args);
} }

View file

@ -3,6 +3,7 @@
<table name="files" /> <table name="files" />
</tables> </tables>
<columns> <columns>
<column name="upload_target_type" var="upload_target_type" />
<column name="isvalid" var="isvalid" default="Y" notnull="notnull" /> <column name="isvalid" var="isvalid" default="Y" notnull="notnull" />
</columns> </columns>
<conditions> <conditions>

View file

@ -173,7 +173,7 @@ class pageAdminController extends page
if(!$output->toBool()) return $output; if(!$output->toBool()) return $output;
// On the page, change the validity status of the attached file // On the page, change the validity status of the attached file
$oFileController = getController('file'); $oFileController = getController('file');
$oFileController->setFilesValid($module_info->module_srl); $oFileController->setFilesValid($module_info->module_srl, 'mod');
$this->add("module_srl", $module_info->module_srl); $this->add("module_srl", $module_info->module_srl);
$this->add("page", Context::get('page')); $this->add("page", Context::get('page'));