안녕하세요?

 

댓글 랜덤 포인트 에드온에서 질문 있어요.

https://xetown.com/xepoint/188667

 

위 에드온을 사용해서 댓글을 달면 랜덤하게 댓글 포인트가 잘 달립니다.

문제는 해당 댓글을 수정하면 아래처럼 포인트가 중복지급이 되어버립니다.

listeck    2 시간 전 (118.127.193.106)
댓글 테스트

- 축하드립니다. 댓글 보너스 6점을 받으셨습니다.


- 축하드립니다. 댓글 보너스 14점을 받으셨습니다.

 

혹시 댓글 수정시 포인트가 중복 지급되지 않게 처리할 수 있을까요?

 

 

<?php
if(!defined("__XE__")) exit();

/**
* @file comment_rr_point.addon.php
* @author Double 'U'([email protected])
* @brief 코멘트를 달 경우 랜덤하게 랜덤한 포인트를 주기도 합니다.
**/

$logged_info = Context::get('logged_info');
$member_srl = $logged_info->member_srl;
if($member_srl && $called_position == 'before_module_proc' && Context::get('act') == 'procBoardInsertComment') {
$chance = $addon_info->chance;
if(!$chance) $chance = 10;

$min_point = $addon_info->min_point;
if(!$min_point) $min_point = 1;

$max_point = $addon_info->max_point;
if(!$max_point) $max_point = 10;

$rand_no = rand(1, $chance);
$rand_point = rand($min_point, $max_point);

if($rand_no == 1) {
$oPointModel = &getModel('point');
$point = $oPointModel->getPoint($member_srl);

$oPointController = &getController('point');
$oPointController->setPoint($member_srl, $rand_point, 'add');

$content_ori = Context::get('content');
Context::set('content', $content_ori."<br><br>- 축하드립니다. 댓글 보너스 ".$rand_point."점을 받으셨습니다.");
}
}
?>

 

  • profile
    if($member_srl && $called_position == 'before_module_proc' && Context::get('act') == 'procBoardInsertComment' && !Context::get('comment_srl')) {
  • profile profile
    안녕하세요? 착한인연님...
    답변주셔서 감사합니다.
    위 코드를 어디쯤에 넣으면 될까요? ^^;
  • profile profile
    12줄을 대채하면 되는 것 같습니다~

    맨뒤에 코멘트의 고유번호(comment_srl)가 없는 경우에만 이라는 조건이 추가된거네요!!
  • profile profile
    안녕하세요? 착한인연님...
    덕분에 문제해결하였습니다.
    잘 작동합니다~
  • profile profile
    감사합니다.
    알려주신 위치에 넣으니 잘 작동하네요.