Fix #1877 allow moving archived messages back to the inbox

This commit is contained in:
Kijin Sung 2022-12-20 01:27:19 +09:00
parent 8b6e1949b0
commit afdc450b00
7 changed files with 64 additions and 9 deletions

View file

@ -261,8 +261,7 @@ class communicationController extends communication
} }
/** /**
* store a specific message into the archive * Move a message to the archive.
* @return void|Object (success : void, fail : Object)
*/ */
function procCommunicationStoreMessage() function procCommunicationStoreMessage()
{ {
@ -283,7 +282,7 @@ class communicationController extends communication
// get the message // get the message
$oCommunicationModel = getModel('communication'); $oCommunicationModel = getModel('communication');
$message = $oCommunicationModel->getSelectedMessage($message_srl); $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; throw new Rhymix\Framework\Exceptions\InvalidRequest;
} }
@ -297,7 +296,47 @@ class communicationController extends communication
return $output; return $output;
} }
$this->updateFlagFile($logged_info->member_srl); $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');
} }
/** /**

View file

@ -13,6 +13,7 @@
<action name="procCommunicationUpdateAllowMessage" type="controller" permission="member" /> <action name="procCommunicationUpdateAllowMessage" type="controller" permission="member" />
<action name="procCommunicationSendMessage" type="controller" permission="member" ruleset="sendMessage" /> <action name="procCommunicationSendMessage" type="controller" permission="member" ruleset="sendMessage" />
<action name="procCommunicationStoreMessage" type="controller" permission="member" /> <action name="procCommunicationStoreMessage" type="controller" permission="member" />
<action name="procCommunicationRestoreMessage" type="controller" permission="member" />
<action name="procCommunicationDeleteMessage" type="controller" permission="member" /> <action name="procCommunicationDeleteMessage" type="controller" permission="member" />
<action name="procCommunicationDeleteMessages" type="controller" permission="member" /> <action name="procCommunicationDeleteMessages" type="controller" permission="member" />
<action name="procCommunicationAddFriend" type="controller" permission="member" ruleset="addFriend" /> <action name="procCommunicationAddFriend" type="controller" permission="member" ruleset="addFriend" />

View file

@ -21,7 +21,8 @@ $lang->cmd_view_friend = 'Friends';
$lang->cmd_add_friend = 'Add Friend'; $lang->cmd_add_friend = 'Add Friend';
$lang->cmd_message_box = 'Message Box'; $lang->cmd_message_box = 'Message Box';
$lang->cmd_view_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_view_selected_frend_group = 'View only selected group';
$lang->cmd_add_friend_group = 'Add Friend Group'; $lang->cmd_add_friend_group = 'Add Friend Group';
$lang->cmd_rename_friend_group = 'Rename 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_no_message = 'There is no message.';
$lang->msg_cannot_send_to_yourself = 'Cannot send a message to yourself.'; $lang->msg_cannot_send_to_yourself = 'Cannot send a message to yourself.';
$lang->message_received = 'You have a new message.'; $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_title_is_null = 'Please enter the title of message.';
$lang->msg_content_is_null = 'Please enter the content.'; $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.'; $lang->msg_allow_message_to_friend = 'Failed to send a message because the recipient accepts messages from friends only.';

View file

@ -22,6 +22,7 @@ $lang->cmd_add_friend = '친구 등록';
$lang->cmd_message_box = '쪽지함'; $lang->cmd_message_box = '쪽지함';
$lang->cmd_view_message_box = '쪽지함 보기'; $lang->cmd_view_message_box = '쪽지함 보기';
$lang->cmd_store = '보관함 이동'; $lang->cmd_store = '보관함 이동';
$lang->cmd_restore_to_inbox = '받은 쪽지함 이동';
$lang->cmd_view_selected_frend_group = '선택된 그룹만 보기'; $lang->cmd_view_selected_frend_group = '선택된 그룹만 보기';
$lang->cmd_add_friend_group = '친구 그룹 생성'; $lang->cmd_add_friend_group = '친구 그룹 생성';
$lang->cmd_rename_friend_group = '친구 그룹 이름 변경'; $lang->cmd_rename_friend_group = '친구 그룹 이름 변경';
@ -31,6 +32,7 @@ $lang->msg_no_self_friend = '자신을 친구로 등록할 수 없습니다.';
$lang->msg_no_message = '쪽지가 없습니다.'; $lang->msg_no_message = '쪽지가 없습니다.';
$lang->msg_cannot_send_to_yourself = '자기 자신에게 쪽지를 보낼 수 없습니다.'; $lang->msg_cannot_send_to_yourself = '자기 자신에게 쪽지를 보낼 수 없습니다.';
$lang->message_received = '쪽지가 왔습니다.'; $lang->message_received = '쪽지가 왔습니다.';
$lang->msg_success_moved = '이동했습니다.';
$lang->msg_title_is_null = '쪽지 제목을 입력해주세요.'; $lang->msg_title_is_null = '쪽지 제목을 입력해주세요.';
$lang->msg_content_is_null = '내용을 입력해주세요.'; $lang->msg_content_is_null = '내용을 입력해주세요.';
$lang->msg_allow_message_to_friend = '친구에게만 쪽지 발송을 허용한 사용자라서 쪽지 발송을 하지 못했습니다.'; $lang->msg_allow_message_to_friend = '친구에게만 쪽지 발송을 허용한 사용자라서 쪽지 발송을 하지 못했습니다.';

View file

@ -3,7 +3,7 @@
<table name="member_message" /> <table name="member_message" />
</tables> </tables>
<columns> <columns>
<column name="message_type" default="T" /> <column name="message_type" var="message_type" default="T" />
</columns> </columns>
<conditions> <conditions>
<condition operation="equal" column="message_srl" var="message_srl" notnull="notnull" filter="number" /> <condition operation="equal" column="message_srl" var="message_srl" notnull="notnull" filter="number" />

View file

@ -27,10 +27,20 @@ function completeDeleteMessage(ret_obj) {
/* 개별 쪽지 보관 */ /* 개별 쪽지 보관 */
function doStoreMessage(message_srl) { function doStoreMessage(message_srl) {
if(!message_srl) return; 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(); function doRestoreMessage(message_srl) {
params['message_srl'] = message_srl; if(!message_srl) return;
exec_xml('communication', 'procCommunicationStoreMessage', params, completeStoreMessage); 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) { function completeStoreMessage(ret_obj) {

View file

@ -47,6 +47,7 @@
<div class="btnArea btn-group" cond="$message" style="margin-bottom:20px"> <div class="btnArea btn-group" cond="$message" style="margin-bottom:20px">
<button class="btn" cond="$message->message_type != 'S' && $message->member_srl != $logged_info->member_srl" type="button" onclick="doSendMessage('{$message->sender_srl}','{$message->message_srl}');">{$lang->cmd_reply_message}</button> <button class="btn" cond="$message->message_type != 'S' && $message->member_srl != $logged_info->member_srl" type="button" onclick="doSendMessage('{$message->sender_srl}','{$message->message_srl}');">{$lang->cmd_reply_message}</button>
<button class="btn" cond="$message->message_type == 'R'" type="button" onclick="doStoreMessage('{$message->message_srl}');">{$lang->cmd_store}</button> <button class="btn" cond="$message->message_type == 'R'" type="button" onclick="doStoreMessage('{$message->message_srl}');">{$lang->cmd_store}</button>
<button class="btn" cond="$message->message_type == 'T'" type="button" onclick="doRestoreMessage('{$message->message_srl}');">{$lang->cmd_restore_to_inbox}</button>
<button class="btn" type="button" onclick="doDeleteMessage('{$message->message_srl}');">{$lang->cmd_delete}</button> <button class="btn" type="button" onclick="doDeleteMessage('{$message->message_srl}');">{$lang->cmd_delete}</button>
</div> </div>