XpressEngine Core  1.11.2
 All Classes Namespaces Files Functions Variables Pages
member_communication.addon.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) NAVER <http://www.navercorp.com> */
3 
4 if(!defined('__XE__'))
5  exit();
6 
16 // Stop if non-logged-in user is
17 $logged_info = Context::get('logged_info');
18 if(!$logged_info|| isCrawler())
19 {
20  return;
21 }
22 
26 if($this->module != 'member' && $called_position == 'before_module_init')
27 {
28  // Load a language file from the communication module
29  Context::loadLang(_XE_PATH_ . 'modules/communication/lang');
30  // Add menus on the member login information
31  $oMemberController = getController('member');
32  $oMemberController->addMemberMenu('dispCommunicationFriend', 'cmd_view_friend');
33  $oMemberController->addMemberMenu('dispCommunicationMessages', 'cmd_view_message_box');
34 
35  $flag_file = _XE_PATH_ . 'files/member_extra_info/new_message_flags/' . getNumberingPath($logged_info->member_srl) . $logged_info->member_srl;
36  if($addon_info->use_alarm != 'N' && file_exists($flag_file))
37  {
38  // Pop-up to display messages if a flag on new message is set
39  $new_message_count = (int) trim(FileHandler::readFile($flag_file));
40  FileHandler::removeFile($flag_file);
41  Context::loadLang(_XE_PATH_ . 'addons/member_communication/lang');
42  Context::loadFile(array('./addons/member_communication/tpl/member_communication.js'), true);
43 
44  $text = preg_replace('@\r?\n@', '\\n', addslashes(Context::getLang('alert_new_message_arrived')));
45  Context::addHtmlFooter("<script type=\"text/javascript\">jQuery(function(){ xeNotifyMessage('{$text}','{$new_message_count}'); });</script>");
46  }
47 }
48 elseif($this->act == 'getMemberMenu' && $called_position == 'before_module_proc')
49 {
50  $member_srl = Context::get('target_srl');
51  $oCommunicationModel = getModel('communication');
52 
53  // Add a feature to display own message box.
54  if($logged_info->member_srl == $member_srl)
55  {
56  $mid = Context::get('cur_mid');
57  $oMemberController = getController('member');
58  // Add your own viewing Note Template
59  $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationMessages'), 'cmd_view_message_box', '', 'self');
60  // Display a list of friends
61  $oMemberController->addMemberPopupMenu(getUrl('', 'mid', $mid, 'act', 'dispCommunicationFriend'), 'cmd_view_friend', '', 'self');
62  // If not, Add menus to send message and to add friends
63  }
64  else
65  {
66  // Get member information
67  $oMemberModel = getModel('member');
68  $target_member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl);
69  if(!$target_member_info->member_srl)
70  {
71  return;
72  }
73 
74  $oMemberController = getController('member');
75  // Add a menu for sending message
76  if($logged_info->is_admin == 'Y' || $target_member_info->allow_message == 'Y' || ($target_member_info->allow_message == 'F' && $oCommunicationModel->isFriend($member_srl)))
77  $oMemberController->addMemberPopupMenu(getUrl('', 'mid', Context::get('cur_mid'), 'act', 'dispCommunicationSendMessage', 'receiver_srl', $member_srl), 'cmd_send_message', '', 'popup');
78  // Add a menu for listing friends (if a friend is new)
79  if(!$oCommunicationModel->isAddedFriend($member_srl))
80  $oMemberController->addMemberPopupMenu(getUrl('', 'mid', Context::get('cur_mid'), 'act', 'dispCommunicationAddFriend', 'target_srl', $member_srl), 'cmd_add_friend', '', 'popup');
81  }
82 }
83 /* End of file member_communication.addon.php */
84 /* Location: ./addons/member_communication/member_communication.addon.php */
getController($module_name)
Definition: func.inc.php:90
getNumberingPath($no, $size=3)
Definition: func.inc.php:1081
loadFile($args)
removeFile($filename)
loadLang($path)
getLang($code)
const _XE_PATH_
Definition: config.inc.php:49
readFile($filename)
getModel($module_name)
Definition: func.inc.php:145
getUrl()
Definition: func.inc.php:297
isCrawler($agent=NULL)
Definition: func.inc.php:1538
addHtmlFooter($footer)
high class of the module module
Definition: module.class.php:8