mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-04 17:21:39 +09:00
Fix #2221 add document.publishDocument (before/after) triggers that cover both insert and update
This commit is contained in:
parent
9f460b4b96
commit
ca4e2d60e3
1 changed files with 34 additions and 0 deletions
|
|
@ -641,6 +641,9 @@ class DocumentController extends Document
|
|||
$this->_checkDocumentStatusForOldVersion($obj);
|
||||
}
|
||||
|
||||
// Check publish status
|
||||
$is_publish = $obj->status !== 'TEMP';
|
||||
|
||||
// can modify regdate only manager
|
||||
$grant = Context::get('grant');
|
||||
if(!$grant->manager)
|
||||
|
|
@ -692,6 +695,16 @@ class DocumentController extends Document
|
|||
return $output;
|
||||
}
|
||||
|
||||
// Call publish trigger (before)
|
||||
if ($is_publish)
|
||||
{
|
||||
$output = ModuleHandler::triggerCall('document.publishDocument', 'before', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
// Register it if no given document_srl exists
|
||||
if(!$obj->document_srl)
|
||||
{
|
||||
|
|
@ -844,6 +857,10 @@ class DocumentController extends Document
|
|||
|
||||
$obj->updated_file_count = $attachOutput->get('updated_file_count');
|
||||
ModuleHandler::triggerCall('document.insertDocument', 'after', $obj);
|
||||
if ($is_publish)
|
||||
{
|
||||
ModuleHandler::triggerCall('document.publishDocument', 'after', $obj);
|
||||
}
|
||||
|
||||
// commit
|
||||
$oDB->commit();
|
||||
|
|
@ -902,6 +919,9 @@ class DocumentController extends Document
|
|||
$this->_checkDocumentStatusForOldVersion($obj);
|
||||
}
|
||||
|
||||
// Check publish status (update from TEMP to non-TEMP)
|
||||
$is_publish = ($obj->status !== 'TEMP' && $source_obj->get('status') === 'TEMP');
|
||||
|
||||
// Preserve original author info.
|
||||
if ($source_obj->get('member_srl'))
|
||||
{
|
||||
|
|
@ -938,6 +958,16 @@ class DocumentController extends Document
|
|||
return $output;
|
||||
}
|
||||
|
||||
// Call publish trigger (before)
|
||||
if ($is_publish)
|
||||
{
|
||||
$output = ModuleHandler::triggerCall('document.publishDocument', 'before', $obj);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
if(!$obj->module_srl) $obj->module_srl = $source_obj->get('module_srl');
|
||||
|
||||
$document_config = ModuleModel::getModulePartConfig('document', $obj->module_srl);
|
||||
|
|
@ -1186,6 +1216,10 @@ class DocumentController extends Document
|
|||
|
||||
// Call a trigger (after)
|
||||
ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
|
||||
if ($is_publish)
|
||||
{
|
||||
ModuleHandler::triggerCall('document.publishDocument', 'after', $obj);
|
||||
}
|
||||
|
||||
// commit
|
||||
$oDB->commit();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue