From 7b1f0b4ee2b6b4ff8af7ab93e7e748ba6dc4c884 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Thu, 28 Sep 2017 11:34:15 +0900 Subject: [PATCH] Fix #916 show error earlier if attempting to add self as friend --- modules/communication/communication.controller.php | 6 +++++- modules/communication/communication.view.php | 4 ++++ modules/communication/lang/en.php | 1 + modules/communication/lang/ko.php | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/modules/communication/communication.controller.php b/modules/communication/communication.controller.php index 294a939b3..b35514649 100644 --- a/modules/communication/communication.controller.php +++ b/modules/communication/communication.controller.php @@ -456,10 +456,14 @@ class communicationController extends communication $logged_info = Context::get('logged_info'); $target_srl = (int) trim(Context::get('target_srl')); - if(!$target_srl || $target_srl == $logged_info->member_srl) + if(!$target_srl) { return new Object(-1, 'msg_invalid_request'); } + if($target_srl == $logged_info->member_srl) + { + return new Object(-1, 'msg_no_self_friend'); + } // Check duplicate friend $args = new stdClass(); diff --git a/modules/communication/communication.view.php b/modules/communication/communication.view.php index 86cb48109..5522fe702 100644 --- a/modules/communication/communication.view.php +++ b/modules/communication/communication.view.php @@ -347,6 +347,10 @@ class communicationView extends communication { return $this->stop('msg_invalid_request'); } + if($target_srl == $logged_info->member_srl) + { + return $this->stop('msg_no_self_friend'); + } // get information of the member $oMemberModel = getModel('member'); diff --git a/modules/communication/lang/en.php b/modules/communication/lang/en.php index 7253ba082..6299e2912 100644 --- a/modules/communication/lang/en.php +++ b/modules/communication/lang/en.php @@ -26,6 +26,7 @@ $lang->cmd_add_friend_group = 'Add Friend Group'; $lang->cmd_rename_friend_group = 'Rename Friend Group'; $lang->cmd_delete_friend_group = 'Delete Friend Group'; $lang->msg_already_friend = 'You are already friends with this person.'; +$lang->msg_no_self_friend = 'You cannot add yourself as a friend.'; $lang->msg_no_message = 'There is no message.'; $lang->msg_cannot_send_to_yourself = 'Cannot send a message to yourself.'; $lang->message_received = 'You have a new message.'; diff --git a/modules/communication/lang/ko.php b/modules/communication/lang/ko.php index f03f29d31..c575059f1 100644 --- a/modules/communication/lang/ko.php +++ b/modules/communication/lang/ko.php @@ -26,6 +26,7 @@ $lang->cmd_add_friend_group = '친구 그룹 생성'; $lang->cmd_rename_friend_group = '친구 그룹 이름 변경'; $lang->cmd_delete_friend_group = '친구 그룹 삭제'; $lang->msg_already_friend = '이미 친구로 등록되어 있습니다.'; +$lang->msg_no_self_friend = '자신을 친구로 등록할 수 없습니다.'; $lang->msg_no_message = '쪽지가 없습니다.'; $lang->msg_cannot_send_to_yourself = '자기 자신에게 쪽지를 보낼 수 없습니다.'; $lang->message_received = '쪽지가 왔습니다.';