알림 수신 거부 기능을 드롭다운 메뉴에 추가 (#1301)

알림센터의 수신 거부 기능을 드롭다운 메뉴에 추가.

* 알림 수신 설정 메뉴 트리거 코드 수정
* Unsubscribe_srl이 잘못된 값일 경우에 대한 오류 처리 추가
* Refining the unsubscribing methods
* 사용하지 않는 변수 제거, 오류 문구 정리
* 사용할 필요가 없어진 $member_srl 변수 사용 안함.
* 수신 거부 해제 대상이 아닌 컨텐츠를 수신 거부 해제 요청시 오류 문구 추가.
* Support multi-lang for the unsubscribing page of default skin
This commit is contained in:
Min-Soo Kim 2020-05-31 22:44:14 +09:00 committed by GitHub
parent 81774f6e96
commit 43fe12af13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 144 additions and 32 deletions

View file

@ -109,6 +109,10 @@ $lang->ncenterlite_commnet_event_noti_all = 'Notice every comments to the author
$lang->ncenterlite_commnet_event_noti_some = 'Notice only direct replies to the author'; $lang->ncenterlite_commnet_event_noti_some = 'Notice only direct replies to the author';
$lang->ncenterlite_message_event = 'Notify message'; $lang->ncenterlite_message_event = 'Notify message';
$lang->ncenterlite_message_event_about = 'Do not notify message (Use XE Core message notification system).'; $lang->ncenterlite_message_event_about = 'Do not notify message (Use XE Core message notification system).';
$lang->ncenterlite_mid_use = 'Module specific settings';
$lang->ncenterlite_to_unsubscribe = 'Disable notification';
$lang->ncenterlite_subscribe = 'Activate notification';
$lang->ncenterlite_cmd_unsubscribe_settings = 'Notification settings';
$lang->ncenterlite_all_delete = 'Delete all'; $lang->ncenterlite_all_delete = 'Delete all';
$lang->ncenterlite_month_before_delete = 'Delete older than 1 month'; $lang->ncenterlite_month_before_delete = 'Delete older than 1 month';
$lang->dont_check_notify_delete = 'Unread notifications will be deleted, too.'; $lang->dont_check_notify_delete = 'Unread notifications will be deleted, too.';
@ -122,3 +126,6 @@ $lang->about_anonymous_scrap = 'anonymize scrapper in scrap notification';
$lang->highlight_effect = 'highlight effect'; $lang->highlight_effect = 'highlight effect';
$lang->about_highlight_effect = 'it gives highlight effect to the comment when access the comment URL.'; $lang->about_highlight_effect = 'it gives highlight effect to the comment when access the comment URL.';
$lang->msg_denger_rhymix_user = '<strong>Warning!</strong> Rhymix includes notification center by default.<br />Please remove this XE-only module and reinstall the Rhymix native version.'; $lang->msg_denger_rhymix_user = '<strong>Warning!</strong> Rhymix includes notification center by default.<br />Please remove this XE-only module and reinstall the Rhymix native version.';
$lang->ncenterlite_content_type = 'Type of the contents';
$lang->msg_unsubscribe_not_in_list = 'This contents is not in the unsubscribed list.';

View file

@ -129,6 +129,7 @@ $lang->ncenterlite_message_event_about = '쪽지 알림을 사용하지 않음(X
$lang->ncenterlite_mid_use = '모듈별 사용 설정'; $lang->ncenterlite_mid_use = '모듈별 사용 설정';
$lang->ncenterlite_to_unsubscribe = '수신 거부'; $lang->ncenterlite_to_unsubscribe = '수신 거부';
$lang->ncenterlite_subscribe = '수신 거부 안함'; $lang->ncenterlite_subscribe = '수신 거부 안함';
$lang->ncenterlite_cmd_unsubscribe_settings = '알림 수신 설정';
$lang->this_message_unsubscribe = '이 게시글/댓글의 알림 수신 거부'; $lang->this_message_unsubscribe = '이 게시글/댓글의 알림 수신 거부';
$lang->about_this_message_unsubscribe = '이 게시글/댓글의 알림을 수신 거부합니다.'; $lang->about_this_message_unsubscribe = '이 게시글/댓글의 알림을 수신 거부합니다.';
$lang->unsubscribe_list = '수신 거부 리스트'; $lang->unsubscribe_list = '수신 거부 리스트';
@ -171,6 +172,7 @@ $lang->cmd_web_notify = '웹 알림';
$lang->cmd_mail_notify = '메일 알림'; $lang->cmd_mail_notify = '메일 알림';
$lang->cmd_sms_notify = '문자 알림'; $lang->cmd_sms_notify = '문자 알림';
$lang->cmd_push_notify = '푸시 알림'; $lang->cmd_push_notify = '푸시 알림';
$lang->ncenterlite_content_type = '컨텐츠 종류';
$lang->ncenterlite_type_id = '알림 타입 아이디'; $lang->ncenterlite_type_id = '알림 타입 아이디';
$lang->ncenterlite_type_objects = '알림 타입 변수값'; $lang->ncenterlite_type_objects = '알림 타입 변수값';
$lang->ncenterlite_type_content = '알림 타입 내용'; $lang->ncenterlite_type_content = '알림 타입 내용';
@ -182,3 +184,4 @@ $lang->msg_denger_rhymix_user = '<strong>경고!</strong> 라이믹스에서는
$lang->msg_test_notifycation_success = '테스트알림더미를 정상적으로 생성하였습니다.'; $lang->msg_test_notifycation_success = '테스트알림더미를 정상적으로 생성하였습니다.';
$lang->msg_unsubscribe_block_not_support = '개별 수신 거부 기능을 제공하지 않습니다. 관리자에게 문의하세요.'; $lang->msg_unsubscribe_block_not_support = '개별 수신 거부 기능을 제공하지 않습니다. 관리자에게 문의하세요.';
$lang->msg_unsubscribe_not_permission = '다른 회원의 구독리스트를 조회할 권한이 없습니다.'; $lang->msg_unsubscribe_not_permission = '다른 회원의 구독리스트를 조회할 권한이 없습니다.';
$lang->msg_unsubscribe_not_in_list = '수신 거부 목록에 없는 컨텐츠입니다.';

View file

@ -31,6 +31,9 @@ class ncenterlite extends ModuleObject
array('document.moveDocumentToTrash', 'ncenterlite', 'controller', 'triggerAfterMoveToTrash', 'after'), array('document.moveDocumentToTrash', 'ncenterlite', 'controller', 'triggerAfterMoveToTrash', 'after'),
array('comment.updateVotedCount', 'ncenterlite', 'controller', 'triggerAfterCommentVotedCount', 'after'), array('comment.updateVotedCount', 'ncenterlite', 'controller', 'triggerAfterCommentVotedCount', 'after'),
array('comment.updateVotedCountCancel', 'ncenterlite', 'controller', 'triggerAfterCommentVotedCancel', 'after'), array('comment.updateVotedCountCancel', 'ncenterlite', 'controller', 'triggerAfterCommentVotedCancel', 'after'),
// 2020. 05. 30 add menu when popup document menu called
array('document.getDocumentMenu', 'ncenterlite', 'controller', 'triggerGetDocumentMenu', 'after'),
array('comment.getCommentMenu', 'ncenterlite', 'controller', 'triggerGetCommentMenu', 'after'),
); );
private $delete_triggers = array( private $delete_triggers = array(

View file

@ -113,40 +113,85 @@ class ncenterliteController extends ncenterlite
throw new Rhymix\Framework\Exception('msg_unsubscribe_block_not_support'); throw new Rhymix\Framework\Exception('msg_unsubscribe_block_not_support');
} }
$member_srl = Context::get('member_srl'); if(!Rhymix\Framework\Session::isMember())
if(!$member_srl)
{ {
$member_srl = $this->user->member_srl; throw new Rhymix\Framework\Exception\MustLogin;
}
if(intval($this->user->member_srl) != intval($member_srl) && $this->user->is_admin != 'Y')
{
throw new Rhymix\Framework\Exception('ncenterlite_stop_no_permission_other_user_block_settings');
} }
$obj = Context::getRequestVars(); $obj = Context::getRequestVars();
if($obj->unsubscribe_srl)
if(!$this->user->member_srl || (!intval($obj->unsubscribe_srl) && !intval($obj->target_srl)))
{ {
$userBlockData = $oNcenterliteModel->getUserUnsubscribeConfigByUnsubscribeSrl($obj->unsubscribe_srl); throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
else if($obj->target_srl)
{
$userBlockData = $oNcenterliteModel->getUserUnsubscribeConfigByTargetSrl($obj->target_srl, $member_srl);
} }
if($obj->target_srl)
{
$userBlockData = $oNcenterliteModel->getUserUnsubscribeConfigByTargetSrl($obj->target_srl, $this->user->member_srl);
// If there was a record directed by unsubscribe_srl, the record should be used to validate the input data.
if($userBlockData)
{
if (!intval($obj->unsubscribe_srl))
{
$obj->unsubscribe_srl = $userBlockData->unsubscribe_srl;
}
if (intval($obj->unsubscribe_srl) != intval($userBlockData->unsubscribe_srl))
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
}
}
if(!$userBlockData && $obj->unsubscribe_srl)
{
$userBlockData = $oNcenterliteModel->getUserUnsubscribeConfigByUnsubscribeSrl($obj->unsubscribe_srl);
// The input member_srl from the POST or GET might not equal to the member_srl from the record of unsubscribe_srl.
if(intval($this->user->member_srl) != intval($userBlockData->member_srl))
{
throw new Rhymix\Framework\Exception('ncenterlite_stop_no_permission_other_user_block_settings');
}
// If there was a record directed by unsubscribe_srl, the record should be used to validate the input data.
if($userBlockData)
{
if (!intval($obj->target_srl))
{
$obj->target_srl = $userBlockData->target_srl;
}
if (intval($obj->target_srl) != intval($userBlockData->target_srl))
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
}
}
if($userBlockData)
{
$obj->unsubscribe_srl = $userBlockData->unsubscribe_srl;
}
// Content type can be document and comment, now. However, the default type cannot be specified, as the type can be another in the future.
if($obj->unsubscribe_type == 'document') if($obj->unsubscribe_type == 'document')
{ {
$text = cut_str(getModel('document')->getDocument($obj->target_srl)->get('title'), 30); $text = cut_str(getModel('document')->getDocument($obj->target_srl)->get('title'), 30);
} }
else elseif($obj->unsubscribe_type == 'comment')
{ {
$comment = getModel('comment')->getComment($obj->target_srl); $comment = getModel('comment')->getComment($obj->target_srl);
$contentString = $comment->getContentText(30); $contentString = $comment->getContentText(30);
$text = strlen($contentString) ? $contentString : lang('comment.no_text_comment'); $text = strlen($contentString) ? $contentString : lang('comment.no_text_comment');
} }
else
{
throw new Rhymix\Framework\Exceptions\InvalidRequest;
}
$args = new stdClass(); $args = new stdClass();
$args->member_srl = $member_srl; $args->member_srl = $this->user->member_srl;
$args->target_srl = $obj->target_srl; $args->target_srl = $obj->target_srl;
if($obj->unsubscribe_type == 'document') if($obj->unsubscribe_type == 'document')
{ {
@ -178,6 +223,11 @@ class ncenterliteController extends ncenterlite
} }
else else
{ {
if(!$obj->unsubscribe_srl && !$userBlockData)
{
throw new Rhymix\Framework\Exception('msg_unsubscribe_not_in_list');
}
$args->unsubscribe_srl = $obj->unsubscribe_srl; $args->unsubscribe_srl = $obj->unsubscribe_srl;
$output = executeQuery('ncenterlite.deleteUnsubscribe', $args); $output = executeQuery('ncenterlite.deleteUnsubscribe', $args);
if(!$output->toBool()) if(!$output->toBool())
@ -193,7 +243,7 @@ class ncenterliteController extends ncenterlite
} }
else else
{ {
$this->setRedirectUrl(getNotEncodedUrl('act', 'dispNcenterliteUnsubscribeList', 'member_srl', $member_srl)); $this->setRedirectUrl(getNotEncodedUrl('act', 'dispNcenterliteUnsubscribeList', 'member_srl', $this->user->member_srl));
} }
} }
@ -1621,4 +1671,53 @@ class ncenterliteController extends ncenterlite
} }
return $notify_member_srls; return $notify_member_srls;
} }
/**
* trigger for document.getDocumentMenu. Append to popup menu a button for dispNcenterliteInsertUnsubscribe()
*
* @param array &$menu_list
*
* @return object
**/
function triggerGetDocumentMenu(&$menu_list)
{
if(!Rhymix\Framework\Session::isMember()) return;
$document_srl = Context::get('target_srl');
/** @var ncenterliteModel $oNcenterliteModel */
$oNcenterliteModel = getModel('ncenterlite');
$config = $oNcenterliteModel->getConfig();
if($config->unsubscribe !== 'Y') return;
$oDocumentController = getController('document');
$url = getUrl('','module','ncenterlite','act','dispNcenterliteInsertUnsubscribe', 'target_srl', $document_srl, 'unsubscribe_type', 'document');
$oDocumentController->addDocumentPopupMenu($url,'ncenterlite_cmd_unsubscribe_settings','','popup');
}
/**
* trigger for comment.getCommentMenu. Append to popup menu a button for dispNcenterliteInsertUnsubscribe()
*
* @param array &$menu_list
*
* @return object
**/
function triggerGetCommentMenu(&$menu_list)
{
if(!Rhymix\Framework\Session::isMember()) return;
$comment_srl = Context::get('target_srl');
/** @var ncenterliteModel $oNcenterliteModel */
$oNcenterliteModel = getModel('ncenterlite');
$config = $oNcenterliteModel->getConfig();
if($config->unsubscribe !== 'Y') return;
$oCommentController = getController('comment');
$url = getUrl('','module','ncenterlite','act','dispNcenterliteInsertUnsubscribe', 'target_srl', $comment_srl, 'unsubscribe_type', 'comment');
$oCommentController->addCommentPopupMenu($url,'ncenterlite_cmd_unsubscribe_settings','','popup');
}
} }

View file

@ -156,11 +156,11 @@ class ncenterliteView extends ncenterlite
if($unsubscribe_type == 'document') if($unsubscribe_type == 'document')
{ {
$text = getModel('document')->getDocument($target_srl)->get('title'); $text = getModel('document')->getDocument($target_srl)->getTitleText();
$type = '문서'; $type = lang('document');
if(!$text) if(!$text)
{ {
$text = getModel('comment')->getComment($target_srl)->get('content'); $text = getModel('comment')->getComment($target_srl)->getContentPlainText();
if(!$text) if(!$text)
{ {
throw new Rhymix\Framework\Exceptions\InvalidRequest; throw new Rhymix\Framework\Exceptions\InvalidRequest;
@ -168,18 +168,18 @@ class ncenterliteView extends ncenterlite
else else
{ {
Context::set('unsubscribe_type', 'comment'); Context::set('unsubscribe_type', 'comment');
$type = '댓글'; $type = lang('comment');
} }
} }
} }
else else
{ {
$text = getModel('comment')->getComment($target_srl)->get('content'); $text = getModel('comment')->getComment($target_srl)->getContentPlainText();
$type = '댓글'; $type = lang('comment');
if(!$text) if(!$text)
{ {
$text = getModel('document')->getDocument($target_srl)->get('title'); $text = getModel('document')->getDocument($target_srl)->getTitleText();
if(!$text) if(!$text)
{ {
throw new Rhymix\Framework\Exceptions\InvalidRequest; throw new Rhymix\Framework\Exceptions\InvalidRequest;
@ -187,7 +187,7 @@ class ncenterliteView extends ncenterlite
else else
{ {
Context::set('unsubscribe_type', 'document'); Context::set('unsubscribe_type', 'document');
$type = '문서'; $type = lang('document');
} }
} }
} }

View file

@ -20,7 +20,7 @@
<!--@end--> <!--@end-->
<section class="section"> <section class="section">
<div class="control-group"> <div class="control-group">
<label class="control-label">글 종류</label> <label class="control-label">{lang('ncenterlite_content_type')}</label>
<div class="controls"> <div class="controls">
<p> <p>
{$type} {$type}
@ -28,7 +28,7 @@
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<label class="control-label">내용</label> <label class="control-label">{lang('content')}</label>
<div class="controls"> <div class="controls">
<p> <p>
<!--@if($unsubscribeData)--> <!--@if($unsubscribeData)-->

View file

@ -5,9 +5,9 @@
<table class="table table-striped table-hover" style="margin-top:20px;"> <table class="table table-striped table-hover" style="margin-top:20px;">
<thead class="bg_f_f9"> <thead class="bg_f_f9">
<tr> <tr>
<th scope="col">타입</th> <th scope="col">{lang('ncenterlite_content_type')}</th>
<th scope="col">콘텐츠</th> <th scope="col">{lang('content')}</th>
<th scope="col">차단설정</th> <th scope="col">{lang('ncenterlite_notify_settings')}</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
@ -15,9 +15,9 @@
<tr> <tr>
<td> <td>
<!--@if($val->unsubscribe_type == 'document')--> <!--@if($val->unsubscribe_type == 'document')-->
<span>문서</span> <span>{lang('document')}</span>
<!--@else--> <!--@else-->
<span>댓글</span> <span>{lang('comment')}</span>
<!--@end--> <!--@end-->
</td> </td>
<td> <td>