mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-08 19:42:15 +09:00
#9 댓글 트리거 추가.
- 문서 트리는 이미 있었으나 (아마 테스트를 위해) IP체크 부분이 주석처리 되어있던 코드를 복원 함
This commit is contained in:
parent
757187aabf
commit
a4f550fa5c
2 changed files with 42 additions and 12 deletions
|
|
@ -1134,6 +1134,18 @@ class commentController extends comment
|
||||||
{
|
{
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
|
||||||
|
|
||||||
|
$trigger_obj = new stdClass();
|
||||||
|
$trigger_obj->comment_srl = $comment_srl;
|
||||||
|
$trigger_obj->declared_count = $declared_count;
|
||||||
|
|
||||||
|
// Call a trigger (before)
|
||||||
|
$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'before', $trigger_obj);
|
||||||
|
if(!$trigger_output->toBool())
|
||||||
|
{
|
||||||
|
return $trigger_output;
|
||||||
|
}
|
||||||
|
|
||||||
// get the original comment
|
// get the original comment
|
||||||
$oCommentModel = getModel('comment');
|
$oCommentModel = getModel('comment');
|
||||||
|
|
@ -1180,6 +1192,10 @@ class commentController extends comment
|
||||||
return new Object(-1, 'failed_declared');
|
return new Object(-1, 'failed_declared');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// begin transaction
|
||||||
|
$oDB = &DB::getInstance();
|
||||||
|
$oDB->begin();
|
||||||
|
|
||||||
// execute insert
|
// execute insert
|
||||||
if($output->data->declared_count > 0)
|
if($output->data->declared_count > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -1192,12 +1208,24 @@ class commentController extends comment
|
||||||
|
|
||||||
if(!$output->toBool())
|
if(!$output->toBool())
|
||||||
{
|
{
|
||||||
|
$oDB->rollback();
|
||||||
return $output;
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// leave the log
|
// leave the log
|
||||||
$output = executeQuery('comment.insertCommentDeclaredLog', $args);
|
$output = executeQuery('comment.insertCommentDeclaredLog', $args);
|
||||||
|
|
||||||
|
// Call a trigger (after)
|
||||||
|
$trigger_obj->declared_count = $declared_count + 1;
|
||||||
|
$trigger_output = ModuleHandler::triggerCall('comment.declaredComment', 'after', $trigger_obj);
|
||||||
|
if(!$trigger_output->toBool())
|
||||||
|
{
|
||||||
|
$oDB->rollback();
|
||||||
|
return $trigger_output;
|
||||||
|
}
|
||||||
|
|
||||||
|
$oDB->commit();
|
||||||
|
|
||||||
// leave into the session information
|
// leave into the session information
|
||||||
$_SESSION['declared_comment'][$comment_srl] = TRUE;
|
$_SESSION['declared_comment'][$comment_srl] = TRUE;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1091,8 +1091,17 @@ class documentController extends document
|
||||||
// Fail if session information already has a reported document
|
// Fail if session information already has a reported document
|
||||||
if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
|
if($_SESSION['declared_document'][$document_srl]) return new Object(-1, 'failed_declared');
|
||||||
|
|
||||||
|
// Check if previously reported
|
||||||
|
$args = new stdClass();
|
||||||
|
$args->document_srl = $document_srl;
|
||||||
|
$output = executeQuery('document.getDeclaredDocument', $args);
|
||||||
|
if(!$output->toBool()) return $output;
|
||||||
|
|
||||||
|
$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
|
||||||
|
|
||||||
$trigger_obj = new stdClass();
|
$trigger_obj = new stdClass();
|
||||||
$trigger_obj->document_srl = $document_srl;
|
$trigger_obj->document_srl = $document_srl;
|
||||||
|
$trigger_obj->declared_count = $declared_count;
|
||||||
|
|
||||||
// Call a trigger (before)
|
// Call a trigger (before)
|
||||||
$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj);
|
$trigger_output = ModuleHandler::triggerCall('document.declaredDocument', 'before', $trigger_obj);
|
||||||
|
|
@ -1101,23 +1110,15 @@ class documentController extends document
|
||||||
return $trigger_output;
|
return $trigger_output;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if previously reported
|
|
||||||
$args = new stdClass();
|
|
||||||
$args->document_srl = $document_srl;
|
|
||||||
$output = executeQuery('document.getDeclaredDocument', $args);
|
|
||||||
if(!$output->toBool()) return $output;
|
|
||||||
|
|
||||||
$declared_count = $output->data->declared_count;
|
|
||||||
|
|
||||||
// Get the original document
|
// Get the original document
|
||||||
$oDocumentModel = &getModel('document');
|
$oDocumentModel = &getModel('document');
|
||||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
||||||
|
|
||||||
// Pass if the author's IP address is as same as visitor's.
|
// Pass if the author's IP address is as same as visitor's.
|
||||||
/*if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
|
if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR']) {
|
||||||
$_SESSION['declared_document'][$document_srl] = true;
|
$_SESSION['declared_document'][$document_srl] = true;
|
||||||
return new Object(-1, 'failed_declared');
|
return new Object(-1, 'failed_declared');
|
||||||
}*/
|
}
|
||||||
|
|
||||||
// Check if document's author is a member.
|
// Check if document's author is a member.
|
||||||
if($oDocument->get('member_srl'))
|
if($oDocument->get('member_srl'))
|
||||||
|
|
@ -1142,6 +1143,7 @@ class documentController extends document
|
||||||
{
|
{
|
||||||
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$args->document_srl = $document_srl;
|
$args->document_srl = $document_srl;
|
||||||
$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
|
$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue