묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
1.7.4.2 에서 추천 하면 추천인도 포인트 받기 방법
2014.11.07 12:35
1.7.4.2에서 updateVotedCount 부분이며
아래 빨간 포인트 부분에서 1로 되어 있는걸 3으로 바꿨는데요 추천하면 1포인트만 올라가는데요
추천 시 3포인트를 받을 수 있는 방법이 없을까요??
아래글들의 내용은 1.7.4.2에서는 없네요..
--------------------------------------------------
function updateVotedCount($document_srl, $point = 3)
{
if($point > 0) $failed_voted = 'failed_voted';
else $failed_voted = 'failed_blamed';
// Return fail if session already has information about votes
if($_SESSION['voted_document'][$document_srl])
{
return new Object(-1, $failed_voted);
}
// Get the original document
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
// Pass if the author's IP address is as same as visitor's.
if($oDocument->get('ipaddress') == $_SERVER['REMOTE_ADDR'])
{
$_SESSION['voted_document'][$document_srl] = true;
return new Object(-1, $failed_voted);
}
// Create a member model object
$oMemberModel = getModel('member');
$member_srl = $oMemberModel->getLoggedMemberSrl();
// Check if document's author is a member.
if($oDocument->get('member_srl'))
{
// Pass after registering a session if author's information is same as the currently logged-in user's.
if($member_srl && $member_srl == $oDocument->get('member_srl'))
{
$_SESSION['voted_document'][$document_srl] = true;
return new Object(-1, $failed_voted);
}
}
// Use member_srl for logged-in members and IP address for non-members.
$args = new stdClass;
if($member_srl)
{
$args->member_srl = $member_srl;
}
else
{
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
}
$args->document_srl = $document_srl;
$output = executeQuery('document.getDocumentVotedLogInfo', $args);
// Pass after registering a session if log information has vote-up logs
if($output->data->count)
{
$_SESSION['voted_document'][$document_srl] = true;
return new Object(-1, $failed_voted);
}
// begin transaction
$oDB = DB::getInstance();
$oDB->begin();
// Update the voted count
if($point < 0)
{
$args->blamed_count = $oDocument->get('blamed_count') + $point;
$output = executeQuery('document.updateBlamedCount', $args);
}
else
{
$args->voted_count = $oDocument->get('voted_count') + $point;
$output = executeQuery('document.updateVotedCount', $args);
}
if(!$output->toBool()) return $output;
// Leave logs
$args->point = $point;
$output = executeQuery('document.insertDocumentVotedLog', $args);
if(!$output->toBool()) return $output;
$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;
$trigger_output = ModuleHandler::triggerCall('document.updateVotedCount', 'after', $obj);
if(!$trigger_output->toBool())
{
$oDB->rollback();
return $trigger_output;
}
$oDB->commit();
$oCacheHandler = CacheHandler::getInstance('object');
if($oCacheHandler->isSupport())
{
//remove document item from cache
$cache_key = 'document_item:'. getNumberingPath($document_srl) . $document_srl;
$oCacheHandler->delete($cache_key);
}
// Leave in the session information
$_SESSION['voted_document'][$document_srl] = true;
// Return result
if($point > 0)
{
return new Object(0, 'success_voted');
}
else
{
return new Object(0, 'success_blamed');
}
}