Also support plain window for adding friend & friend group #2154

This commit is contained in:
Kijin Sung 2023-07-17 21:50:04 +09:00
parent e635970c6a
commit 64b2918559
6 changed files with 95 additions and 30 deletions

View file

@ -76,6 +76,8 @@
'dispCommunicationFriend',
'dispCommunicationMessages',
'dispCommunicationSendMessage',
'dispCommunicationAddFriend',
'dispCommunicationAddFriendGroup',
'dispNcenterliteUserConfig',
'dispNcenterliteNotifyList',
'dispNcenterliteUnsubscribeList',

View file

@ -593,13 +593,20 @@ class communicationController extends communication
if(!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON')))
{
global $lang;
htmlHeader();
alertScript($lang->success_registed);
closePopupScript();
htmlFooter();
Context::close();
exit;
if (Context::get('window_type') === 'self')
{
$this->setRedirectUrl(getNotEncodedUrl('', 'act', 'dispCommunicationFriend'));
}
else
{
global $lang;
htmlHeader();
alertScript($lang->success_registed);
closePopupScript();
htmlFooter();
Context::close();
exit;
}
}
}
@ -767,13 +774,20 @@ class communicationController extends communication
{
if(!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON')))
{
global $lang;
htmlHeader();
alertScript($lang->fail_to_registed);
closePopupScript();
htmlFooter();
Context::close();
exit;
if (Context::get('window_type') === 'self')
{
$this->setRedirectUrl(getNotEncodedUrl('', 'act', 'dispCommunicationFriend'));
}
else
{
global $lang;
htmlHeader();
alertScript($lang->fail_to_registed);
closePopupScript();
htmlFooter();
Context::close();
exit;
}
}
else
{
@ -784,14 +798,21 @@ class communicationController extends communication
{
if(!in_array(Context::getRequestMethod(), array('XMLRPC', 'JSON')))
{
global $lang;
htmlHeader();
alertScript($lang->success_registed);
reload(true);
closePopupScript();
htmlFooter();
Context::close();
exit;
if (Context::get('window_type') === 'self')
{
$this->setRedirectUrl(getNotEncodedUrl('', 'act', 'dispCommunicationFriend'));
}
else
{
global $lang;
htmlHeader();
alertScript($lang->success_registed);
reload(true);
closePopupScript();
htmlFooter();
Context::close();
exit;
}
}
else
{
@ -976,13 +997,15 @@ class communicationController extends communication
// Add a menu for sending message
if($config->enable_message == 'Y' && ($logged_info->is_admin == 'Y' || $target_member_info->allow_message == 'Y' || ($target_member_info->allow_message == 'F' && $oCommunicationModel->isFriend($member_srl))))
{
$oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationSendMessage', 'receiver_srl', $member_srl), 'cmd_send_message', '', 'popup');
$url = getUrl('', 'mid', $mid, 'act', 'dispCommunicationSendMessage', 'receiver_srl', $member_srl, 'window_type', 'self');
$oMemberController->addMemberPopupMenu($url, 'cmd_send_message', '', 'self');
}
// Add a menu for listing friends (if a friend is new)
if($config->enable_friend == 'Y' && !$oCommunicationModel->isAddedFriend($member_srl))
{
$oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationAddFriend', 'target_srl', $member_srl), 'cmd_add_friend', '', 'popup');
$url = getUrl('', 'mid', $mid, 'act', 'dispCommunicationAddFriend', 'target_srl', $member_srl, 'window_type', 'self');
$oMemberController->addMemberPopupMenu($url, 'cmd_add_friend', '', 'self');
}
}
}

View file

@ -374,8 +374,22 @@ class communicationView extends communication
*/
function dispCommunicationAddFriend()
{
$this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("popup_layout");
// If window type is self, use member module layout.
// Otherwise, assume it's a popup window on PC for backward compatibility.
if(Context::get('window_type') === 'self')
{
$oMemberView = MemberView::getInstance();
if (!$oMemberView->checkMidAndRedirect())
{
$this->setRedirectUrl($oMemberView->getRedirectUrl());
return;
}
}
elseif(!Context::get('m'))
{
$this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("popup_layout");
}
if($this->config->enable_friend == 'N')
{
@ -432,8 +446,22 @@ class communicationView extends communication
*/
function dispCommunicationAddFriendGroup()
{
$this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("popup_layout");
// If window type is self, use member module layout.
// Otherwise, assume it's a popup window on PC for backward compatibility.
if(Context::get('window_type') === 'self')
{
$oMemberView = MemberView::getInstance();
if (!$oMemberView->checkMidAndRedirect())
{
$this->setRedirectUrl($oMemberView->getRedirectUrl());
return;
}
}
elseif(!Context::get('m'))
{
$this->setLayoutPath('./common/tpl/');
$this->setLayoutFile("popup_layout");
}
if($this->config->enable_friend == 'N')
{

View file

@ -1,6 +1,11 @@
<load target="filter/add_friend.xml" />
<load target="css/communication.css" />
<load target="js/communication.js" />
<!--@if(isset($window_type) && $window_type === 'self')-->
<include target="./common_header.html" />
<!--@endif-->
<div class="xc">
<h1>{$lang->cmd_add_friend}</h1>
<div cond="$XE_VALIDATOR_MESSAGE && $XE_VALIDATOR_ID == 'modules/communication/skins/default/add_friend/1'" class="message {$XE_VALIDATOR_MESSAGE_TYPE}">
@ -11,6 +16,7 @@
<input type="hidden" name="act" value="procCommunicationAddFriend" />
<input type="hidden" name="target_srl" value="{$target_info->member_srl}" />
<input type="hidden" name="xe_validator_id" value="modules/communication/skins/default/add_friend/1" />
<input type="hidden" name="window_type" value="{escape($window_type ?? '')}" />
<table class="table table-striped table-hover">
<tr>
<th scope="row">{$lang->nick_name}</th>
@ -22,7 +28,7 @@
<select name="friend_group_srl" id="friend_group_srl">
<option value="">{$lang->default_friend_group}</option>
<option loop="$friend_group_list => $key,$val" value="{$val->friend_group_srl}">{$val->title}</option>
</select>
</select>
<a href="{getUrl('act','dispCommunicationAddFriendGroup')}" class="btn" onclick="popopen(this.href);return false;">{$lang->cmd_add_friend_group}</a>
</td>
</tr>

View file

@ -1,5 +1,10 @@
<load target="css/communication.css" />
<load target="js/communication.js" />
<!--@if(isset($window_type) && $window_type === 'self')-->
<include target="./common_header.html" />
<!--@endif-->
<div class="xc">
<h1 style="border-bottom:1px solid #ccc">
<!--@if($friend_group->friend_group_srl)-->
@ -16,6 +21,7 @@
<input type="hidden" name="act" value="procCommunicationAddFriendGroup" />
<input type="hidden" name="friend_group_srl" value="{$friend_group->friend_group_srl}" />
<input type="hidden" name="xe_validator_id" value="modules/communication/skins/default/add_friend_group/1" />
<input type="hidden" name="window_type" value="{escape($window_type ?? '')}" />
<div class="control-group">
<label for="title" class="control-label">{$lang->msg_insert_group_name}</label>
<div class="controls"><input name="title" id="title" type="text" value="{htmlspecialchars($friend_group->title, ENT_COMPAT | ENT_HTML401, 'UTF-8', false)}"/></div>

View file

@ -26,7 +26,7 @@
<span class="btn-group">
<button type="button" class="btn" cond="count($friend_group_list)" onclick="doRenameFriendGroup();return false;">{$lang->cmd_rename_friend_group}</button>
<button type="button" class="btn" cond="count($friend_group_list)" onclick="doDeleteFriendGroup();return false;">{$lang->cmd_delete_friend_group}</button>
<a href="{getUrl('','module','communication','act','dispCommunicationAddFriendGroup')}" class="btn" onclick="popopen(this.href);return false;">{$lang->cmd_add_friend_group}</a>
<a href="{getUrl('','module','communication','act','dispCommunicationAddFriendGroup','window_type','self')}" class="btn">{$lang->cmd_add_friend_group}</a>
</span>
</div>