게시글과 댓글을 작성 및 수정시 대기된 파일을 공개하는 방식을 변경

파일이 대기모드에서 공개할때 트리거에서 직접 호출 하는 방식으로 변경
This commit is contained in:
BJRambo 2020-11-11 15:06:00 +09:00
parent 234ad09867
commit 2cb477fd55
4 changed files with 44 additions and 100 deletions

View file

@ -394,6 +394,8 @@ class commentController extends comment
$obj->module_srl = intval($obj->module_srl);
$obj->document_srl = intval($obj->document_srl);
$obj->parent_srl = intval($obj->parent_srl);
$obj->uploaded_count = FileModel::getFilesCount($obj->comment_srl);
// call a trigger (before)
$output = ModuleHandler::triggerCall('comment.insertComment', 'before', $obj);
@ -596,6 +598,16 @@ class commentController extends comment
$output = $oDocumentController->updateCommentCount($document_srl, $comment_count, $obj->nick_name, $update_document);
}
if($obj->uploaded_count)
{
$attachOutput = getController('file')->setFilesValid($obj->comment_srl, 'com');
if(!$attachOutput->toBool())
{
$oDB->rollback();
return $attachOutput;
}
}
// call a trigger(after)
ModuleHandler::triggerCall('comment.insertComment', 'after', $obj);
@ -754,6 +766,8 @@ class commentController extends comment
$obj->module_srl = intval($obj->module_srl);
$obj->document_srl = intval($obj->document_srl);
$obj->parent_srl = intval($obj->parent_srl);
$obj->uploaded_count = FileModel::getFilesCount($obj->comment_srl);
// call a trigger (before)
$output = ModuleHandler::triggerCall('comment.updateComment', 'before', $obj);
@ -855,6 +869,16 @@ class commentController extends comment
return $output;
}
if($obj->uploaded_count)
{
$attachOutput = getController('file')->setFilesValid($obj->comment_srl, 'com');
if(!$attachOutput->toBool())
{
$oDB->rollback();
return $attachOutput;
}
}
// call a trigger (after)
ModuleHandler::triggerCall('comment.updateComment', 'after', $obj);

View file

@ -500,6 +500,8 @@ class documentController extends document
// Remove manual member info to prevent forgery. This variable can be set by triggers only.
unset($obj->manual_member_info);
$obj->uploaded_count = FileModel::getFilesCount($obj->document_srl);
// Call a trigger (before)
$output = ModuleHandler::triggerCall('document.insertDocument', 'before', $obj);
if(!$output->toBool())
@ -647,6 +649,14 @@ class documentController extends document
return $update_output;
}
}
$attachOutput = getController('file')->setFilesValid($obj->document_srl, 'doc');
if(!$attachOutput->toBool())
{
$oDB->rollback();
return $attachOutput;
}
ModuleHandler::triggerCall('document.insertDocument', 'after', $obj);
// commit
@ -708,6 +718,8 @@ class documentController extends document
// Remove manual member info to prevent forgery. This variable can be set by triggers only.
unset($obj->manual_member_info);
$obj->uploaded_count = FileModel::getFilesCount($obj->document_srl);
// Call a trigger (before)
$output = ModuleHandler::triggerCall('document.updateDocument', 'before', $obj);
@ -947,6 +959,14 @@ class documentController extends document
return $update_output;
}
}
$attachOutput = getController('file')->setFilesValid($obj->document_srl, 'doc');
if(!$attachOutput->toBool())
{
$oDB->rollback();
return $attachOutput;
}
ModuleHandler::triggerCall('document.updateDocument', 'after', $obj);
// commit

View file

@ -21,15 +21,7 @@ class file extends ModuleObject
FileHandler::makeDir('./files/attach/binaries');
// 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
$oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
$oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
$oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
$oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
$oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after');
$oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
$oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
$oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
$oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
$oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after');
// 2009. 6. 9 Delete all the attachements when auto-saved document is deleted
$oModuleController->insertTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after');
@ -49,15 +41,7 @@ class file extends ModuleObject
$oDB = &DB::getInstance();
$oModuleModel = getModel('module');
// 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before')) return true;
if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after')) return true;
if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before')) return true;
if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after')) return true;
if(!$oModuleModel->getTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after')) return true;
if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before')) return true;
if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after')) return true;
if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before')) return true;
if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after')) return true;
if(!$oModuleModel->getTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after')) return true;
// 2009. 6. 9 Delete all the attachements when auto-saved document is deleted
if(!$oModuleModel->getTrigger('editor.deleteSavedDoc', 'file', 'controller', 'triggerDeleteAttached', 'after')) return true;
@ -131,33 +115,9 @@ class file extends ModuleObject
$oModuleModel = getModel('module');
$oModuleController = getController('module');
// 2007. 10. 17 Create a trigger to insert, update, delete documents and comments
if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before'))
$oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
if(!$oModuleModel->getTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after'))
$oModuleController->insertTrigger('document.insertDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before'))
$oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerCheckAttached', 'before');
if(!$oModuleModel->getTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after'))
$oModuleController->insertTrigger('document.updateDocument', 'file', 'controller', 'triggerAttachFiles', 'after');
if(!$oModuleModel->getTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after'))
$oModuleController->insertTrigger('document.deleteDocument', 'file', 'controller', 'triggerDeleteAttached', 'after');
if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before'))
$oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
if(!$oModuleModel->getTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after'))
$oModuleController->insertTrigger('comment.insertComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before'))
$oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentCheckAttached', 'before');
if(!$oModuleModel->getTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after'))
$oModuleController->insertTrigger('comment.updateComment', 'file', 'controller', 'triggerCommentAttachFiles', 'after');
if(!$oModuleModel->getTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after'))
$oModuleController->insertTrigger('comment.deleteComment', 'file', 'controller', 'triggerCommentDeleteAttached', 'after');
// 2009. 6. 9 Delete all the attachements when auto-saved document is deleted

View file

@ -633,36 +633,6 @@ class fileController extends file
$this->add('file_size_total', $fileSizeTotal);
$this->add('file_size_total_human', FileHandler::filesize($fileSizeTotal));
}
/**
* A trigger to return numbers of attachments in the upload_target_srl (document_srl)
*
* @param object $obj Trigger object
* @return Object
*/
function triggerCheckAttached(&$obj)
{
$document_srl = $obj->document_srl;
if(!$document_srl) return;
// Get numbers of attachments
$obj->uploaded_count = FileModel::getFilesCount($document_srl);
// TODO: WTF are we doing with uploaded_count anyway?
}
/**
* A trigger to link the attachment with the upload_target_srl (document_srl)
*
* @param object $obj Trigger object
* @return Object
*/
function triggerAttachFiles(&$obj)
{
$document_srl = $obj->document_srl;
if(!$document_srl) return;
$output = $this->setFilesValid($document_srl, 'doc');
if(!$output->toBool()) return $output;
}
/**
* A trigger to delete the attachment in the upload_target_srl (document_srl)
@ -679,36 +649,6 @@ class fileController extends file
return $output;
}
/**
* A trigger to return numbers of attachments in the upload_target_srl (comment_srl)
*
* @param object $obj Trigger object
* @return Object
*/
function triggerCommentCheckAttached(&$obj)
{
$comment_srl = $obj->comment_srl;
if(!$comment_srl) return;
// Get numbers of attachments
$obj->uploaded_count = FileModel::getFilesCount($comment_srl);
}
/**
* A trigger to link the attachment with the upload_target_srl (comment_srl)
*
* @param object $obj Trigger object
* @return Object
*/
function triggerCommentAttachFiles(&$obj)
{
$comment_srl = $obj->comment_srl;
$uploaded_count = $obj->uploaded_count;
if(!$comment_srl || !$uploaded_count) return;
$output = $this->setFilesValid($comment_srl, 'com');
if(!$output->toBool()) return $output;
}
/**
* A trigger to delete the attachment in the upload_target_srl (comment_srl)
*