#1183 #1152 추천 취소 기능 보강

This commit is contained in:
BJRambo 2019-08-07 20:29:53 +09:00
parent de432e8e46
commit 239b231ffa
8 changed files with 69 additions and 38 deletions

View file

@ -63,9 +63,16 @@ class documentController extends document
throw new Rhymix\Framework\Exceptions\NotPermitted;
}
}
if($this->module_info->cancel_vote !=='Y')
{
throw new Rhymix\Framework\Exception('failed_voted_cancel');
}
$document_srl = Context::get('target_srl');
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
if(!$document_srl)
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
$oDocumentModel = getModel('document');
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
@ -150,6 +157,11 @@ class documentController extends document
}
}
if($this->module_info->cancel_vote !=='Y')
{
return new Rhymix\Framework\Exception('failed_voted_canceled');
}
$document_srl = Context::get('target_srl');
if(!$document_srl) throw new Rhymix\Framework\Exceptions\InvalidRequest;
@ -180,26 +192,31 @@ class documentController extends document
*/
function updateVotedCountCancel($document_srl, $oDocument, $point)
{
$logged_info = Context::get('logged_info');
if(!$_SESSION['voted_document'][$document_srl])
{
return new BaseObject(-1, $point > 0 ? 'failed_voted_canceled' : 'failed_blamed_canceled');
}
// Check if the current user has voted previously.
$args = new stdClass;
$args->document_srl = $document_srl;
$args->point = $point;
if($logged_info->member_srl)
if($this->user->member_srl)
{
$args->member_srl = $logged_info->member_srl;
$args->member_srl = $this->user->member_srl;
}
else
{
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
}
$output = executeQuery('document.getDocumentVotedLogInfo', $args);
if(!$output->data->count)
{
return new BaseObject(-1, $point > 0 ? 'failed_voted_canceled' : 'failed_blamed_canceled');
}
$point = $output->data->point;
// Call a trigger (before)
$trigger_obj = new stdClass;
$trigger_obj->member_srl = $oDocument->get('member_srl');
@ -215,35 +232,38 @@ class documentController extends document
{
return $trigger_output;
}
// begin transaction
$oDB = DB::getInstance();
$oDB->begin();
$args = new stdClass();
$d_args = new stdClass();
$args->document_srl = $d_args->document_srl = $document_srl;
$d_args->member_srl = $logged_info->member_srl;
if ($trigger_obj->update_target === 'voted_count')
if($point != 0)
{
$args->voted_count = $trigger_obj->after_point;
$output = executeQuery('document.updateVotedCount', $args);
$args = new stdClass();
$d_args = new stdClass();
$args->document_srl = $d_args->document_srl = $document_srl;
$d_args->member_srl = $this->user->member_srl;
if ($trigger_obj->update_target === 'voted_count')
{
$args->voted_count = $trigger_obj->after_point;
$output = executeQuery('document.updateVotedCount', $args);
}
else
{
$args->blamed_count = $trigger_obj->after_point;
$output = executeQuery('document.updateBlamedCount', $args);
}
$d_output = executeQuery('document.deleteDocumentVotedLog', $d_args);
if(!$d_output->toBool()) return $d_output;
}
else
{
$args->blamed_count = $trigger_obj->after_point;
$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;
// Call a trigger (after)
ModuleHandler::triggerCall('document.updateVotedCountCancel', 'after', $trigger_obj);
$oDB->commit();
return $output;
}

View file

@ -495,7 +495,14 @@ class documentItem extends BaseObject
}
$args = new stdClass;
$args->member_srl = $logged_info->member_srl;
if($logged_info->member_srl)
{
$args->member_srl = $logged_info->member_srl;
}
else
{
$args->ipaddress = $_SERVER['REMOTE_ADDR'];
}
$args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocumentVotedLog', $args);
if($output->data->point)

View file

@ -5,7 +5,6 @@ $lang->view_count_option_all = '모두 계산';
$lang->view_count_option_some = '일부 계산';
$lang->view_count_option_once = '중복 금지';
$lang->view_count_option_none = '계산 안 함';
$lang->cmd_examination_vote = '추천 비추천 신고 검사';
$lang->cmd_document_module_config = '기본 설정';
$lang->cmd_delete_all_thumbnail = '섬네일 모두 삭제';
$lang->cmd_pc_icon_setting = 'PC 아이콘 설정';
@ -20,7 +19,6 @@ $lang->expand = '펼침';
$lang->category_group_srls = '그룹 제한';
$lang->cmd_make_child = '하위 분류 추가';
$lang->cmd_enable_move_category = '분류 위치 변경 (선택 후 위 메뉴를 드래그하세요.)';
$lang->about_examination_vote = '사용시 유저가 추천 비추천 신고를 했다는 검사를 좀 더 까다롭게 합니다. 기본값은 사용하지 않음(기존 동작과 일치)이고 사용할 경우 세션, 아이피까지 확인하여 검사합니다.';
$lang->about_category_title = '분류 이름을 입력해주세요.';
$lang->about_view_count_option = '조회 수 설정에 따라 중복 조회 수 카운트를 할 수 있도록 도와줍니다. 각 옵션에 따라 조회 수를 기록하는 방식이 달라집니다.';
$lang->about_expand = '선택하면 늘 펼쳐진 상태로 있게 합니다.';

View file

@ -4,6 +4,7 @@
</tables>
<columns>
<column name="count(*)" alias="count" />
<column name="sum(point)" alias="point" />
</columns>
<conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />

View file

@ -41,16 +41,6 @@
<p id="micons_help" class="x_help-block">{$lang->about_cmd_mobile_icon_setting}</p>
</div>
</div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cmd_examination_vote}</label>
<div class="x_controls">
<select name="examination_vote">
<option value="Y" selected="selected"|cond="$config->examination_vote=='Y'">{$lang->use}</option>
<option value="N" selected="selected"|cond="$config->examination_vote!='Y'">{$lang->notuse}</option>
</select>
<p class="x_help-block">{$lang->about_examination_vote}</p>
</div>
</div>
<div class="btnArea x_clearfix">
<span class="x_pull-right" style="margin-left:10px;"><input class="btn" type="button" value="{$lang->cmd_delete_all_thumbnail}" onclick="doDeleteAllThumbnail()"/></span>
<span class="x_pull-right"><input class="x_btn x_btn-primary" type="submit" value="{$lang->cmd_save}" /></span>