From afdc450b00985a59cb25121c9f56c6448a9e0877 Mon Sep 17 00:00:00 2001 From: Kijin Sung Date: Tue, 20 Dec 2022 01:27:19 +0900 Subject: [PATCH] Fix #1877 allow moving archived messages back to the inbox --- .../communication.controller.php | 47 +++++++++++++++++-- modules/communication/conf/module.xml | 1 + modules/communication/lang/en.php | 4 +- modules/communication/lang/ko.php | 2 + .../queries/setMessageStored.xml | 2 +- .../skins/default/js/communication.js | 16 +++++-- .../communication/skins/default/messages.html | 1 + 7 files changed, 64 insertions(+), 9 deletions(-) diff --git a/modules/communication/communication.controller.php b/modules/communication/communication.controller.php index 66f9b1cef..8838d8a4d 100644 --- a/modules/communication/communication.controller.php +++ b/modules/communication/communication.controller.php @@ -261,8 +261,7 @@ class communicationController extends communication } /** - * store a specific message into the archive - * @return void|Object (success : void, fail : Object) + * Move a message to the archive. */ function procCommunicationStoreMessage() { @@ -283,7 +282,7 @@ class communicationController extends communication // get the message $oCommunicationModel = getModel('communication'); $message = $oCommunicationModel->getSelectedMessage($message_srl); - if(!$message || $message->message_type != 'R') + if(!$message || $message->receiver_srl !== $logged_info->member_srl || $message->message_type != 'R') { throw new Rhymix\Framework\Exceptions\InvalidRequest; } @@ -297,7 +296,47 @@ class communicationController extends communication return $output; } $this->updateFlagFile($logged_info->member_srl); - $this->setMessage('success_registed'); + $this->setMessage('msg_success_moved'); + } + + /** + * Restore an archived message to the inbox. + */ + function procCommunicationRestoreMessage() + { + // Check login information + if(!Context::get('is_logged')) + { + throw new Rhymix\Framework\Exceptions\MustLogin; + } + $logged_info = Context::get('logged_info'); + + // Check variable + $message_srl = Context::get('message_srl'); + if(!$message_srl) + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; + } + + // get the message + $oCommunicationModel = getModel('communication'); + $message = $oCommunicationModel->getSelectedMessage($message_srl); + if(!$message || $message->receiver_srl !== $logged_info->member_srl || $message->message_type != 'T') + { + throw new Rhymix\Framework\Exceptions\InvalidRequest; + } + + $args = new stdClass(); + $args->message_srl = $message_srl; + $args->receiver_srl = $logged_info->member_srl; + $args->message_type = 'R'; + $output = executeQuery('communication.setMessageStored', $args); + if(!$output->toBool()) + { + return $output; + } + $this->updateFlagFile($logged_info->member_srl); + $this->setMessage('msg_success_moved'); } /** diff --git a/modules/communication/conf/module.xml b/modules/communication/conf/module.xml index 51fe0c009..8b2688388 100644 --- a/modules/communication/conf/module.xml +++ b/modules/communication/conf/module.xml @@ -13,6 +13,7 @@ + diff --git a/modules/communication/lang/en.php b/modules/communication/lang/en.php index 9c20e521d..55c4b88cc 100644 --- a/modules/communication/lang/en.php +++ b/modules/communication/lang/en.php @@ -21,7 +21,8 @@ $lang->cmd_view_friend = 'Friends'; $lang->cmd_add_friend = 'Add Friend'; $lang->cmd_message_box = 'Message Box'; $lang->cmd_view_message_box = 'Message Box'; -$lang->cmd_store = 'Save'; +$lang->cmd_store = 'Move to Archive'; +$lang->cmd_restore_to_inbox = 'Move to Inbox'; $lang->cmd_view_selected_frend_group = 'View only selected group'; $lang->cmd_add_friend_group = 'Add Friend Group'; $lang->cmd_rename_friend_group = 'Rename Friend Group'; @@ -31,6 +32,7 @@ $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.'; +$lang->msg_success_moved = 'Successfully moved.'; $lang->msg_title_is_null = 'Please enter the title of message.'; $lang->msg_content_is_null = 'Please enter the content.'; $lang->msg_allow_message_to_friend = 'Failed to send a message because the recipient accepts messages from friends only.'; diff --git a/modules/communication/lang/ko.php b/modules/communication/lang/ko.php index 1b9dbbeb4..43a6f182b 100644 --- a/modules/communication/lang/ko.php +++ b/modules/communication/lang/ko.php @@ -22,6 +22,7 @@ $lang->cmd_add_friend = '친구 등록'; $lang->cmd_message_box = '쪽지함'; $lang->cmd_view_message_box = '쪽지함 보기'; $lang->cmd_store = '보관함 이동'; +$lang->cmd_restore_to_inbox = '받은 쪽지함 이동'; $lang->cmd_view_selected_frend_group = '선택된 그룹만 보기'; $lang->cmd_add_friend_group = '친구 그룹 생성'; $lang->cmd_rename_friend_group = '친구 그룹 이름 변경'; @@ -31,6 +32,7 @@ $lang->msg_no_self_friend = '자신을 친구로 등록할 수 없습니다.'; $lang->msg_no_message = '쪽지가 없습니다.'; $lang->msg_cannot_send_to_yourself = '자기 자신에게 쪽지를 보낼 수 없습니다.'; $lang->message_received = '쪽지가 왔습니다.'; +$lang->msg_success_moved = '이동했습니다.'; $lang->msg_title_is_null = '쪽지 제목을 입력해주세요.'; $lang->msg_content_is_null = '내용을 입력해주세요.'; $lang->msg_allow_message_to_friend = '친구에게만 쪽지 발송을 허용한 사용자라서 쪽지 발송을 하지 못했습니다.'; diff --git a/modules/communication/queries/setMessageStored.xml b/modules/communication/queries/setMessageStored.xml index 440ba29af..b2170d00c 100644 --- a/modules/communication/queries/setMessageStored.xml +++ b/modules/communication/queries/setMessageStored.xml @@ -3,7 +3,7 @@ - + diff --git a/modules/communication/skins/default/js/communication.js b/modules/communication/skins/default/js/communication.js index 99033abc7..a80f07253 100644 --- a/modules/communication/skins/default/js/communication.js +++ b/modules/communication/skins/default/js/communication.js @@ -27,10 +27,20 @@ function completeDeleteMessage(ret_obj) { /* 개별 쪽지 보관 */ function doStoreMessage(message_srl) { if(!message_srl) return; + var params = { message_srl: message_srl }; + exec_json('communication.procCommunicationStoreMessage', params, function(data) { + alert(data.message); + location.href = current_url.setQuery('message_type', 'T'); + }); +} - var params = new Array(); - params['message_srl'] = message_srl; - exec_xml('communication', 'procCommunicationStoreMessage', params, completeStoreMessage); +function doRestoreMessage(message_srl) { + if(!message_srl) return; + var params = { message_srl: message_srl }; + exec_json('communication.procCommunicationRestoreMessage', params, function(data) { + alert(data.message); + location.href = current_url.setQuery('message_type', 'R'); + }); } function completeStoreMessage(ret_obj) { diff --git a/modules/communication/skins/default/messages.html b/modules/communication/skins/default/messages.html index ec2df2f9f..7ad2fb4c8 100644 --- a/modules/communication/skins/default/messages.html +++ b/modules/communication/skins/default/messages.html @@ -47,6 +47,7 @@
+