mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
트리거를 사용하여 포인트를 회수할 수 있도록 개선.
This commit is contained in:
parent
4a0efef53e
commit
d641e2cc0e
3 changed files with 63 additions and 17 deletions
|
|
@ -57,18 +57,8 @@ class documentController extends document
|
|||
{
|
||||
return new Object(-1, 'msg_document_voted_cancel_not');
|
||||
}
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
$args = new stdClass();
|
||||
$d_args = new stdClass();
|
||||
$args->document_srl = $d_args->document_srl = $document_srl;
|
||||
$d_args->member_srl = $logged_info->member_srl;
|
||||
$args->voted_count = $oDocument->get('voted_count') - 1;
|
||||
$output = executeQuery('document.updateVotedCount', $args);
|
||||
$d_output = executeQuery('document.deleteDocumentVotedLog', $d_args);
|
||||
|
||||
//session reset
|
||||
$_SESSION['voted_document'][$document_srl] = false;
|
||||
$point = 1;
|
||||
$output = $this->updateVotedCountCancel($document_srl, $oDocument, $point);
|
||||
|
||||
$output = new Object();
|
||||
$output->setMessage('success_voted_canceled');
|
||||
|
|
@ -133,21 +123,62 @@ class documentController extends document
|
|||
{
|
||||
return new Object(-1, 'msg_document_voted_cancel_not');
|
||||
}
|
||||
$point = -1;
|
||||
$output = $this->updateVotedCountCancel($document_srl, $oDocument, $point);
|
||||
|
||||
$output = new Object();
|
||||
$output->setMessage('success_blamed_canceled');
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update Document Voted Cancel
|
||||
* @param stdClass $args
|
||||
* @param stdClass $d_args
|
||||
* @param int $point
|
||||
* @return object
|
||||
*/
|
||||
function updateVotedCountCancel($document_srl, $oDocument, $point)
|
||||
{
|
||||
$logged_info = Context::get('logged_info');
|
||||
|
||||
$args = new stdClass();
|
||||
$d_args = new stdClass();
|
||||
$args->document_srl = $d_args->document_srl = $document_srl;
|
||||
$d_args->member_srl = $logged_info->member_srl;
|
||||
$args->blamed_count = $oDocument->get('blamed_count') + 1;
|
||||
$output = executeQuery('document.updateBlamedCount', $args);
|
||||
if($point > 0)
|
||||
{
|
||||
$args->voted_count = $oDocument->get('voted_count') - 1;
|
||||
$output = executeQuery('document.updateVotedCount', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->blamed_count = $oDocument->get('blamed_count') + 1;
|
||||
$output = executeQuery('document.updateBlamedCount', $args);
|
||||
}
|
||||
$d_output = executeQuery('document.deleteDocumentVotedLog', $d_args);
|
||||
if(!$d_output->toBool()) return $d_output;
|
||||
|
||||
//session reset
|
||||
$_SESSION['voted_document'][$document_srl] = false;
|
||||
|
||||
$output = new Object();
|
||||
$output->setMessage('success_blamed_canceled');
|
||||
$obj = new stdClass();
|
||||
$obj->member_srl = $oDocument->get('member_srl');
|
||||
$obj->module_srl = $oDocument->get('module_srl');
|
||||
$obj->document_srl = $oDocument->get('document_srl');
|
||||
$obj->update_target = ($point < 0) ? 'blamed_count' : 'voted_count';
|
||||
$obj->point = $point;
|
||||
$obj->before_point = ($point < 0) ? $oDocument->get('blamed_count') : $oDocument->get('voted_count');
|
||||
$obj->after_point = ($point < 0) ? $args->blamed_count : $args->voted_count;
|
||||
$obj->cancel = 1;
|
||||
|
||||
$trigger_output = ModuleHandler::triggerCall('document.updateVotedCountCancel', 'after', $obj);
|
||||
if(!$trigger_output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $trigger_output;
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -93,6 +93,7 @@ class point extends ModuleObject
|
|||
$oModuleController->insertTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before');
|
||||
// Add a trigger for comment voting up and down 2014.08.30 sejin7940
|
||||
$oModuleController->insertTrigger('comment.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
|
||||
$oModuleController->insertTrigger('document.updateVotedCountCancel', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
|
||||
return new Object();
|
||||
}
|
||||
|
||||
|
|
@ -132,6 +133,7 @@ class point extends ModuleObject
|
|||
|
||||
// Add a trigger for comment voting up and down 2014.08.30 sejin7940
|
||||
if(!$oModuleModel->getTrigger('comment.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after')) return true;
|
||||
if(!$oModuleModel->getTrigger('document.updateVotedCountCancel', 'point', 'controller', 'triggerUpdateVotedCount', 'after')) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
@ -174,6 +176,8 @@ class point extends ModuleObject
|
|||
// Add a trigger for voting up and down 2008.05.13 haneul
|
||||
if(!$oModuleModel->getTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after'))
|
||||
$oModuleController->insertTrigger('document.updateVotedCount', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
|
||||
if(!$oModuleModel->getTrigger('document.updateVotedCountCancel', 'point', 'controller', 'triggerUpdateVotedCount', 'after'))
|
||||
$oModuleController->insertTrigger('document.updateVotedCountCancel', 'point', 'controller', 'triggerUpdateVotedCount', 'after');
|
||||
// Add a trigger for using points for permanent saving of a temporarily saved document 2009.05.19 zero
|
||||
if(!$oModuleModel->getTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before'))
|
||||
$oModuleController->insertTrigger('document.updateDocument', 'point', 'controller', 'triggerUpdateDocument', 'before');
|
||||
|
|
|
|||
|
|
@ -492,7 +492,18 @@ class pointController extends point
|
|||
|
||||
if(!$point) return new Object();
|
||||
// Increase the point
|
||||
$cur_point += $point;
|
||||
if($obj->cancel > 0)
|
||||
{
|
||||
$cur_point -= $point;
|
||||
}
|
||||
else if($obj->cancel == null)
|
||||
{
|
||||
$cur_point += $point;
|
||||
}
|
||||
else
|
||||
{
|
||||
$cur_point += $point;
|
||||
}
|
||||
$this->setPoint($member_srl,$cur_point);
|
||||
|
||||
return new Object();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue