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..25364e145 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 on
+ 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..760bb75ef 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,17 @@ class communication extends ModuleObject
}
}
}
+
+ // check if module is abled
+ if($config->able_module != 'N')
+ {
+ // Check 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 +101,7 @@ class communication extends ModuleObject
}
$oModuleModel = getModel('module');
+ $oModuleController = getController('module');
$config = $oModuleModel->getModuleConfig('message');
if(!is_object($config))
{
@@ -81,7 +122,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 +141,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 @@
+
+
+