#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

@ -271,6 +271,7 @@ $lang->fail_to_delete = '삭제 실패했습니다.';
$lang->fail_to_move = '이동 실패했습니다.'; $lang->fail_to_move = '이동 실패했습니다.';
$lang->failed_voted = '추천할 수 없습니다.'; $lang->failed_voted = '추천할 수 없습니다.';
$lang->failed_voted_canceled = '추천한 적이 없으므로 취소할 수 없습니다.'; $lang->failed_voted_canceled = '추천한 적이 없으므로 취소할 수 없습니다.';
$lang->failed_voted_cancel = '추천을 취소할 수 없습니다.';
$lang->failed_blamed = '비추천할 수 없습니다.'; $lang->failed_blamed = '비추천할 수 없습니다.';
$lang->failed_blamed_canceled = '비추천한 적이 없으므로 취소할 수 없습니다.'; $lang->failed_blamed_canceled = '비추천한 적이 없으므로 취소할 수 없습니다.';
$lang->failed_declared = '신고할 수 없습니다.'; $lang->failed_declared = '신고할 수 없습니다.';

View file

@ -51,6 +51,7 @@ $lang->about_allow_no_category = '분류를 선택하지 않은 글도 허용하
$lang->protect_content = '글 보호 기능'; $lang->protect_content = '글 보호 기능';
$lang->protect_comment = '댓글 보호 기능'; $lang->protect_comment = '댓글 보호 기능';
$lang->protect_regdate = '기간 제한 기능'; $lang->protect_regdate = '기간 제한 기능';
$lang->cancel_vote = '추천/비추천/신고 취소 허용';
$lang->document_length_limit = '문서 길이 제한'; $lang->document_length_limit = '문서 길이 제한';
$lang->comment_length_limit = '댓글 길이 제한'; $lang->comment_length_limit = '댓글 길이 제한';
$lang->about_document_length_limit = '지나치게 용량이 큰 글을 작성하지 못하도록 합니다. 지저분한 태그가 많이 붙은 글을 붙여넣기하면 제한을 초과할 수도 있습니다.'; $lang->about_document_length_limit = '지나치게 용량이 큰 글을 작성하지 못하도록 합니다. 지저분한 태그가 많이 붙은 글을 붙여넣기하면 제한을 초과할 수도 있습니다.';
@ -58,6 +59,7 @@ $lang->about_comment_length_limit = '지나치게 용량이 큰 댓글을 작성
$lang->update_order_on_comment = '댓글 작성시 글 수정 시각 갱신'; $lang->update_order_on_comment = '댓글 작성시 글 수정 시각 갱신';
$lang->about_update_order_on_comment = '댓글이 작성되면 해당 글의 수정 시각을 갱신합니다. 포럼형 게시판, 최근 댓글 표시 기능 등에 필요합니다.'; $lang->about_update_order_on_comment = '댓글이 작성되면 해당 글의 수정 시각을 갱신합니다. 포럼형 게시판, 최근 댓글 표시 기능 등에 필요합니다.';
$lang->non_login_vote = '비회원 추천 허용'; $lang->non_login_vote = '비회원 추천 허용';
$lang->about_cancel_vote = '추천 비추천 신고를 취소할 수 있습니다.';
$lang->about_non_login_vote = '로그인하지 않은 방문자도 추천할 수 있도록 합니다.'; $lang->about_non_login_vote = '로그인하지 않은 방문자도 추천할 수 있도록 합니다.';
$lang->about_protect_regdate = '글이나 댓글을 작성한 후 일정 기간이 지나면 수정 또는 삭제할 수 없도록 합니다. (단위 : day)'; $lang->about_protect_regdate = '글이나 댓글을 작성한 후 일정 기간이 지나면 수정 또는 삭제할 수 없도록 합니다. (단위 : day)';
$lang->about_protect_content = '댓글이 달린 글은 수정 또는 삭제할 수 없도록 합니다.'; $lang->about_protect_content = '댓글이 달린 글은 수정 또는 삭제할 수 없도록 합니다.';

View file

@ -289,6 +289,18 @@
<p class="x_help-block">{$lang->about_non_login_vote}</p> <p class="x_help-block">{$lang->about_non_login_vote}</p>
</div> </div>
</div> </div>
<div class="x_control-group">
<label class="x_control-label">{$lang->cancel_vote}</label>
<div class="x_controls">
<label class="x_inline">
<input type="radio" id="cancel_vote_y" name="cancel_vote" value="Y" checked="checked"|cond="$module_info->cancel_vote == 'Y'" /> {$lang->cmd_yes}
</label>
<label class="x_inline">
<input type="radio" id="cancel_vote_n" name="cancel_vote" value="N" checked="checked"|cond="$module_info->cancel_vote != 'Y'" /> {$lang->cmd_no}
</label>
<p class="x_help-block">{$lang->about_cancel_vote}</p>
</div>
</div>
<div class="x_control-group"> <div class="x_control-group">
<label class="x_control-label">{$lang->protect_content}</label> <label class="x_control-label">{$lang->protect_content}</label>
<div class="x_controls"> <div class="x_controls">

View file

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

View file

@ -495,7 +495,14 @@ class documentItem extends BaseObject
} }
$args = new stdClass; $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; $args->document_srl = $this->document_srl;
$output = executeQuery('document.getDocumentVotedLog', $args); $output = executeQuery('document.getDocumentVotedLog', $args);
if($output->data->point) if($output->data->point)

View file

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

View file

@ -4,6 +4,7 @@
</tables> </tables>
<columns> <columns>
<column name="count(*)" alias="count" /> <column name="count(*)" alias="count" />
<column name="sum(point)" alias="point" />
</columns> </columns>
<conditions> <conditions>
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" /> <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> <p id="micons_help" class="x_help-block">{$lang->about_cmd_mobile_icon_setting}</p>
</div> </div>
</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"> <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" 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> <span class="x_pull-right"><input class="x_btn x_btn-primary" type="submit" value="{$lang->cmd_save}" /></span>