From e75983768f10755d12458e25b53dc43240bf8f45 Mon Sep 17 00:00:00 2001 From: MinSoo Kim Date: Mon, 25 May 2015 02:32:47 +0900 Subject: [PATCH] Communication module mobile support enhancement MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 쪽지 모듈의 모바일 지원을 향상시켰습니다. 이 PR 이후에 회원 모듈의 모바일 지원을 향상 시키면 XE의 모바일 지원 수준이 한 단계 상승하게 됩니다. 꼭 반영되길 바랍니다! ## 수정 내용 * 커뮤니케이션 애드온의 회원 메뉴 설정 기능을 모듈의 트리거로 처리하여 조금 더 직관적으로 설정하게 됨. * 기본값은 모듈이 동작 하도록 함. * 모듈을 켜고 끌 수 있도록 함. * 모바일에서 친구 추가를 할 수 있게 함. * 스타일 아주 조금 다듬음. --- .../member_communication.addon.php | 42 ---------- .../communication.admin.controller.php | 79 ++++++++++++------- modules/communication/communication.class.php | 60 +++++++++++++- .../communication.controller.php | 75 ++++++++++++++++++ .../communication/communication.mobile.php | 67 ++++++++++++++++ modules/communication/communication.model.php | 6 +- modules/communication/lang/lang.xml | 22 ++++++ .../m.skins/default/add_friend.html | 31 ++++++++ .../m.skins/default/add_friend_group.html | 30 +++++++ .../m.skins/default/css/mcommunication.css | 2 +- .../m.skins/default/js/communication.js | 47 +++++++++++ modules/communication/ruleset/addFriend.xml | 14 ++-- .../communication/ruleset/addFriendGroup.xml | 11 ++- modules/communication/tpl/index.html | 27 ++++++- 14 files changed, 428 insertions(+), 85 deletions(-) create mode 100644 modules/communication/m.skins/default/add_friend.html create mode 100644 modules/communication/m.skins/default/add_friend_group.html diff --git a/addons/member_communication/member_communication.addon.php b/addons/member_communication/member_communication.addon.php index 8986d8b59..4b2373e84 100644 --- a/addons/member_communication/member_communication.addon.php +++ b/addons/member_communication/member_communication.addon.php @@ -25,13 +25,6 @@ if(!$logged_info|| isCrawler()) * */ if($this->module != 'member' && $called_position == 'before_module_init') { - // Load a language file from the communication module - Context::loadLang(_XE_PATH_ . 'modules/communication/lang'); - // Add menus on the member login information - $oMemberController = getController('member'); - $oMemberController->addMemberMenu('dispCommunicationFriend', 'cmd_view_friend'); - $oMemberController->addMemberMenu('dispCommunicationMessages', 'cmd_view_message_box'); - $flag_file = _XE_PATH_ . 'files/member_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl) . $logged_info->member_srl; if($addon_info->use_alarm != 'N' && file_exists($flag_file)) { @@ -45,40 +38,5 @@ if($this->module != 'member' && $called_position == 'before_module_init') Context::addHtmlFooter(""); } } -elseif($this->act == 'getMemberMenu' && $called_position == 'before_module_proc') -{ - $member_srl = Context::get('target_srl'); - $oCommunicationModel = getModel('communication'); - - // Add a feature to display own message box. - if($logged_info->member_srl == $member_srl) - { - $mid = Context::get('cur_mid'); - $oMemberController = getController('member'); - // Add your own viewing Note Template - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationMessages'), 'cmd_view_message_box', '', 'self'); - // Display a list of friends - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationFriend'), 'cmd_view_friend', '', 'self'); - // If not, Add menus to send message and to add friends - } - else - { - // Get member information - $oMemberModel = getModel('member'); - $target_member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl); - if(!$target_member_info->member_srl) - { - return; - } - - $oMemberController = getController('member'); - // Add a menu for sending message - if($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', Context::get('cur_mid'), 'act', 'dispCommunicationSendMessage', 'receiver_srl', $member_srl), 'cmd_send_message', '', 'popup'); - // Add a menu for listing friends (if a friend is new) - if(!$oCommunicationModel->isAddedFriend($member_srl)) - $oMemberController->addMemberPopupMenu(getUrl('', 'mid', Context::get('cur_mid'), 'act', 'dispCommunicationAddFriend', 'target_srl', $member_srl), 'cmd_add_friend', '', 'popup'); - } -} /* End of file member_communication.addon.php */ /* Location: ./addons/member_communication/member_communication.addon.php */ diff --git a/modules/communication/communication.admin.controller.php b/modules/communication/communication.admin.controller.php index 1f9e8b028..829e789da 100644 --- a/modules/communication/communication.admin.controller.php +++ b/modules/communication/communication.admin.controller.php @@ -23,41 +23,66 @@ class communicationAdminController extends communication */ function procCommunicationAdminInsertConfig() { + // Get the configuration information + $oModuleModel = getModel('module'); + $config = $oModuleModel->getModuleConfig('communication'); + // get the default information - $args = Context::gets('skin', 'colorset', 'editor_skin', 'sel_editor_colorset', 'mskin', 'mcolorset', 'layout_srl', 'mlayout_srl', 'grant_write_default','grant_write_group'); - $args->editor_colorset = $args->sel_editor_colorset; - unset($args->sel_editor_colorset); + $args = Context::gets('able_module', 'skin', 'colorset', 'editor_skin', 'sel_editor_colorset', 'mskin', 'mcolorset', 'layout_srl', 'mlayout_srl', 'grant_write_default','grant_write_group'); - if(!$args->skin) + //if module IO config is off + if($args->able_module === 'Y') { - $args->skin = 'default'; - } + // Re-install triggers, if it was disabled. + if($config->able_module == 'N') + { + $this->moduleUpdate(); + } - if(!$args->colorset) + $args->editor_colorset = $args->sel_editor_colorset; + unset($args->sel_editor_colorset); + + if(!$args->skin) + { + $args->skin = 'default'; + } + + if(!$args->colorset) + { + $args->colorset = 'white'; + } + + if(!$args->editor_skin) + { + $args->editor_skin = 'default'; + } + + if(!$args->mskin) + { + $args->mskin = 'default'; + } + + if(!$args->layout_srl) + { + $args->layout_srl = NULL; + } + + $oCommunicationModel = getModel('communication'); + $args->grant_write = $oCommunicationModel->getGrantArray($args->grant_write_default, $args->grant_write_group); + unset($args->grant_write_default); + unset($args->grant_write_group); + } + else { - $args->colorset = 'white'; - } + //module IO config is OFF, Other settings will not be modified. + $config->able_module = 'N'; + $args = $config; - if(!$args->editor_skin) - { - $args->editor_skin = 'default'; + // Delete Triggers + $oModuleController = getController('module'); + $oModuleController->deleteModuleTriggers('communication'); } - if(!$args->mskin) - { - $args->mskin = 'default'; - } - - if(!$args->layout_srl) - { - $args->layout_srl = NULL; - } - - $oCommunicationModel = getModel('communication'); - $args->grant_write = $oCommunicationModel->getGrantArray($args->grant_write_default, $args->grant_write_group); - unset($args->grant_write_default); - unset($args->grant_write_group); - // create the module module Controller object $oModuleController = getController('module'); $output = $oModuleController->insertModuleConfig('communication', $args); diff --git a/modules/communication/communication.class.php b/modules/communication/communication.class.php index 155fd6413..44848c08c 100644 --- a/modules/communication/communication.class.php +++ b/modules/communication/communication.class.php @@ -8,6 +8,10 @@ */ class communication extends ModuleObject { + var $triggers = array( + array('member.getMemberMenu', 'communication', 'controller', 'triggerBeforeMemberPopupMenu', 'before'), + array('moduleHandler.init', 'communication', 'controller', 'triggerAddMemberMenu', 'after') + ); /** * Implement if additional tasks are necessary when installing @@ -15,8 +19,32 @@ class communication extends ModuleObject */ function moduleInstall() { + $oModuleModel = getModel('module'); + $oModuleController = getController('module'); + + // Create triggers + foreach($this->triggers as $trigger) + { + if(!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) + { + $oModuleController->insertTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]); + } + } + // Create a temporary file storage for one new private message notification FileHandler::makeDir('./files/member_extra_info/new_message_flags'); + + // Save Default Config. + $config = new stdClass; + $config->able_module = 'Y'; + $config->skin = 'default'; + $config->colorset = 'white'; + $config->editor_skin = 'default'; + $communication_config->mskin = 'default'; + $communication_config->grant_write = array('default_grant'=>'member'); + + // Save configurations + $oModuleController->insertModuleConfig('communication', $config); return new Object(); } @@ -32,6 +60,7 @@ class communication extends ModuleObject } $oModuleModel = getModel('module'); + $oModuleController = getController('module'); $config = $oModuleModel->getModuleConfig('message'); if($config->skin) @@ -46,6 +75,13 @@ class communication extends ModuleObject } } } + + // Create triggers + foreach($this->triggers as $trigger) + { + if(!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) return true; + } + return FALSE; } @@ -61,6 +97,7 @@ class communication extends ModuleObject } $oModuleModel = getModel('module'); + $oModuleController = getController('module'); $config = $oModuleModel->getModuleConfig('message'); if(!is_object($config)) { @@ -81,7 +118,16 @@ class communication extends ModuleObject } } } - + + // Create triggers + foreach($this->triggers as $trigger) + { + if(!$oModuleModel->getTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4])) + { + $oModuleController->insertTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]); + } + } + return new Object(0, 'success_updated'); } @@ -91,9 +137,19 @@ class communication extends ModuleObject */ function recompileCache() { - } + + function moduleUninstall() + { + $oModuleController = getController('module'); + + foreach($this->triggers as $trigger) + { + $oModuleController->deleteTrigger($trigger[0], $trigger[1], $trigger[2], $trigger[3], $trigger[4]); + } + return new Object(); + } } /* End of file communication.class.php */ /* Location: ./modules/comment/communication.class.php */ diff --git a/modules/communication/communication.controller.php b/modules/communication/communication.controller.php index 69cba0d09..9a90bc6a3 100644 --- a/modules/communication/communication.controller.php +++ b/modules/communication/communication.controller.php @@ -775,6 +775,81 @@ class communicationController extends communication return executeQuery('communication.setMessageReaded', $args); } + /** + * Create communication module menu on the member menu + * @param int $message_srl + * @return Object + */ + public function triggerAddMemberMenu() + { + // Stop if non-logged-in user is + $logged_info = Context::get('logged_info'); + if(!$logged_info|| isCrawler()) + { + return new Object(); + } + + $oCommunicationModel = getModel('communication'); + $config = $oCommunicationModel->getConfig(); + + if($config->able_module === 'Y') + { + $oMemberController = getController('member'); + $oMemberController->addMemberMenu('dispCommunicationFriend', 'cmd_view_friend'); + $oMemberController->addMemberMenu('dispCommunicationMessages', 'cmd_view_message_box'); + } + + return new Object(); + } + + /** + * Create communication module menu on the member popup menu + * @param int $message_srl + * @return Object + */ + public function triggerBeforeMemberPopupMenu() + { + // Stop if non-logged-in user is + $logged_info = Context::get('logged_info'); + if(!$logged_info|| isCrawler()) + { + return; + } + + $member_srl = Context::get('target_srl'); + $oCommunicationModel = getModel('communication'); + + // Add a feature to display own message box. + if($logged_info->member_srl == $member_srl) + { + $mid = Context::get('cur_mid'); + $oMemberController = getController('member'); + // Add your own viewing Note Template + $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationMessages'), 'cmd_view_message_box', '', 'self'); + // Display a list of friends + $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationFriend'), 'cmd_view_friend', '', 'self'); + // If not, Add menus to send message and to add friends + } + else + { + // Get member information + $oMemberModel = getModel('member'); + $target_member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl); + if(!$target_member_info->member_srl) + { + return; + } + + $oMemberController = getController('member'); + // Add a menu for sending message + if($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', Context::get('cur_mid'), 'act', 'dispCommunicationSendMessage', 'receiver_srl', $member_srl), 'cmd_send_message', '', 'popup'); + // Add a menu for listing friends (if a friend is new) + if(!$oCommunicationModel->isAddedFriend($member_srl)) + $oMemberController->addMemberPopupMenu(getUrl('', 'mid', Context::get('cur_mid'), 'act', 'dispCommunicationAddFriend', 'target_srl', $member_srl), 'cmd_add_friend', '', 'popup'); + } + } + } /* End of file communication.controller.php */ /* Location: ./modules/comment/communication.controller.php */ diff --git a/modules/communication/communication.mobile.php b/modules/communication/communication.mobile.php index d846f4cca..1f32166a9 100644 --- a/modules/communication/communication.mobile.php +++ b/modules/communication/communication.mobile.php @@ -182,6 +182,73 @@ class communicationMobile extends communicationView $this->setTemplateFile('send_message'); } + /** + * display Add a friend + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationAddFriend() + { + // error appears if not logged-in + if(!Context::get('is_logged')) + { + return $this->stop('msg_not_logged'); + } + + $logged_info = Context::get('logged_info'); + $target_srl = Context::get('target_srl'); + + if(!$target_srl) + { + return $this->stop('msg_invalid_request'); + } + + // get information of the member + $oMemberModel = getModel('member'); + $oCommunicationModel = getModel('communication'); + $communication_info = $oMemberModel->getMemberInfoByMemberSrl($target_srl); + + if($communication_info->member_srl != $target_srl) + { + return $this->stop('msg_invalid_request'); + } + + Context::set('target_info', $communication_info); + + // get a group list + $friend_group_list = $oCommunicationModel->getFriendGroups(); + Context::set('friend_group_list', $friend_group_list); + + $this->setTemplateFile('add_friend'); + } + + /** + * display add a group of friends + * @return void|Object (void : success, Object : fail) + */ + function dispCommunicationAddFriendGroup() + { + // error apprears if not logged-in + if(!Context::get('is_logged')) + { + return $this->stop('msg_not_logged'); + } + + $logged_info = Context::get('logged_info'); + + // change to edit mode when getting the group_srl + $friend_group_srl = Context::get('friend_group_srl'); + if($friend_group_srl) + { + $oCommunicationModel = getModel('communication'); + $friend_group = $oCommunicationModel->getFriendGroupInfo($friend_group_srl); + if($friend_group->friend_group_srl == $friend_group_srl) + { + Context::set('friend_group', $friend_group); + } + } + + $this->setTemplateFile('add_friend_group'); + } } /* End of file communication.mobile.php */ /* Location: ./modules/comment/communication.mobile.php */ diff --git a/modules/communication/communication.model.php b/modules/communication/communication.model.php index 46e262fd3..d66e115aa 100644 --- a/modules/communication/communication.model.php +++ b/modules/communication/communication.model.php @@ -51,12 +51,16 @@ class communicationModel extends communication { $communication_config->mskin = 'default'; } - + if(!$communication_config->grant_write) { $communication_config->grant_write = array('default_grant'=>'member'); } + if(!$communication_config->able_module) + { + $communication_config->able_module = 'Y'; + } return $communication_config; } diff --git a/modules/communication/lang/lang.xml b/modules/communication/lang/lang.xml index d4bac684f..05d9ade79 100644 --- a/modules/communication/lang/lang.xml +++ b/modules/communication/lang/lang.xml @@ -10,6 +10,28 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/modules/communication/m.skins/default/add_friend.html b/modules/communication/m.skins/default/add_friend.html new file mode 100644 index 000000000..fd3679ed9 --- /dev/null +++ b/modules/communication/m.skins/default/add_friend.html @@ -0,0 +1,31 @@ + + +
+

{$lang->cmd_add_friend}

+
+
+

{$XE_VALIDATOR_MESSAGE}

+
+
+ + + + + +
+ +
+
\ No newline at end of file diff --git a/modules/communication/m.skins/default/add_friend_group.html b/modules/communication/m.skins/default/add_friend_group.html new file mode 100644 index 000000000..dc2cde80b --- /dev/null +++ b/modules/communication/m.skins/default/add_friend_group.html @@ -0,0 +1,30 @@ + + +
+

+ + {$lang->cmd_rename_friend_group} + + {$lang->cmd_add_friend_group} + +

+
+
+

{$XE_VALIDATOR_MESSAGE}

+
+
+ + + + +
    +
  • + + +
  • +
+
+ + +
+
diff --git a/modules/communication/m.skins/default/css/mcommunication.css b/modules/communication/m.skins/default/css/mcommunication.css index 7d803cbab..8f7fc8b90 100644 --- a/modules/communication/m.skins/default/css/mcommunication.css +++ b/modules/communication/m.skins/default/css/mcommunication.css @@ -100,7 +100,7 @@ input[type=radio]{width:13px;height:13px;margin:0;padding:0} .ff label+input[type=text], .ff label+input[type=password], .ff label+textarea, -.ff label+select{display:block;width:96%;font-size:14px;margin:0 0 5px 0} +.ff label+select{display:block;box-sizing:border-box;width:100%;font-size:14px;margin:0 0 5px 0} .ff label+input[type=text], .ff label+input[type=password], .ff label+textarea{padding:5px} diff --git a/modules/communication/m.skins/default/js/communication.js b/modules/communication/m.skins/default/js/communication.js index e37272d41..07934c2f0 100644 --- a/modules/communication/m.skins/default/js/communication.js +++ b/modules/communication/m.skins/default/js/communication.js @@ -20,3 +20,50 @@ function mergeContents() $form.find('input[name=content]').val(content); $form.submit(); } + +/* 친구 그룹 삭제 */ +function doDeleteFriendGroup() { + var friend_group_srl = jQuery('#friend_group_list option:selected').val(); + if(!friend_group_srl) return; + + var fo_obj = jQuery('#for_delete_group').get(0); + fo_obj.friend_group_srl.value = friend_group_srl; + + procFilter(fo_obj, delete_friend_group); +} + +function completeDeleteFriendGroup(ret_obj) { + alert(ret_obj['message']); + location.href = current_url.setQuery('friend_group_srl',''); +} + +/* 친구 그룹의 이름 변경 */ +function doRenameFriendGroup() { + var friend_group_srl = jQuery('#friend_group_list option:selected').val(); + if(!friend_group_srl) return; + + popopen("./?module=communication&act=dispCommunicationAddFriendGroup&friend_group_srl="+friend_group_srl); +} + +/* 친구 그룹 이동 */ +function doMoveFriend() { + var fo_obj = jQuery('#fo_friend_list').get(0); + procFilter(fo_obj, move_friend); +} + +/* 친구 그룹 선택 */ +function doJumpFriendGroup() { + var sel_val = jQuery('#jumpMenu option:selected').val(); + location.href = current_url.setQuery('friend_group_srl', sel_val); +} + +jQuery(function($){ + $('.__submit_group button[type=submit]').click(function(e){ + var sel_val = $('input[name="friend_srl_list[]"]:checked').length; + if(sel_val == 0) + { + e.preventDefault(); + return false; + } + }); +}); diff --git a/modules/communication/ruleset/addFriend.xml b/modules/communication/ruleset/addFriend.xml index 27e72cf1e..94b2daa9c 100644 --- a/modules/communication/ruleset/addFriend.xml +++ b/modules/communication/ruleset/addFriend.xml @@ -1,7 +1,11 @@ - + - - - - + + + + + + + + diff --git a/modules/communication/ruleset/addFriendGroup.xml b/modules/communication/ruleset/addFriendGroup.xml index b65ad171e..1bcb89fcb 100644 --- a/modules/communication/ruleset/addFriendGroup.xml +++ b/modules/communication/ruleset/addFriendGroup.xml @@ -1,8 +1,11 @@ - - - + + + + + + - + diff --git a/modules/communication/tpl/index.html b/modules/communication/tpl/index.html index 7f21fa105..706f8d2ed 100644 --- a/modules/communication/tpl/index.html +++ b/modules/communication/tpl/index.html @@ -15,11 +15,18 @@

{$XE_VALIDATOR_MESSAGE}

-
+ +
+ +
+ + {$lang->about_communication_io} +
+
@@ -105,10 +112,24 @@
+ jQuery(function($){ + var communication_module_cfg = $('#communication_module_config_form .x_control-group:not(.module_io)'); + if(!$('#able_module').is(':checked')) + { + communication_module_cfg.hide(); + } + $('#able_module').change(function(){ + if($(this).is(':checked')){ + communication_module_cfg.slideDown(200); + } else { + communication_module_cfg.slideUp(200); + } + }); +}); + \ No newline at end of file