mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-05 17:51:40 +09:00
신고를 취소하는 기능 추가
This commit is contained in:
parent
daf51c24fd
commit
7e345870a0
10 changed files with 226 additions and 3 deletions
|
|
@ -250,6 +250,7 @@ $lang->msg_crypto_not_available = 'OpenSSL extension is not installed.';
|
|||
$lang->comment_to_be_approved = 'Your comment must be approved by admin before being published.';
|
||||
$lang->success_registed = 'Registered successfully.';
|
||||
$lang->success_declared = 'Reported successfully.';
|
||||
$lang->success_declared_cancel = 'The report successfully canceled.';
|
||||
$lang->success_updated = 'Updated successfully.';
|
||||
$lang->success_deleted = 'Deleted successfully.';
|
||||
$lang->success_declare_canceled = 'Your report has been canceled.';
|
||||
|
|
@ -273,6 +274,7 @@ $lang->failed_voted_canceled = 'You cannot cancel an upvote that you did\'t make
|
|||
$lang->failed_blamed = 'No permission to downvote.';
|
||||
$lang->failed_blamed_canceled = 'You cannot cancel a downvote that you did\'t make.';
|
||||
$lang->failed_declared = 'No permission to Report.';
|
||||
$lang->failed_declared_cancel = 'You cannot cancel the report.';
|
||||
$lang->fail_to_delete_have_children = 'Cannot delete the article with comments.';
|
||||
$lang->confirm_submit = 'Are you sure you want to submit?';
|
||||
$lang->confirm_logout = 'Are you sure you want to sign out?';
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@ $lang->msg_crypto_not_available = 'openssl 확장모듈이 설치되어 있지
|
|||
$lang->comment_to_be_approved = '관리자의 확인이 필요한 댓글입니다.';
|
||||
$lang->success_registed = '등록했습니다.';
|
||||
$lang->success_declared = '신고했습니다.';
|
||||
$lang->success_declared_cancel = '신고를 취소 했습니다.';
|
||||
$lang->success_updated = '수정했습니다.';
|
||||
$lang->success_deleted = '삭제했습니다.';
|
||||
$lang->success_declare_canceled = '신고가 취소되었습니다.';
|
||||
|
|
@ -273,6 +274,7 @@ $lang->failed_voted_canceled = '추천한 적이 없으므로 취소할 수 없
|
|||
$lang->failed_blamed = '비추천할 수 없습니다.';
|
||||
$lang->failed_blamed_canceled = '비추천한 적이 없으므로 취소할 수 없습니다.';
|
||||
$lang->failed_declared = '신고할 수 없습니다.';
|
||||
$lang->failed_declared_cancel = '신고를 취소할 수 없습니다.';
|
||||
$lang->fail_to_delete_have_children = '댓글이 있어서 삭제할 수 없습니다.';
|
||||
$lang->confirm_submit = '등록하시겠습니까?';
|
||||
$lang->confirm_logout = '로그아웃하시겠습니까?';
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
<action name="procDocumentVoteDownCancel" type="controller" />
|
||||
<action name="procDocumentTempSave" type="controller" permission="member" />
|
||||
<action name="procDocumentDeclare" type="controller" permission="member" />
|
||||
<action name="procDocumentDeclareCancel" type="controller" permission="member" />
|
||||
<action name="procDocumentGetList" type="controller" permission="manager" check_type="document" check_var="document_srls" />
|
||||
<action name="procDocumentAddCart" type="controller" permission="manager" check_type="document" check_var="srls" />
|
||||
<action name="procDocumentManageCheckedDocument" type="controller" permission="manager" check_type="document" check_var="cart" />
|
||||
|
|
|
|||
|
|
@ -267,8 +267,7 @@ class documentController extends document
|
|||
// if an user select message from options, message would be the option.
|
||||
$message_option = strval(Context::get('message_option'));
|
||||
$improper_document_reasons = lang('improper_document_reasons');
|
||||
$declare_message = ($message_option !== 'others' && isset($improper_document_reasons[$message_option]))?
|
||||
$improper_document_reasons[$message_option] : trim(Context::get('declare_message'));
|
||||
$declare_message = ($message_option !== 'others' && isset($improper_document_reasons[$message_option])) ? $improper_document_reasons[$message_option] : trim(Context::get('declare_message'));
|
||||
|
||||
// if there is return url, set that.
|
||||
if(Context::get('success_return_url'))
|
||||
|
|
@ -279,6 +278,33 @@ class documentController extends document
|
|||
return $this->declaredDocument($document_srl, $declare_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고를 취소하는 액션
|
||||
* @return BaseObject|object
|
||||
* @throws \Rhymix\Framework\Exceptions\InvalidRequest
|
||||
* @throws \Rhymix\Framework\Exceptions\MustLogin
|
||||
*/
|
||||
function procDocumentDeclareCancel()
|
||||
{
|
||||
if(!Context::get('is_logged'))
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\MustLogin;
|
||||
}
|
||||
|
||||
$document_srl = intval(Context::get('target_srl'));
|
||||
if(!$document_srl)
|
||||
{
|
||||
throw new Rhymix\Framework\Exceptions\InvalidRequest;
|
||||
}
|
||||
|
||||
if(Context::get('success_return_url'))
|
||||
{
|
||||
$this->setRedirectUrl(Context::get('success_return_url'));
|
||||
}
|
||||
|
||||
return $this->declaredDocumentCancel($document_srl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete alias when module deleted
|
||||
* @param int $module_srl
|
||||
|
|
@ -1720,6 +1746,123 @@ class documentController extends document
|
|||
$this->setMessage('success_declared');
|
||||
}
|
||||
|
||||
/**
|
||||
* 신고 취소
|
||||
* @param $document_srl
|
||||
* @return BaseObject|object|void
|
||||
*/
|
||||
function declaredDocumentCancel($document_srl)
|
||||
{
|
||||
$args = new stdClass();
|
||||
$args->document_srl = $document_srl;
|
||||
$output = executeQuery('document.getDeclaredDocument', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
return $output;
|
||||
}
|
||||
|
||||
$declared_count = ($output->data->declared_count) ? $output->data->declared_count : 0;
|
||||
|
||||
$trigger_obj = new stdClass();
|
||||
$trigger_obj->document_srl = $document_srl;
|
||||
$trigger_obj->declared_count = $declared_count;
|
||||
|
||||
// Call a trigger (before)
|
||||
$trigger_output = ModuleHandler::triggerCall('document.declaredDocumentCancel', 'before', $trigger_obj);
|
||||
if(!$trigger_output->toBool())
|
||||
{
|
||||
return $trigger_output;
|
||||
}
|
||||
|
||||
// Get the original document
|
||||
$oDocumentModel = getModel('document');
|
||||
$oDocument = $oDocumentModel->getDocument($document_srl, false, false);
|
||||
|
||||
$oDB = DB::getInstance();
|
||||
$oDB->begin();
|
||||
|
||||
$member_srl = intval($this->user->member_srl);
|
||||
|
||||
$args = new stdClass;
|
||||
$args->document_srl = $document_srl;
|
||||
if($member_srl)
|
||||
{
|
||||
$args->member_srl = $member_srl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->ipaddress = \RX_CLIENT_IP;
|
||||
}
|
||||
$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
|
||||
|
||||
if($output->data->count <= 0 || !isset($output->data->count))
|
||||
{
|
||||
$_SESSION['declared_document'][$document_srl] = false;
|
||||
return new BaseObject(-1, 'failed_declared_cancel');
|
||||
}
|
||||
|
||||
if($declared_count > 1)
|
||||
{
|
||||
$output = executeQuery('document.updateDeclaredDocumentCancel', $args);
|
||||
}
|
||||
else
|
||||
{
|
||||
$output = executeQuery('document.deleteDeclaredDocument', $args);
|
||||
}
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$output = executeQuery('document.deleteDeclaredDocumentLog', $args);
|
||||
if(!$output->toBool())
|
||||
{
|
||||
$oDB->rollback();
|
||||
return $output;
|
||||
}
|
||||
|
||||
$message_targets = array();
|
||||
$module_srl = $oDocument->get('module_srl');
|
||||
$oModuleModel = getModel('module');
|
||||
$document_config = $oModuleModel->getModulePartConfig('document', $module_srl);
|
||||
if ($document_config->declared_message && in_array('admin', $document_config->declared_message))
|
||||
{
|
||||
$output = executeQueryArray('member.getAdmins', new stdClass);
|
||||
foreach ($output->data as $admin)
|
||||
{
|
||||
$message_targets[$admin->member_srl] = true;
|
||||
}
|
||||
}
|
||||
if ($document_config->declared_message && in_array('manager', $document_config->declared_message))
|
||||
{
|
||||
$output = executeQueryArray('module.getModuleAdmin', (object)['module_srl' => $module_srl]);
|
||||
foreach ($output->data as $manager)
|
||||
{
|
||||
$message_targets[$manager->member_srl] = true;
|
||||
}
|
||||
}
|
||||
if ($message_targets)
|
||||
{
|
||||
$oCommunicationController = getController('communication');
|
||||
$message_title = lang('document.declared_cancel_message_title');
|
||||
$message_content = sprintf('<p><a href="%s">%s</a></p><p>%s</p>', $oDocument->getPermanentUrl(), $oDocument->getTitleText());
|
||||
foreach ($message_targets as $target_member_srl => $val)
|
||||
{
|
||||
$oCommunicationController->sendMessage($this->user->member_srl, $target_member_srl, $message_title, $message_content, false);
|
||||
}
|
||||
}
|
||||
|
||||
$oDB->commit();
|
||||
|
||||
$trigger_obj->declared_count = $declared_count - 1;
|
||||
ModuleHandler::triggerCall('document.declaredDocumentCancel', 'after', $trigger_obj);
|
||||
|
||||
$_SESSION['declared_document'][$document_srl] = false;
|
||||
|
||||
$this->setMessage('success_declared_cancel');
|
||||
}
|
||||
|
||||
/**
|
||||
* Increase the number of comments in the document
|
||||
* Update modified date, modifier, and order with increasing comment count
|
||||
|
|
|
|||
|
|
@ -506,6 +506,48 @@ class documentItem extends BaseObject
|
|||
return $_SESSION['voted_document'][$this->document_srl] = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 게시글에 신고한 이력이 있는지 검사
|
||||
* @return bool|int
|
||||
*/
|
||||
function getDeclared()
|
||||
{
|
||||
if(!$this->isExists())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
$logged_info = Context::get('logged_info');
|
||||
if(!$logged_info->member_srl)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(isset($_SESSION['declared_document'][$this->document_srl]))
|
||||
{
|
||||
return $_SESSION['declared_document'][$this->document_srl];
|
||||
}
|
||||
|
||||
$args = new stdClass();
|
||||
if($logged_info->member_srl)
|
||||
{
|
||||
$args->member_srl = $logged_info->member_srl;
|
||||
}
|
||||
else
|
||||
{
|
||||
$args->ipaddress = \RX_CLIENT_IP;
|
||||
}
|
||||
$args->document_srl = $this->document_srl;
|
||||
$output = executeQuery('document.getDocumentDeclaredLogInfo', $args);
|
||||
$declaredCount = intval($output->data->count);
|
||||
if($declaredCount > 0)
|
||||
{
|
||||
return $_SESSION['declared_document'][$this->document_srl] = $declaredCount;
|
||||
}
|
||||
|
||||
return $_SESSION['declared_document'][$this->document_srl] = false;
|
||||
}
|
||||
|
||||
function getTitle($cut_size = 0, $tail = '...')
|
||||
{
|
||||
if(!$this->isExists())
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ $lang->original_date = 'Original date';
|
|||
$lang->declared_count = 'Report count';
|
||||
$lang->latest_declared_date = 'Last reported date';
|
||||
$lang->declared_message_title = 'A post has been reported.';
|
||||
$lang->declared_cancel_message_title = 'Cancel the reported a post.';
|
||||
$lang->declaring_user = 'Reporter';
|
||||
$lang->improper_document_declare_reason = 'Reason';
|
||||
$lang->improper_document_reasons['advertisement'] = 'Advertisements that do not fit the topics or themes.';
|
||||
|
|
|
|||
|
|
@ -98,6 +98,7 @@ $lang->original_date = '작성 날짜';
|
|||
$lang->declared_count = '신고 수';
|
||||
$lang->latest_declared_date = '최근 신고 날짜';
|
||||
$lang->declared_message_title = '신고가 접수되었습니다.';
|
||||
$lang->declared_cancel_message_title = '신고가 취소되었습니다.';
|
||||
$lang->declaring_user = '신고자';
|
||||
$lang->improper_document_declare_reason = '신고 이유';
|
||||
$lang->improper_document_reasons['advertisement'] = '주제나 흐름에 맞지 않는 광고 글입니다.';
|
||||
|
|
|
|||
8
modules/document/queries/deleteDeclaredDocument.xml
Normal file
8
modules/document/queries/deleteDeclaredDocument.xml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<query id="deleteDeclaredDocument" action="delete">
|
||||
<tables>
|
||||
<table name="document_declared" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
12
modules/document/queries/deleteDeclaredDocumentLog.xml
Normal file
12
modules/document/queries/deleteDeclaredDocumentLog.xml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
<query id="deleteDocumentDeclaredLog" action="delete">
|
||||
<tables>
|
||||
<table name="document_declared_log" />
|
||||
</tables>
|
||||
<conditions>
|
||||
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||
<group pipe="and">
|
||||
<condition operation="equal" column="member_srl" var="member_srl" filter="number" pipe="and" />
|
||||
<condition operation="equal" column="ipaddress" var="ipaddress" pipe="and" />
|
||||
</group>
|
||||
</conditions>
|
||||
</query>
|
||||
11
modules/document/queries/updateDeclaredDocumentCancel.xml
Normal file
11
modules/document/queries/updateDeclaredDocumentCancel.xml
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<query id="updateDeclaredDocumentCancel" action="update">
|
||||
<tables>
|
||||
<table name="document_declared" />
|
||||
</tables>
|
||||
<columns>
|
||||
<column name="declared_count" default="minus(1)" />
|
||||
</columns>
|
||||
<conditions>
|
||||
<condition operation="equal" column="document_srl" var="document_srl" filter="number" notnull="notnull" />
|
||||
</conditions>
|
||||
</query>
|
||||
Loading…
Add table
Add a link
Reference in a new issue